编码标签熊猫时出现意外结果

时间:2019-04-05 09:15:16

标签: python python-3.x pandas numpy

我具有以下用于编码标签的代码:

import numpy as np
import pandas as pd

train_sentiments = pd.Series(['neutral', 'positive', 'neutral', 'negative'])
y_train = np.asarray(pd.get_dummies(train_sentiments), dtype = np.int8)

print('"{}" is converted into {}'.format(train_sentiments[0], y_train[0]))
print('"{}" is converted into {}'.format(train_sentiments[1], y_train[1]))
print('"{}" is converted into {}'.format(train_sentiments[3], y_train[3]))

对于以上部分,我得到的结果是,对于标签,编码值是相同的:

"neutral" is converted into [1 0 0]
"positive" is converted into [1 0 0]
"negative" is converted into [1 0 0]

如何知道每个标签的编码值是什么?

0 个答案:

没有答案