I have a DataFrame that is processed with LinearRegression. If I do it directly, like below, I can display the details of the model:
val lr = new LinearRegression()
val lrModel = lr.fit(df)
lrModel: org.apache.spark.ml.regression.LinearRegressionModel = linReg_b22a7bb88404
println(s"Coefficients: ${lrModel.coefficients} Intercept: ${lrModel.intercept}")
Coefficients: [0.9705748115939526] Intercept: 0.31041486689532866
However, if I use it inside a pipeline (like in the simplified example below),
val pipeline = new Pipeline().setStages(Array(lr))
val lrModel = pipeline.fit(df)
then I get the following error.
scala> lrModel
res9: org.apache.spark.ml.PipelineModel = pipeline_99ca9cba48f8
scala> println(s"Coefficients: ${lrModel.coefficients} Intercept: ${lrModel.intercept}")
<console>:68: error: value coefficients is not a member of org.apache.spark.ml.PipelineModel
println(s"Coefficients: ${lrModel.coefficients} Intercept: ${lrModel.intercept}")
^
<console>:68: error: value intercept is not a member of org.apache.spark.ml.PipelineModel
println(s"Coefficients: ${lrModel.coefficients} Intercept: ${lrModel.intercept}")
I understand what it means (it's obvious I got a different class, because of the pipeline), but don't know how to get to the real underlying model.