I'm facing an issue with MLeap 0.16 and Python 3 when I try serialising a model. Here is my code:
from mleap.sklearn.logistic import LogisticRegression
from sklearn.datasets import load_iris
X, y = load_iris(return_X_y=True)
clf = LogisticRegression(random_state=0).fit(X, y)
clf.serialize_to_bundle("path", "irismodel")
error:
AttributeError: 'LogisticRegression' object has no attribute 'input_features'
Did anyone find a workaround?
I found the solution.
clf.mlinit(input_features="features", prediction_column="prediction")
was missing.
You can also use a pipeline to do that:
from mleap.sklearn.logistic import LogisticRegression
from sklearn.datasets import load_iris
from mleap.sklearn.pipeline import Pipeline
X, y = load_iris(return_X_y=True)
logistic = LogisticRegression(random_state=0)
logistic.mlinit(input_features="features", prediction_column="prediction")
pipeline = Pipeline([("log", logistic)])
clf = pipeline.fit(X, y)
clf.mlinit()
clf.serialize_to_bundle("/dbfs/endpath", "model.json")