
Ultimate access to all questions.
Consider a scenario where you have a dataset with a categorical feature 'Education Level' having categories 'High School', 'Bachelor', 'Master', 'PhD', and missing values. Write a code snippet to perform ordinal encoding on this feature using Python and the scikit-learn library. Explain how this process handles missing values.
A
from sklearn.preprocessing import OrdinalEncoder encoder = OrdinalEncoder(handle_unknown='ignore') encoder.fit(df[['Education Level']]) df['Education Level'] = encoder.transform(df[['Education Level']])_
B
from sklearn.preprocessing import OrdinalEncoder encoder = OrdinalEncoder() encoder.fit(df[['Education Level']]) df['Education Level'] = encoder.transform(df[['Education Level']])
C
from sklearn.preprocessing import OrdinalEncoder encoder = OrdinalEncoder(handle_unknown='error') encoder.fit(df[['Education Level']]) df['Education Level'] = encoder.transform(df[['Education Level']])_
D
from sklearn.preprocessing import OrdinalEncoder encoder = OrdinalEncoder(handle_unknown='use_encoded_value', unknown_value=-1) encoder.fit(df[['Education Level']]) df['Education Level'] = encoder.transform(df[['Education Level']])