我试图通过LabelEncoder和OneHotEncoder方法对分类变量进行编码。我的X矩阵由所有带有浮点数的变量组成,而我的Y则由类型为object的变量组成:X = df.loc[:, df.dtypes == np.float64]Y = df['VCat']当我应用我的方法时:from sklearn.preprocessing import LabelEncoder, OneHotEncoderlabelencoder_Y = LabelEncoder()Y = labelencoder_Y.fit_transform(Y)onehotencoder = OneHotEncoder(categorical_features = [0])Y = onehotencoder.fit_transform(Y).toarray()出去 :TypeError: '<' not supported between instances of 'str' and 'float'感谢帮助
添加回答
举报
0/150
提交
取消