Comments (5)
Is it possible to directly use a regular sklearn pipeline with sklearn2pmml?
Not supported at the moment. See jpmml/jpmml-sklearn#3
Very likely, will not be supported in the context of "feature preparation and pre-processing" ever. You should adopt the DataFrameMapper
approach for that.
How can I specify the label encoding for PMML?
JPMML-SkLearn supports LabelBinarizer
and LabelEncoder
transforms:
my_mapper = DataFrameMapper([
([<list of my categorical column names>], LabelBinarizer()),
('MyTargetFieldName', None)
])
How can I specify split in target / X for PMML?
By JPMML-SkLearn conventions, if you are convertinng a supervised estimator object (eg. some classification or regression model), then DataFrameMapper
rows [0, n_rows - 2] are considered to be active fields, and the last row [n_rows - 1] is considered to be the target field. Also, the target field must be mapped to None
transform.
If you are converting an unsupervised estimator object (eg. some clustering model), then all DataFrameMapper
rows [0, n_rows - 1] are considered to be active fields.
How can I perform the selection of continuous / factor fields? would I need to hard code them?
Currently there is no feature selection support. So, you would need to perform feature selection "manually" in your SkLearn code, and then construct an appropriate DataFrameMapper
object based on those selection results.
However, built-in support for feature selection seems like a desirable functionality, so perhaps the sklearn2pmml()
function should take an additional parameter that would allow you to specify some sort of "filtered connection" between the "left-side" DataFrameMapper
object and the "right-side" estimator object. Something like this:
def sklearn2pmml(estimator, mapper, mapper_to_estimator_connection = None, pmml)
pass
The responsibility of the mapper_to_estimator_connection
is to deal with the situation where the number of DataFrameMapper
output columns is different (typically greater) than the number of estimator input columns. It would operate on the transformed feature space. For example, it would able to successfully deal with "column expansions" as performed by the OneHotEncoder
transformer.
In the beginning, it could be a single SkLearn feature selection transformer. Later on, if the concept is successfully validated, it could be a list transformers or even a pipeline of transformers.
from sklearn2pmml.
What kind of feature selector classes do you need?
Specifically, class ColumnExtractor
seems to be provided some third-party Python package:
http://zacstewart.com/2014/08/05/pipelines-of-featureunions-of-pipelines.html
from sklearn2pmml.
Thank you very much for the quick response.
Indeed a ColumnExtractor is good enough to feed only certain columns into the one-hot encoding.
from sklearn2pmml.
I'm reopening this issue, because there needs to be support for feature selection in PMML conversion workflows.
If the feature selection happens in transformed feature space (eg. after categorical columns have been expanded using OneHotEncoder
transformer), then it's virtually impossible to backtrack it in Scikit-Learn application code. However, it's pretty straightforward in JPMML-SkLearn.
from sklearn2pmml.
JPMML-SkLearn version 1.2.0 added limited support for the sklearn.pipeline.Pipeline
estimator type.
By definition, the pipeline contains a list of zero or more transformation steps followed by a final estimator step. You cannot do arbitrary feature transformation work there (as it should be encapsulated into the DataFrameMapper
object). But you can do feature selection work. For example, selecting a subset of "best" features:
pipeline = Pipeline([
("selector", SelectKBest(k = 5)),
("estimator", ...)
])
sklearn2pmml(pipeline, mapper, "Workflow.pmml")
from sklearn2pmml.
Related Issues (20)
- Missing dependency `dill` from `setup.py`. HOT 7
- Support for Python power operator `**` HOT 1
- Assembling a pipeline from pre-fitted components HOT 3
- looking for support on quantile_forest for RandomForestQuantileRegressor HOT 2
- Failing to convert `CalibratedClassifierCV` plus `XGBClassifier` combination HOT 12
- Effectively debugging XGBoost pipelines (mis-matching predictions between Python and (J)PMML) HOT 14
- Revisit the missing value handling of custom transformers HOT 1
- Support for AgglomerativeClustering HOT 2
- `ExpressionTransformer` should try to rectify feature type information HOT 5
- `Alias` object has no attribute `transformer_` HOT 8
- Storing LinearSVC as coefficients instead of support vectors HOT 1
- Reshape transformation results from 2-D to 1-D (column vectors) HOT 1
- 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
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.