There are some cases where LabelEncoder or DictVectorizor are useful, but these are quite limited in my opinion due to ordinality.
LabelEncoder can turn [dog,cat,dog,mouse,cat] into [1,2,1,3,2], but then the imposed ordinality means that the average of dog and mouse is cat. Still there are algorithms like decision trees and random forests that can work with categorical variables just fine and LabelEncoder can be used to store values using less disk space.
One-Hot-Encoding has the advantage that the result is binary rather than ordinal and that everything sits in an orthogonal vector space. The disadvantage is that for high cardinality, the feature space can really blow up quickly and you start fighting with the curse of dimensionality. In these cases, I typically employ one-hot-encoding followed by PCA for dimensionality reduction. I find that the judicious combination of one-hot plus PCA can seldom be beat by other encoding schemes. PCA finds the linear overlap, so will naturally tend to group similar features into the same feature.
Answer from AN6U5 on Stack ExchangeThere are some cases where LabelEncoder or DictVectorizor are useful, but these are quite limited in my opinion due to ordinality.
LabelEncoder can turn [dog,cat,dog,mouse,cat] into [1,2,1,3,2], but then the imposed ordinality means that the average of dog and mouse is cat. Still there are algorithms like decision trees and random forests that can work with categorical variables just fine and LabelEncoder can be used to store values using less disk space.
One-Hot-Encoding has the advantage that the result is binary rather than ordinal and that everything sits in an orthogonal vector space. The disadvantage is that for high cardinality, the feature space can really blow up quickly and you start fighting with the curse of dimensionality. In these cases, I typically employ one-hot-encoding followed by PCA for dimensionality reduction. I find that the judicious combination of one-hot plus PCA can seldom be beat by other encoding schemes. PCA finds the linear overlap, so will naturally tend to group similar features into the same feature.
While AN6U5 has given a very good answer, I wanted to add a few points for future reference. When considering One Hot Encoding(OHE) and Label Encoding, we must try and understand what model you are trying to build. Namely the two categories of model we will be considering are:
- Tree Based Models: Gradient Boosted Decision Trees and Random Forests.
- Non-Tree Based Models: Linear, kNN or Neural Network based.
Let's consider when to apply OHE and when to apply Label Encoding while building tree based models.
We apply OHE when:
- When the values that are close to each other in the label encoding correspond to target values that aren't close (non-linear data).
- When the categorical feature is not ordinal (dog, cat, mouse).
We apply Label encoding when:
- The categorical feature is ordinal (Jr. kg, Sr. kg, Primary school, high school, etc).
- When we can come up with a label encoder that assigns close labels to similar categories: This leads to less splits in the trees hence reducing the execution time.
- When the number of categorical features in the dataset is huge: One-hot encoding a categorical feature with huge number of values can lead to (1) high memory consumption and (2) the case when non-categorical features are rarely used by model. You can deal with the 1st case if you employ sparse matrices. The 2nd case can occur if you build a tree using only a subset of features. For example, if you have 9 numeric features and 1 categorical with 100 unique values and you one-hot-encoded that categorical feature, you will get 109 features. If a tree is built with only a subset of features, initial 9 numeric features will rarely be used. In this case, you can increase the parameter controlling size of this subset. In xgboost it is called colsample_bytree, in sklearn's Random Forest max_features.
In case you want to continue with OHE, as @AN6U5 suggested, you might want to combine PCA with OHE.
Let's consider when to apply OHE and Label Encoding while building non tree based models.
To apply Label encoding, the dependance between feature and target must be linear in order for Label Encoding to be utilised effectively.
Similarly, in case the dependance is non-linear, you might want to use OHE for the same.
Note: Some of the explanation has been referenced from How to Win a Data Science Competition from Coursera.
When should I use Label Encoder over One Hot Encoder?
How can I reverse the transformation done by Label Encoder or One Hot Encoder?
How does Label Encoder handle unseen categories in test data?
A simple example which encodes an array using LabelEncoder, OneHotEncoder, LabelBinarizer is shown below.
I see that OneHotEncoder needs data in integer encoded form first to convert into its respective encoding which is not required in the case of LabelBinarizer.
from numpy import array
from sklearn.preprocessing import LabelEncoder
from sklearn.preprocessing import OneHotEncoder
from sklearn.preprocessing import LabelBinarizer
# define example
data = ['cold', 'cold', 'warm', 'cold', 'hot', 'hot', 'warm', 'cold',
'warm', 'hot']
values = array(data)
print "Data: ", values
# integer encode
label_encoder = LabelEncoder()
integer_encoded = label_encoder.fit_transform(values)
print "Label Encoder:" ,integer_encoded
# onehot encode
onehot_encoder = OneHotEncoder(sparse=False)
integer_encoded = integer_encoded.reshape(len(integer_encoded), 1)
onehot_encoded = onehot_encoder.fit_transform(integer_encoded)
print "OneHot Encoder:", onehot_encoded
#Binary encode
lb = LabelBinarizer()
print "Label Binarizer:", lb.fit_transform(values)

Another good link which explains the OneHotEncoder is: Explain onehotencoder using python
There may be other valid differences between the two which experts can probably explain.
A difference is that you can use OneHotEncoder for multi column data, while not for LabelBinarizer and LabelEncoder.
from sklearn.preprocessing import LabelBinarizer, LabelEncoder, OneHotEncoder
X = [["US", "M"], ["UK", "M"], ["FR", "F"]]
OneHotEncoder().fit_transform(X).toarray()
# array([[0., 0., 1., 0., 1.],
# [0., 1., 0., 0., 1.],
# [1., 0., 0., 1., 0.]])
LabelBinarizer().fit_transform(X)
# ValueError: Multioutput target data is not supported with label binarization
LabelEncoder().fit_transform(X)
# ValueError: bad input shape (3, 2)