0

I have created a ML model with Random forest it has 6000+ data with 27 features out of which about 22 were categorical data i have used label encoder on it.Now when i have to predict the result is their a way that when i enter details into as categorical data it is converted to the same numbers assigned earlier by label encoder to the data.Or what approach should i use ? Heres the Screenshot of data that has been encoded by label encoder

1 Answers1

0

If you fit your train data and only transform your test data, it should give the same representations because you are using the same encoder.

""It is possible that the unique values appearing in the training and the test sets are different. And in that case, the encodings will be different too."" ref

Furthermore, it is not recommended to use a label encoder for categorical data. (Use only on y(target) not on X(features)).

Refer this for a detailed explaination.

Pathi_rao
  • 93
  • 8