从 pySpark 中的线性回归模型中获取标准误差

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

我有以下代码对 pySpark 执行线性回归:

lr = LinearRegression(featuresCol = 'features', labelCol='units_sold', maxIter=10, regParam=0.3, elasticNetParam=0.8)
lr_model = lr.fit(premodel_df)
summary =lr_model.summary

我正在尝试从系数中获取标准误差,这应该通过以下方式完成:

summary.coefficientStandardErrors

但是我得到以下错误:

调用 o704.coefficientStandardErrors 时出错。 : java.lang.UnsupportedOperationException:无标准。系数误差 适用于此 LinearRegressionModel

还有其他方法可以得到标准误差吗?

python apache-spark pyspark linear-regression
1个回答
0
投票

According to the docs the

coefficientStandardErrors
is only available when using the "normal" solver, however the relevant scala code shows a different condition.

这个答案建议将

elasticNetParam
regParam
设置为零。这对我有用。

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