1

I'm doing label encoding with LabelEncoder(). I want to know what is the categorical name corresponding to the encoded values. For example:

import pandas as pd 
from sklearn.preprocessing import LabelEncoder
from sklearn import preprocessing

le = LabelEncoder()
data = [['tom', 10], ['nick', 15], ['juli', 14]]
df = pd.DataFrame(data, columns = ['Name', 'Age'])
df['Name']= le.fit_transform(df['Name'])
df

When i use this, code works successfully. But how do i know encoded tom=2 or nick=1? This is a really big problem when working with big data. How do i save these encoded categorical informations?

Thank you for your answer in advance.

Tarik Karakas
  • 13
  • 1
  • 3

1 Answers1

0

Use LabelEncoder.inverse_transform

le.inverse_transform([1])
array(['nick'], dtype=object)
luigigi
  • 4,146
  • 1
  • 13
  • 30