我想对我的数据集中的10个特征中的3个分类特征进行编码。我使用sklearn.preprocessingpreprocessing
如下面这样做:OneHotEncoder对分类特征的问题
from sklearn import preprocessing
cat_features = ['color', 'director_name', 'actor_2_name']
enc = preprocessing.OneHotEncoder(categorical_features=cat_features)
enc.fit(dataset.values)
但是,我无法继续,因为我得到这个错误:
array = np.array(array, dtype=dtype, order=order, copy=copy)
ValueError: could not convert string to float: PG
我很奇怪为什么它抱怨串因为它应该转换它!我在这里错过了什么吗?
非常感谢。 – Medo