I am learning about label encoders, one hot encoding etc applied to datasets for classification via KNN and XGBoost type trees. However, I am a bit confused as to whether the target variable should be one hot encoded or not.
In my case, I have a dataframe which has 500x10 size and the last column is the target (for prediction) country column while the rest of the 499 columns contain floating point values. So, an example row:
feature1 ..... fetaure499 target
1.1 ......... 40.1 Germany
6.1 ......... 265.7 USA
8.1 ......... 98,7 Singapore
In this case, what is the optimal way to encode the target for: [1] KNN [2] tree based methods.
My relatively naive understanding says that one hot encoding is useful for the feature space while for the target such as this, i.e list of countries labelencoding should be enough. Is this true for this case? Are there any situations I need to aware of when the target has to be label encoded?
Thank you.
classes_
attribute. $\endgroup$