1

I am quite new to ML can anyone please help me, I am facing issue while encoding and decoding below mentioned DF using preprocessing.LabelEncoder()

df.head()

     Col1      |    Col2 |  Col3 |  Col4 |  Col5    |   Col6

0   | Minor    |    Yes  |  BSS  | Data1 |  Data3   |  Packet-Core/EPC
1   | Critical |    Yes  |  OSS  | Data2 |  Data4   |  Packet-Core/EPC

Mentioning the code which I am using

le = preprocessing.LabelEncoder()
X_categorical = df.select_dtypes(include=['object'])
X_categorical = X_categorical.apply(le.fit_transform)
X_categorical.head()

     Col1      |    Col2 |  Col3 |  Col4 |  Col5    |   Col6

0   | 0        |    0    |  0    | 0     |  0       |  0
1   | 1        |    0    |  1    | 0     |  1       |  0


df_categorical = df.head(1).apply(le.transform)

Getting below mentioned error

ValueError: y contains previously unseen labels: 'Minor'

0 Answers0