'Device_Type','Filled_Form','Gender','Var1','Var2','Mobile_Verified','Source'这些特征类型为object
# 数值编码
from sklearn.preprocessing import LabelEncoder
le = LabelEncoder()
var_to_encode = ['Device_Type','Filled_Form','Gender','Var1','Var2','Mobile_Verified','Source']
for col in var_to_encode:
data[col] = le.fit_transform(data[col])
错误代码:
TypeError: '<' not supported between instances of 'float' and 'str'
1个回答
你看看你的那些col里有没有null或者nan的情况,如果有的话会出错
TypeError: unorderable types: float() < str()
谢谢,里面确实有一个缺失值,修改后可以了
-
evan
2018-10-08 10:09