What is the difference between the two? It seems that both create new columns, which their number is equal to the number of unique categories in the feature. Then they assig
The results of OneHotEncoder() and LabelBinarizer() are almost similar [there might be differences in the default output type.
However, to the best of my understanding, LabelBinarizer() should ideally be used for response variables and OneHotEncoder() should be used for feature variables.
Although, at present, I am not sure why do we need different encoders for similar tasks. Any pointer in this direction would be appreciated.
A quick summary:
LabelEncoder – for labels(response variable) coding 1,2,3… [implies order]
OrdinalEncoder – for features coding 1,2,3 … [implies order]
Label Binarizer – for response variable, coding 0 & 1 [ creating multiple dummy columns]
OneHotEncoder - for feature variables, coding 0 & 1 [ creating multiple dummy columns]
A quick example can be found here.