0

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?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Nastasia
  • 557
  • 3
  • 22
  • Doesn't seem to work like that, and the whole project seems oriented to pipelines. See the example notebook [here](https://github.com/combust/mleap-demo/blob/master/notebooks/airbnb-price-regression-scikit.ipynb). Notice step #7, and that the models used are actually from skikit-learn, and not from mleap. – desertnaut May 25 '20 at 15:24
  • Yes. The documentation is oriented to pipelines. But it is possible to do that with a LogisticRegression for instance too. – Nastasia May 27 '20 at 09:51

1 Answers1

0

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")
Nastasia
  • 557
  • 3
  • 22