Github user yanboliang commented on a diff in the pull request:
https://github.com/apache/spark/pull/12624#discussion_r61252164
--- Diff:
mllib/src/main/scala/org/apache/spark/ml/regression/GeneralizedLinearRegression.scala
---
@@ -834,43 +864,51 @@ object GeneralizedLinearRegressionModel extends
MLReadable[GeneralizedLinearRegr
/**
* :: Experimental ::
- * Summarizing Generalized Linear regression Fits.
+ * Summary of [[GeneralizedLinearRegression]] model and predictions.
*
* @param predictions predictions output by the model's `transform` method
- * @param predictionCol field in "predictions" which gives the prediction
value of each instance
* @param model the model that should be summarized
- * @param diagInvAtWA diagonal of matrix (A^T * W * A)^-1 in the last
iteration
- * @param numIterations number of iterations
- * @param solver the solver algorithm used for model training
*/
@Since("2.0.0")
@Experimental
class GeneralizedLinearRegressionSummary private[regression] (
@Since("2.0.0") @transient val predictions: DataFrame,
- @Since("2.0.0") val predictionCol: String,
- @Since("2.0.0") val model: GeneralizedLinearRegressionModel,
- private val diagInvAtWA: Array[Double],
- @Since("2.0.0") val numIterations: Int,
- @Since("2.0.0") val solver: String) extends Serializable {
+ model: GeneralizedLinearRegressionModel) extends Serializable {
import GeneralizedLinearRegression._
- private lazy val family = Family.fromName(model.getFamily)
- private lazy val link = if (model.isDefined(model.getParam("link"))) {
+ // Extract values from model immediately to avoid problems with user
reseting model Params.
+ // Coefficients is not a deep copy, but that is acceptable.
+
+ /**
+ * Field in "predictions" which gives the prediction value of each
instance
+ */
+ @Since("2.0.0")
+ val predictionCol: String = model.getPredictionCol
+
+ private val weightCol: String = model.getWeightCol
+ private val labelCol: String = model.getLabelCol
+
+ private[regression] val familyName: String = model.getFamily
+ private[regression] val family: Family = Family.fromName(familyName)
+ private[regression] val link: Link = if (model.isDefined(model.link)) {
Link.fromName(model.getLink)
} else {
family.defaultLink
}
+ private[regression] val fitIntercept: Boolean = model.getFitIntercept
+ private[regression] val intercept: Double = model.intercept
+ private[regression] val coefficients: Vector = model.coefficients
--- End diff --
If the model of ```GeneralizedLinearRegressionSummary``` is immutable, it's
not necessary to extract these values in advance.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]