Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

One Hot Encoder Classes #1

Open
PersianSpock opened this issue Aug 25, 2022 · 0 comments
Open

One Hot Encoder Classes #1

PersianSpock opened this issue Aug 25, 2022 · 0 comments

Comments

@PersianSpock
Copy link

I have a data with 46 classes. Because the 46th class is small in splitting it moves to tet and it doesn't exist in train. now my onehotencoder has 45 classes but after all I need to train my model with 46 classes. What can be done?

from sklearn.preprocessing import OneHotEncoder
num_labels = 46

#creating instance of one-hot-encoder
encoder = OneHotEncoder(handle_unknown='ignore')

#perform one-hot encoding on 'team' column 
e_sh['one_hot_labels'] =list(encoder.fit_transform(e_sh[['Label']]).toarray())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant