pythonsklearn2pmml

PMMLPipeline._fit() takes from 2 to 3 positional arguments but 4 were given


scikitlearn 1.1.1, XGBoost 1.7.6, nyoka 5.5.0, scikitlearn2pmml 0.94.1

I'm trying to run the following code and get TypeError.

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":

TypeError: PMMLPipeline._fit() takes from 2 to 3 positional arguments but 4 were given

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?


Solution

  • Ran into the same error and it was a dependency issue. I guess for your set-up you could simply update sklearn2pmml for a start:

    pip install sklearn2pmml --upgrade
    

    If that doesn't solve it, you should probably also update scikit-learn to a more recent version, I suggest v1.3.2.