【问题标题】:MLeap broken with Skicit-learn when serialising: object has no attribute 'input_features'序列化时 MLeap 被 Scikit-learn 破坏:对象没有属性“输入特征”
【发布时间】:2020-05-27 17:53:03
【问题描述】:

我在尝试序列化模型时遇到了 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'

有人找到解决方法了吗?

【问题讨论】:

  • 好像不是这样工作的,整个项目似乎是面向管道的。请参阅示例笔记本 here。注意第 7 步,使用的模型实际上来自skikit-learn,而不是来自mleap。
  • 是的。该文档面向管道。但是也可以使用 LogisticRegression 来做到这一点。

标签: python scikit-learn mleap


【解决方案1】:

我找到了解决办法。

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

【讨论】:

    猜你喜欢
    • 2019-06-18
    • 2015-07-03
    • 2019-07-03
    • 2017-11-04
    • 2017-11-24
    • 1970-01-01
    • 1970-01-01
    • 2018-12-31
    • 1970-01-01
    相关资源
    最近更新 更多