【发布时间】:2019-10-09 11:37:44
【问题描述】:
我已经使用模型预测了一些数据并得到了这种结果
[[0 0 0 ... 0 0 1]
[0 0 0 ... 0 0 0]
[0 0 0 ... 0 0 0]
...
[0 0 0 ... 0 0 0]
[0 0 0 ... 0 0 1]
[0 0 0 ... 0 0 0]]
它们基本上是目标列的单热编码标签。 现在我想以某种方式回到原始值的单列。 我使用这些行来进行编码。 我怎样才能回到单列?
le_candidate = LabelEncoder()
df['candidate_encoded'] = le_candidate.fit_transform(df.Candidate)
candidate_ohe = OneHotEncoder()
Y = candidate_ohe.fit_transform(df.candidate_encoded.values.reshape(-1, 1)).toarray()
【问题讨论】:
-
尝试
np.argmax(results,axis=-1)返回单列。
标签: python scikit-learn one-hot-encoding