I am working with this data containing a categorical column which has "Good","Medium","Bad", now I wish to know which number has been assigned to which category, i.e. is medium assigned 1 or 2?
Asked
Active
Viewed 40 times
1 Answers
1
If you use sklearn le.classes_
give the names of the classes enumerating them :
from sklearn import preprocessing
mylist = ['r', 'z', 'd', 'd', 'r', 'a']
le = preprocessing.LabelEncoder()
le.fit_transform(mylist)
>>> array([2, 3, 1, 1, 2, 0])
le.classes_
>>> array(['a', 'd', 'r', 'z'], dtype='<U1')
You can check using inverse_transform
:
list(le.inverse_transform([i for i in range(len(le.classes_))]))
>>> ['a', 'd', 'r', 'z']

Lue Mar
- 442
- 7
- 10