ValueError:无法将字符串转换为浮点型:'RM'

时间:2019-07-02 07:00:53

标签: python scikit-learn linear-regression

我正在尝试使用线性回归来预测称为SalePrice的目标变量。我有60多个属性的数据集,但不包括IdSalePrice

这是我的代码。有办法解决这个问题吗?

from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
label=df_data['SalePrice']
features=df_data
features.drop(columns=['SalePrice'],inplace=True)

X_train,X_test,y_train,y_test=train_test_split(features,label,test_size=0.30)

在拟合模型时,我在“ MsZoning”上遇到了Value错误。

clf=LinearRegression()
clf.fit(X_train,y_train)
  

ValueError:无法将字符串转换为浮点数:“ RM”

MSZoning值:array(['RL', 'RM', 'C (all)', 'FV', 'RH'], dtype=object)

0 个答案:

没有答案