one_hot_encoder.categories_[0][1] and one-hot_encoder.categories_[0][2], which are Queenstown and Southampton, respectively. As discussed previously, OneHotEncoder(drop=”first”) will drop the first column.
The output of the above program will be:
['Cherbourg' 'Queenstown' 'Southampton'] survived pclass sex age ... alive alone Queenstown Southampton 0 0 3 male 22.0 ... no False 0.0 1.0 1 1 1 female 38.0 ... yes False 0.0 0.0 2 1 3 female 26.0 ... yes True 0.0 1.0 3 1 1 female 35.0 ... yes False 0.0 1.0 4 0 3 male 35.0 ... no True 0.0 1.0 [5 rows x 17 columns]








































0 Comments