Are there any differences between get_dummies and labelbinarizer in terms of what they want to achieve? It seems to be both will somehow do a one-hot encoding.
1 Answer
A couple of things comes to mind.
get_dummies can transform a dataframe with many columns, whereas LabelBinarizer will only do one column.
get_dummies outputs a dataframe (if the input is a dataframe) with a nicely formatted columns, whereas LabelBinarizer outputs a numpy array, so if you want to attach labels to them, you'd need to get them from the fitted instance of the LabelBinarizer.
Inverse transform is more intuitive with LabelBinarizer, it has a method named inverse_transform, whereas with get_dummies you would need to do something like dummies.idxmax(axis=1)
So overall, get_dummies seems to be a better choice