-
Notifications
You must be signed in to change notification settings - Fork 116
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 it possible to combine LGBMClassifier and IsotonicRegressor into a single PMML? #146
Comments
In plain english, what is this model chain supposed to do? What is the function of Are you trying to "smooth" the prediction of the classifier?
I assume you're referring to Scikit-Learn's stacking estimator classes, and that it is Scikit-Learn that prevents you from building such a model chain (not the SkLearn2PMML/JPMML-SkLearn stack).
Possible workaround - the first estimator should be packaged as a transformer: jpmml/sklearn2pmml#118 |
LGBMClassifier takes in around 100 features to predict a binary target class. The isotonic regression is used to calibrate the model predictions to match a different distribution. The output should be a probability of the target being 1, after prediction calibration. Thank you, I will look into packaging the LGBMClassifier as a transformer. |
This looks like a "decision engineering" problem - taking the prediction of a model, and then doing something extra with it. In such a case Decision engineering is not supported by Scikit-Learn pipelines. However, the Suppose you want to manually correct the predicted probability of a binary classifier: pipeline = PMMLPipeline(.., predict_proba_transformer = ExpressionTransformer("X[1] * 0.95 + 0.1")) You should package |
Hi Villu! Could you suggest a way to package IsotonicRegression as a transformer, please?
And I'm also not sure how to represent isotonic regression as an expression for ExpressionTransformer. The only idea which came to my mind is iteratively building a string with "if else" clauses with implementing extrapolation between values x in Are there any other options to wrap IsotonicRegression in a transformer? Or maybe is there a better solution with ExpressionTransformer? |
Looks like you're trying to develop a custom transformer. You've implemented the Python side, but you still haven't implemented the Java side, plus informing the SkLearn2PMML package about it all. Lately it's been discussed here: jpmml/sklearn2pmml#283
See the Something like this: from sklego.meta import EstimatorTransformer
# A pre-fitted Isotonic regression
isotonicRegression = ..
pipeline = PMMLPipeline(.., predict_proba_transformer = EstimatorTransformer(isotonicRegression)) |
Thanks for the quick response! I found EstimatorTransformer in the supported packages list #https://github.com/jpmml/jpmml-sklearn and tried to use it but found two issues:
Is there a workaround with using EstimatorTransformer? Or the only way is building a custom transformer? |
Exactly - support for the
Use a helper transformer to select a single column (eg. probability of class Z) out of the available ones: pipeline = PMMLPipeline(..,
predict_proba_transformer = Pipeline([
("select_col", ExpressionTransformer("X[1]")),
("transform_col", IsotonicRegression())
])
)
Honestly, just upgrade the SkLearn2PMML package to the latest version. |
Hi, Villu! I updated sklearn2pmml library and found a new issue while building PMMLPipeline
Error:
sklearn2pmml version: 0.60.0 and older work well, but EstimatorTransformer isn't supported there. |
The Why would anyone use a pre-0.21 version in June 2021? |
It works with updated libraries! |
I have been able to do the above by creating separate PMMLs for both LGBMClassifier and IsotonicRegressor, then copying the IsotonicRegressor PMML into the LGBM PMML as a final
Segment
in the chained model. I have looked into using StackedClassifier/Regressor but because LGBM is a classifier and Isotonic is a regressor, it does not allow it. I am also unable to use two models in a single pipeline as only one estimator is allowed. Is it possible to do this using a single pipeline or some other work-around?The text was updated successfully, but these errors were encountered: