from sklearn.preprocessing import OrdinalEncoder enc = OrdinalEncoder(handle_unknown=’use_encoded_value’, unknown_value=-1) enc.fit(X_train) enc.transform(X_test) What is the result of this configuration when encountering an unseen category in the test set?
Key points
- Default OrdinalEncoder behavior raises an error on unknown labels.
- handle_unknown='use_encoded_value' allows custom mapping.
- This is critical for robust production pipelines.
Ready to go further?
