我有以下代码对 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
还有其他方法可以得到标准误差吗?
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
设置为零。这对我有用。