【发布时间】:2019-11-21 01:03:20
【问题描述】:
我有一个数据集,其中有分类值列表作为特征值。如何对其进行编码以训练模型?
例如,我有一些数据:
feature1: [a, b, c]
feature2: [[category1, category2, category3], [category2], [category3, category4]]
如何编码feature2?
【问题讨论】:
-
使用 one-hot 编码,将每个列表变成一个向量,其大小为类别总数,在所选类别上为一个,其他地方为零。
标签: python numpy machine-learning scikit-learn