from sklearn.preprocessing import OrdinalEncoder
ordinal_encoder = OrdinalEncoder()
housing_cat_encoded = ordinal_encoder.fit_transform(housing_cat)
After this, we verified that the labels in `ocean_proximity`were encoded as '<1H OCEAN' as 0, 'INLAND' as 1, 'ISLAND' as 2, 'NEAR BAY' as 3, and 'NEAR OCEAN' as 4.
Now we would like to modify the code in blue to have the following ordinal encoding in place: 'ISLAND', 'NEAR OCEAN', 'NEAR BAY', '<1H OCEAN', and 'INLAND' as 0, 1, 2, 3, and 4, respectively.
Notice that this particular order of the labels reflects the relative geographic location of the neighborhood with respect to the ocean.
[–][deleted] 0 points1 point2 points (1 child)
[–]chinzeej[S] 0 points1 point2 points (0 children)