Skip to content
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

Is there a way to combine multiple models into a single pmml file? #358

Closed
liuhuanshuo opened this issue Nov 2, 2022 · 3 comments
Closed

Comments

@liuhuanshuo
Copy link

I can convert my machine learning model from pkl to a pmml file using sklearn2pmml for java use, which is great.

But now I have a problem. I have multiple lgb models such as lgb1, lgb2... Lgb5.

I want to predict a probability from each of these five models, and then calculate their average as the final result.

But the only way I can do this is with code like,

pipeline_test = PMMLPipeline(
steps=[("mapper", mapper),
("classifier", clf_1)])

In this way, 5 pmml are produced respectively, and then the five pmml are calculated five times, and finally a score is calculated

I would like to know if sklearn2pmml can implement the above tasks in a pipeline, so that only one pmml file is needed in the end

@vruusmann
Copy link
Member

vruusmann commented Nov 2, 2022

Cross-linking with jpmml/jpmml-sklearn#52

I have multiple lgb models such as lgb1, lgb2... Lgb5.
I want to predict a probability from each of these five models, and then calculate their average as the final result.

Let's assume that the current technical capabilities of the SkLearn2PMML/JPMML-SkLearn stack are not a problem. Then, how would you implement a proper solution in Python here and now? Is there some third-party Python package available that is suitable for such work?

Important: the proposed solution must work within Scikit-Learn's pipeline framework (otherwise it wouldn't be pickleable, and therefore reusable across Python sessions/environments). So, using lambdas is not allowed!

@vruusmann
Copy link
Member

How about sklearn.ensemble.VotingRegressor?
https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.VotingRegressor.html

Can you implement your solution using it? Please note that you do not need to invoke VotingRegressor.fit(X, y) method, because the child models are already fitted.

@liuhuanshuo
Copy link
Author

How about sklearn.ensemble.VotingRegressor? https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.VotingRegressor.html

Thank you, I will study the contents of this link.

If feasible, I will add a reply here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants