0

当我尝试序列化模型时,我遇到了 MLeap 0.16 和 Python 3 的问题。这是我的代码:

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")

错误:

AttributeError: 'LogisticRegression' object has no attribute 'input_features'

有没有人找到解决方法?

4

1 回答 1

0

我找到了解决方案。

clf.mlinit(input_features="features", prediction_column="prediction") 

失踪。

您还可以使用管道来执行此操作:

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")
于 2020-05-26T14:13:08.913 回答