Skip to content

Instantly share code, notes, and snippets.

@veekaybee
Created March 11, 2016 15:48
Show Gist options
  • Save veekaybee/25e42ccb93b05e49b220 to your computer and use it in GitHub Desktop.
Save veekaybee/25e42ccb93b05e49b220 to your computer and use it in GitHub Desktop.
from sklearn.preprocessing import LabelEncoder
le = LabelEncoder()
le.fit(['a', 'b', 'c', 'c’])
dict(zip(le.classes_, range(len(le.classes_))))
>>>{'a': 0, 'b': 1, 'c': 2}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment