【发布时间】:2017-11-20 15:01:00
【问题描述】:
问题: pyspark 和 scikit-learn 中逻辑回归模型的默认实现(未设置自定义参数)在给定默认参数值的情况下似乎会产生不同的结果。
我正在尝试使用 scikit-learn 的逻辑回归模型(请参阅:http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html)复制使用 pypark(请参阅:https://spark.apache.org/docs/latest/api/python/pyspark.ml.html#pyspark.ml.classification.LogisticRegression)执行的逻辑回归(未设置自定义参数)的结果。
在我看来,两个模型实现(在 pyspark 和 scikit 中)不具有相同的参数,所以我不能简单地匹配 scikit 中的参数以适应 pyspark 中的参数。有什么解决方案可以在默认配置上匹配这两个模型吗?
参数Scikit模型(默认参数):
`LogisticRegression(
C=1.0,
class_weight=None,
dual=False,
fit_intercept=True,
intercept_scaling=1,
max_iter=100,
multi_class='ovr',
n_jobs=1,
penalty='l2',
random_state=None,
solver='liblinear',
tol=0.0001,
verbose=0,
warm_start=False`
参数 Pyspark 模型(默认参数):
LogisticRegression(self,
featuresCol="features",
labelCol="label",
predictionCol="prediction",
maxIter=100,
regParam=0.0,
elasticNetParam=0.0,
tol=1e-6,
fitIntercept=True,
threshold=0.5,
thresholds=None,
probabilityCol="probability",
rawPredictionCol="rawPrediction",
standardization=True,
weightCol=None,
aggregationDepth=2,
family="auto")
非常感谢!
【问题讨论】:
-
你能指出两个类之间不匹配的参数吗?虽然参数名称不同,但似乎是匹配的。
-
例如,scikit 模型有一个名为“penalty”的参数,默认为“l2”。但是,我在 pyspark 模型实现中找不到相同的参数。另一个例子是 pyspark 模型中的参数“aggregationDepth”——它在 scikit 的实现中缺失
-
@frankyjuang 请查看我更新的问题,其中包含每个模型的参数列表
-
对于 scikit 中的
penalty,在 pyspark 中设置elasticNetParam以匹配设置。而aggregationDepth通常不会对结果产生影响。
标签: python machine-learning scikit-learn pyspark