The following code:
from sklearn.preprocessing import LabelBinarizer lb = LabelBinarizer() lb.fit_transform([\'yes\', \'no\', \'no\', \'yes\'])
R