Comments (3)
Simply wrap your pre-trained estimator object into a sklearn.PMMLPipeline
object:
estimator = pickle.load(...)
pipeline = PMMLPipeline([
("pretrained-estimator", estimator)
])
sklearn2pmml(pipeline, "pretrained-estimator.pmml")
The main problem with using pre-trained estimators is that the resulting PMML document will be devoid of any supporting (meta-)information such as column names or data types. All input fields will be called x{index}
, and they will be of some numeric data type (typically, float
for decision tree-based model types, and double
for all other model types).
If you have some knowledge about the "schema" of your pre-trained models, then it's possible to enhance the sklearn2pmml.PMMLPipeline
object accordingly:
dataframemapper = pickle.load(...)
pipeline = PMMLPipeline([
("pretrained-dataframemapper", dataframemapper),
("pretrained-estimator", estimator)
])
or
pipeline = PMMLPipeline([
("pretrained-estimator", estimator)
])
pipeline.target_field = "Species"
pipeline.active_fields = numpy.array(["Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"])
from sklearn2pmml.
Thanks @vruusmann!
from sklearn2pmml.
It would be nice to have utility method(s) for doing this kind of wrapping work. Furthermore, it could happen silently inside the sklearn2pmml
function itself.
The underlying JPMML-SkLearn library has no problem accepting "raw" estimator objects:
jpmml/jpmml-sklearn@7b258cd
So, this limitation exists only in the sklearn2pmml
package, in the form of the following isinstance
check:
https://github.com/jpmml/sklearn2pmml/blob/master/sklearn2pmml/__init__.py#L128
from sklearn2pmml.
Related Issues (20)
- sklearn2pmml does not work with sklearn version 1.3.0 and newer HOT 6
- sklearn2pmml does not work with xgboost >= 2.0.0 HOT 9
- LookupTransformer TypeError when default value is not exactly the type from the mapping HOT 2
- xgb 生成的pkl 转pmml 失败 HOT 1
- Can sklearn2pmml just for variable transformations be used? HOT 1
- PyPMML is making systematically off predictions with XGBoost PMML documents? HOT 16
- ImportError: cannot import name 'LabelBinarizer' from 'sklearn2pmml.preprocessing' HOT 2
- Compatibility with Scikit-Learn 1.4.0 HOT 8
- Convenience API for embedding model evaluation metrics as `ModelExplanation` element HOT 13
- Ability to "refine" (categorical-) valid value spaces along the transformer pipeline HOT 17
- NullPointerException when using OneHotEncoder with Integer Categorical Variables in sklearn2pmml HOT 10
- Create .pmml File for Calibrated xgboost Model HOT 8
- Pandas 2.2 FutureWarning for time series offset aliases HOT 2
- Pandas not installed as dependency HOT 2
- CategoricalDomain decorator doesn't work with nullable pandas Int64 column HOT 3
- RegEx expressions are un-evaluatable due to missing `(pc)re` imports HOT 8
- ExplainableBoostingRegressor not supporting other link functions HOT 1
- How to properly re-use raw features HOT 23
- Referencing input feature(s) during the post-processing in PMML pipeline HOT 2
- How to reference categorical input feature(s) during the post-processing in PMML pipeline HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sklearn2pmml.