'Value of LabelEncoder() is getting overwritten while traversing through DF
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() , basically the label encoder is getting overwritten with new value
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/OSS
le = preprocessing.LabelEncoder()
dfCatagorical=df.apply(le.fit_transform)
dfCatagorical.head()
| Col1 | Col2 | Col3 | Col4 | Col5 | Col6 0 | 0 | 0 | 0 | 0 | 0 | 0 1 | 1 | 0 | 1 | 1 | 1 | 1
le.classes_
array(['Packet-Core/EPC', 'Packet-Core/OSS'])
Here the last column (COl6) values are present in LE , and when I am trying to transform the value for COL1 its giving me error
le.transform(['Minor']))
"previously unseen labels: ['Minor']"
Expected value is "0" (as per dfCatagorical[0][0])
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
