5ada49d396c2c502fd56ebb4d9b6d7351b74f59c
python/pandas/ValueError: y contains previously unseen labels: ''.md
... | ... | @@ -0,0 +1,13 @@ |
1 | +LabelEncoderをフィットさせたフィット元データに含まれないデータを用いてエンコードを行おうとしたときに発生。 |
|
2 | + |
|
3 | +解決策というか、妥協策? |
|
4 | +[python - sklearn.LabelEncoder with never seen before values - Stack Overflow](https://stackoverflow.com/questions/21057621/sklearn-labelencoder-with-never-seen-before-values) |
|
5 | +``` |
|
6 | +from sklearn.preprocessing import LabelEncoder |
|
7 | + |
|
8 | +le = preprocessing.LabelEncoder() |
|
9 | +le.fit(X) |
|
10 | + |
|
11 | +le_dict = dict(zip(le.classes_, le.transform(le.classes_))) |
|
12 | +le_dict.get(new_item, None) |
|
13 | +``` |
|
... | ... | \ No newline at end of file |