How to use the sklearn2pmml.ruleset.RuleSetClassifier function in sklearn2pmml

To help you get started, we’ve selected a few sklearn2pmml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openscoring / papis.io / RuleSetIris.py View on Github external
from sklearn2pmml import sklearn2pmml
from sklearn2pmml.pipeline import PMMLPipeline
from sklearn2pmml.ruleset import RuleSetClassifier

import pandas
import sys

iris_df = pandas.read_csv("csv/Iris.csv")
#print(iris_df.head(5))

iris_X = iris_df[iris_df.columns.difference(["Species"])]
iris_y = iris_df["Species"]

classifier = RuleSetClassifier([
	("X['Petal_Length'] < 2.45", "setosa"),
	("X['Petal_Width'] < 1.75", "versicolor"),
], default_score = "virginica")

pipeline = PMMLPipeline([
	("classifier", classifier)
])
pipeline.fit(iris_X, iris_y)

sklearn2pmml(pipeline, "pmml/RuleSetIris.pmml")

if "--deploy" in sys.argv:
	from openscoring import Openscoring

	os = Openscoring("http://localhost:8080/openscoring")
	os.deployFile("RuleSetIris", "pmml/RuleSetIris.pmml")

sklearn2pmml

Python library for converting Scikit-Learn pipelines to PMML

AGPL-3.0
Latest version published 7 days ago

Package Health Score

76 / 100
Full package analysis

Similar packages