I am currently working on a machine learning assignment, and I am using a tree-based model in scikit-learn. I have categorical features in my dataset, and I want to know if it’s better to use OrdinalEncoder
instead of OneHotEncoder
for my model. I have read that OrdinalEncoder
is more efficient for tree-based models because it preserves the ordinal relationship between categories.
Here’s an example of my code using `OneHotEncoder":
Can someone help me understand how to use OrdinalEncoder instead of OneHotEncoder for my tree-based model? And is it really more efficient for this type of model? Any feedback or suggestions on my code are also appreciated. Thank you!