值错误:无法将字符串转换为浮点数:“好”
我正在尝试将决策树模型与训练数据集进行拟合。但发现这个错误
credit_df=pd.read_csv('credit.csv')
credit_df.head()
X = credit_df.drop("default" , axis=1)
Y=credit_df.pop("default")
from sklearn.model_selection import train_test_split
X_train, X_test, train_labels, test_labels = train_test_split(X, y, test_size=.30, random_state=1)
dt_model = DecisionTreeClassifier(criterion = 'gini' )
dt_model.fit(X_train, train_labels)
I am trying to fit a decision tree model with the training dataset. But finding this error
credit_df=pd.read_csv('credit.csv')
credit_df.head()
X = credit_df.drop("default" , axis=1)
Y=credit_df.pop("default")
from sklearn.model_selection import train_test_split
X_train, X_test, train_labels, test_labels = train_test_split(X, y, test_size=.30, random_state=1)
dt_model = DecisionTreeClassifier(criterion = 'gini' )
dt_model.fit(X_train, train_labels)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我尝试了下面的代码,现在错误已修复。有一些对象数据类型,我将它们转换为分类值
I tried the code below and now the error is fixed. There were some object data types and i converted them into categorical values