-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sklearn2pmml does not work with xgboost >= 2.0.0 #402
Comments
I don't think that anything major has happened to the Will have to update the JPMML-XGBoost project first... In the meantime, can you try adding the missing Something like this: classifier = XGBClassifier()
pipeline = Pipeline([
("classifier", classifier)
])
pipeline.fit(X, y)
# After fitting, set the missing `classes_` attribute
classifier.classes_ = numpy.unique(y)
sklearn2pmml(pipeline, "XGBClassifier.pmml") |
Actually, the classes_ property still exists in XGBClassifier: @property
def classes_(self) -> np.ndarray:
return np.arange(self.n_classes_) It is also accessible read-only in Python via |
The Yep, and since there is a virtual Now, the workaround would be to update the Java handler of Another idea would be to define a special-purpose |
FYI: I'm currently working on getting Scikit-Learn 1.3.X supported. Should be ready any day now. After that, I'll do a round of XGBoost and LightGBM library updates, and will fix this particular issue among others. Should be done by end of next week. |
Both options sound feasible to me, the second one is probably easier to implement and more flexible. And there is already a similar construct with Thanks a lot for all your great work and quick response! |
The conversion should succeed with SkLearn2PMML 0.100.1 and newer. |
Damn, forgot that in addition to JPMML-XGBoost library update, it will be necessary to provide a workaround for the now-missing Working on it right now. |
The conversion of XGBoost 2.0.X models should succeed with SkLearn2PMML 0.100.2 and newer. The transformer = ...
classifier = XGBClassifier()
pipeline = PMMLPipeline([
("transformer", transformer),
("classifier", classifier)
])
pipeline.fit(df, df["target"])
# THIS! make the virtual property persistent
classifier.pmml_classes_ = classifier.classes_
sklearn2pmml(pipeline, "XGBoost.pmml") |
confirm it is working now again. thanks a lot for the quick fix. |
When trying to generate a PMML for an xgboost model, I get the following error:
Libraries anf versions:
After downgrading xgboost to 1.7.6, everything works fine.
The text was updated successfully, but these errors were encountered: