Skip to content

Instantly share code, notes, and snippets.

@baatout
Last active September 8, 2018 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baatout/b762a08fcb4d862d52ef018d885b04dc to your computer and use it in GitHub Desktop.
Save baatout/b762a08fcb4d862d52ef018d885b04dc to your computer and use it in GitHub Desktop.
PMML failure
# with X_train, X_test, Y_train, Y_test
from sklearn_pandas import DataFrameMapper
from sklearn2pmml import PMMLPipeline, sklearn2pmml
from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import FunctionTransformer
def is_adult(x): return x > 18
clf = PMMLPipeline([
("mapper", DataFrameMapper([
(['age'], FunctionTransformer(is_adult)),
(features, None)
])),
("classifier", LogisticRegression())
])
clf.fit(X_train, Y_train)
print(clf.score(X_test, Y_test))
sklearn2pmml(clf, "Model.pmml", with_repr=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment