scikitlearn 1.1.1、XGboost 1.7.6、nyoka 5.5.0、scikitlearn 2pmml 0.94.1

我正在try 运行下面的代码并获取类型错误.

pipeline = PMMLPipeline([("classifier", XGBClassifier(**params))])
pipeline.fit(X_train, y_train)

The error:

TypeError Traceback (most recent call last)
Cell In[28], line 1
----> 1 pipeline.fit(X_train, y_train)

File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\sklearn\base.py:1474, in _fit_context..decorator..wrapper(estimator, *args, **kwargs)
1467 estimator._validate_params()
1469 with config_context(
1470 skip_parameter_validation=(
1471 prefer_skip_nested_validation or global_skip_validation
1472 )
1473 ):
-> 1474 return fit_method(estimator, *args, **kwargs)

File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\sklearn\pipeline.py:471, in Pipeline.fit(self, X, y, **params)
428 """Fit the model.
429
430 Fit all the transformers one after the other and sequentially transform the (...)
468 Pipeline with fitted steps.
469 """
470 routed_params = self._check_method_params(method="fit", props=params)
--> 471 Xt = self._fit(X, y, routed_params)
472 with _print_elapsed_time("Pipeline", self._log_message(len(self.steps) - 1)):
473 if self._final_estimator != "passthrough":

类型错误:PMMLPipeline._ fit()需要2到3个位置参数,但给出了4个位置参数

I see from the traceback that there is an extra argument "(self, X, y, **params)" but I run the same sequence of commands for other XGBoost models without problem.
What could be happen?

推荐答案

遇到了同样的错误,这是依赖性问题. 我想对于您的设置,您可以简单地更新sklearn2pmml作为开始:

pip install sklearn2pmml --upgrade

如果这还不能解决这个问题,您可能还应该将scikit-learn更新到更新的版本,我建议v1.3.2.

Python相关问答推荐

Python中使用时区感知日期时间对象进行时间算术的Incredit

如何在图片中找到这个化学测试条?OpenCV精明边缘检测不会绘制边界框

通过优化空间在Python中的饼图中添加标签

试图找到Python方法来部分填充numpy数组

如何根据参数推断对象的返回类型?

为什么符号没有按顺序添加?

在Python Attrs包中,如何在field_Transformer函数中添加字段?

Vectorize多个头寸的止盈/止盈回溯测试pythonpandas

' osmnx.shortest_track '返回有效源 node 和目标 node 的'无'

用合并列替换现有列并重命名

在Mac上安装ipython

修复mypy错误-赋值中的类型不兼容(表达式具有类型xxx,变量具有类型yyy)

我如何根据前一个连续数字改变一串数字?

在单个对象中解析多个Python数据帧

如何并行化/加速并行numba代码?

如何在Python Pandas中填充外部连接后的列中填充DDL值

为什么后跟inplace方法的`.rename(Columns={';b';:';b';},Copy=False)`没有更新原始数据帧?

如何根据一定条件生成段id

设置索引值每隔17行左右更改的索引

时间戳上的SOAP头签名无效