python - Python:TypeError:“类型”和“类型”的实例之间不支持“<”。Model.fit() 不起作用
问题描述
尝试在 Python 中绘制部分依赖图时遇到问题。我使用随机森林分类器创建模型:
model = RandomForestClassifier()
model.fit(X,y)
之后我想绘制对模型中一些特征的部分依赖。我试图通过运行以下代码来做到这一点
# PDP plot for most important feature of the model
from sklearn.inspection import plot_partial_dependence
disp1 = plot_partial_dependence(model.fit(X, y), X,
[8, 11, 12], target = int)
但是,在这里我收到错误:TypeError: '<' not supported between 'type' and 'type' 我怎样才能让部分依赖图运行?
X (pandas.dataframe):16 列和 94.347 行的 DataFrame。
Location int64
Complex int64
OR int64
Surgery int64
Operating region int64
Urgency int64
Specialism int64
Surgeon int64
Size of surgical team int64
Gender head surgeon int64
Gender patient int64
Age int64
BMI object
Weekday (Sunday =1) int64
Time of Day int64
Expected Operating Time int64
dtype: object
Y (pandas.series):int64,1 列和 94.347 行
解决方案
推荐阅读
- fortran - 写函数出错。尽管编译成功,但输出文件为空
- java - 部分语音分类问题 - 神经网络不学习
- scala - 如何使用 Circe Optics 解析嵌套的 Json 数组
- java - JavaFX 应用程序线程如何在忙碌时进行队列更新?
- python-3.x - 如何使用 tkinter 显示图像?
- android - 导航抽屉在活动开始时打开
- java - 以下带有 Lambda 表达式的代码是如何编译的?
- c# - Actor 模型相对于基于任务的异步模式的优势
- c++ - 如何从文件读取特定数量的字符到结构
- c# - GetInt("x").Value 在 x = 1.0 时不返回 int