如何在PySpark中创建自定义估算器

问题描述 投票:13回答:1

我正在尝试在PySpark MLlib中构建一个简单的自定义Estimator。我有here可以编写自定义的Transformer,但是我不确定如何在Estimator上执行此操作。我也不清楚@keyword_only的功能,为什么我需要这么多的设置方法和获取方法。 Scikit-learn似乎具有适用于自定义模型的文档(see here,但PySpark没有。)

示例模型的伪代码:

class NormalDeviation():
    def __init__(self, threshold = 3):
    def fit(x, y=None):
       self.model = {'mean': x.mean(), 'std': x.std()]
    def predict(x):
       return ((x-self.model['mean']) > self.threshold * self.model['std'])
    def decision_function(x): # does ml-lib support this?

我正在尝试在PySpark MLlib中构建一个简单的自定义估算器。我在这里可以编写自定义的Transformer,但是我不确定如何在Estimator上进行操作。我也听不懂...

python apache-spark pyspark apache-spark-mllib apache-spark-ml
1个回答
12
投票

一般而言,没有文档,因为对于Spark 1.6 / 2.0,大多数相关API都不打算公开。它应该在Spark 2.1.0中更改(请参见SPARK-7146)。

© www.soinside.com 2019 - 2024. All rights reserved.