Sklearn分类模型返回TypeError:'>'在' str'的实例之间不支持。和' int'试图适应
我是建筑模型的新手;所以请轻松:)。我正在尝试使用各种模型类型(SGD,决策树等)构建一个多分类模型,但是,每当我尝试适合任何一个模型,我都会收到一个TypeError:
TypeError: '>' not supported between instances of 'str' and 'int'
我使用的示例代码如下:
sgd = SGDClassifier(loss='modified_huber', shuffle=True, random_state=101, average='micro')
sgd.fit(X_train,Y_train)
y_pred = sgd.predict(X_test)
我以前曾确保这些列是相同的dtype:
for column in X_train.columns.tolist():
X_train[column] = X_train[column].astype('float32')
Y_train = Y_train.astype('float32')
我可以验证使用时它们确实是float32:
X_train.dtypes
Y_train.dtypes
所以我不确定为什么它会看到“ str”的任何实例。有人可以建议吗?谢谢!
I am fairly new to building models; so please go easy :). I am trying to build a multi-classification model using various model types (SGD, Decision Tree, etc), however, whenever I try to fit any of them, I am receive a TypeError:
TypeError: '>' not supported between instances of 'str' and 'int'
An example code I am using is as below:
sgd = SGDClassifier(loss='modified_huber', shuffle=True, random_state=101, average='micro')
sgd.fit(X_train,Y_train)
y_pred = sgd.predict(X_test)
I had previously ensured that the columns were of the same dtype:
for column in X_train.columns.tolist():
X_train[column] = X_train[column].astype('float32')
Y_train = Y_train.astype('float32')
And I can verify that they are indeed float32 when using:
X_train.dtypes
Y_train.dtypes
So I am not sure why it is seeing any instances of a 'str'. Could someone please advise? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论