A library to parse PMML models into Scikit-learn estimators.
Project description
sklearn-pmml-model
A library to parse PMML models into Scikit-learn estimators.
Installation
The easiest way is to use pip:
$ pip install sklearn-pmml-model
Status
This library is very alpha, and currently only supports a small part of the specification:
- DataDictionary
- DataField (continuous, categorical, ordinal)
- Value
- Interval
- DataField (continuous, categorical, ordinal)
- TransformationDictionary
- DerivedField
- TreeModel
Example
A minimal working example is shown below:
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
import pandas as pd
import numpy as np
from sklearn_pmml_model.tree import PMMLTreeClassifier
# Prepare data
iris = load_iris()
X = pd.DataFrame(iris.data)
X.columns = np.array(iris.feature_names)
y = pd.Series(np.array(iris.target_names)[iris.target])
y.name = "Class"
Xtr, Xte, ytr, yte = train_test_split(X, y, test_size=0.33, random_state=123)
df = pd.concat([Xte, yte], axis=1)
clf = PMMLTreeClassifier(pmml="models/sklearn2pmml.pmml")
clf.predict(Xte)
clf.score(Xte, yte)
Development
Prerequisites
Tests can be run using Py.test. Grab a local copy of the source:
$ git clone http://github.com/iamDecode/sklearn-pmml-model
create a virtual environment:
$ python3 -m venv venv
And install the dependencies:
$ pip install -r requirements.txt
Testing
You can execute tests with py.test by running:
$ python setup.py pytest
Contributing
Feel free to make a contribution. Please read CONTRIBUTING.md for details on the code of conduct, and the process for submitting pull requests.
License
This project is licensed under the BSD 2-Clause License - see the LICENSE.md file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for sklearn-pmml-model-0.0.2b0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e165fd0e31b52f3e3e59d30a08247227a35dc6f1bcc57e5cf4cb1b05b8338ba5 |
|
MD5 | 974e68c58ab9163c5b9d9584ab3c8c35 |
|
BLAKE2b-256 | 48fee675f5663b40e143aca4546fe48ecb44060985126bd8a860b91731d81223 |
Hashes for sklearn_pmml_model-0.0.2b0-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78b3c587fd411ebdfd6a43593cf8c3d0fb7552f4775f446aba90e18b85e78ed7 |
|
MD5 | 21c1c12064bc24c085d56611d96a90e3 |
|
BLAKE2b-256 | 9fdac8dab0bf5307149c2bcc5ea0ab38798db776fc79a05632c4310a70c62dbf |