This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pandas import read_csv | |
from sklearn.model_selection import train_test_split | |
url = "https://raw.githubusercontent.com/baatout/ml-in-prod/master/pima-indians-diabetes.csv" | |
features = ['preg', 'plas', 'pres', 'skin', 'test', 'mass', 'pedi', 'age'] | |
label = 'label' | |
dataframe = read_csv(url, names=features + [label]) | |
X = dataframe[features] | |
Y = dataframe[label] | |
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.33, random_state=42) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# with X_train, X_test, Y_train, Y_test | |
from sklearn.linear_model import LogisticRegression | |
clf = LogisticRegression() | |
clf.fit(X_train, Y_train) | |
print(clf.score(X_test, Y_test)) | |
import json | |
with open('logreg_coefs', 'w') as f: | |
json.dump(clf.coef_.tolist(), f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# with X_train, X_test, Y_train, Y_test | |
import numpy as np | |
from sklearn_pandas import DataFrameMapper | |
from sklearn2pmml import PMMLPipeline, sklearn2pmml | |
from sklearn.linear_model import LogisticRegression | |
from sklearn.preprocessing import FunctionTransformer | |
clf = PMMLPipeline([ | |
("mapper", DataFrameMapper([ | |
(['mass'], FunctionTransformer(np.log1p)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | |
<PMML xmlns="http://www.dmg.org/PMML-4_3" xmlns:data="http://jpmml.org/jpmml-model/InlineTable" version="4.3"> | |
<Header> | |
<Application name="JPMML-SkLearn" version="1.5.6"/> | |
<Timestamp>2018-09-08T11:13:03Z</Timestamp> | |
</Header> | |
<MiningBuildTask> | |
<Extension>PMMLPipeline(steps=[('mapper', DataFrameMapper(default=False, df_out=False, | |
features=[(['mass'], FunctionTransformer(accept_sparse=False, func=<ufunc 'log1p'>, | |
inv_kw_args=None, inverse_func=None, kw_args=None, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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([ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# with X_train, X_test, Y_train, Y_test | |
import dill | |
from sklearn_pandas import DataFrameMapper | |
from sklearn.pipeline import Pipeline | |
from sklearn.linear_model import LogisticRegression | |
from sklearn.preprocessing import FunctionTransformer | |
def is_adult(x): return x > 18 | |
clf = Pipeline([ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run this anywhere and change the pipeline.pk path | |
import dill | |
from pandas import read_csv | |
url = "https://raw.githubusercontent.com/baatout/ml-in-prod/master/pima-indians-diabetes.csv" | |
features = ['preg', 'plas', 'pres', 'skin', 'test', 'mass', 'pedi', 'age'] | |
label = 'label' | |
dataframe = read_csv(url, names=features + [label]) | |
X = dataframe[features] | |
Y = dataframe[label] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add(a, b): | |
return a + b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from adder import add | |
x = add(4, 6) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add(a: int, b: int) -> int: | |
return a + b |
OlderNewer