1

I have the following code to perform a linear regression on 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

I am trying to get the standard error from the coefficients, which is supposed to be done with:

summary.coefficientStandardErrors

But I obtain the folloging error:

An error occurred while calling o704.coefficientStandardErrors. : java.lang.UnsupportedOperationException: No Std. Error of coefficients available for this LinearRegressionModel

Is there another way to obtain the standard error?

mblume
  • 243
  • 1
  • 3
  • 11

1 Answers1

1

According to the docs the coefficientStandardErrors are only available when when using the “normal” solver, however the relevant scala code shows a different condition.

This answer suggests to set either elasticNetParam or regParam to zero. This worked for me.

werner
  • 13,518
  • 6
  • 30
  • 45