Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/12624#discussion_r61477060
--- Diff:
mllib/src/main/scala/org/apache/spark/ml/regression/GeneralizedLinearRegression.scala
---
@@ -834,36 +836,55 @@ 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
+ * @param dataset Dataset to be summarized.
+ * @param origModel Model to be summarized. This is copied to create an
internal
+ * model which cannot be modified from outside.
*/
@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 {
+ dataset: Dataset[_],
+ origModel: GeneralizedLinearRegressionModel) extends Serializable {
import GeneralizedLinearRegression._
- private lazy val family = Family.fromName(model.getFamily)
- private lazy val link = if (model.isDefined(model.getParam("link"))) {
+ /**
+ * Field in "predictions" which gives the prediction value of each
instance.
+ * This is set to a new column name if the original model's
`predictionCol` is not set.
+ */
+ @Since("2.0.0")
+ val predictionCol: String = {
+ if (origModel.isDefined(origModel.predictionCol) &&
origModel.getPredictionCol != "") {
+ origModel.getPredictionCol
+ } else {
+ "prediction_" + java.util.UUID.randomUUID.toString
+ }
+ }
+
+ /**
+ * Private copy of model to ensure Params are not modified outside this
class.
+ * Coefficients is not a deep copy, but that is acceptable.
--- End diff --
I'm pretty sure it's a shallow copy of the coefficients:
[https://github.com/apache/spark/blob/89addd40abdacd65cc03ac8aa5f9cf3dd4a4c19b/mllib/src/main/scala/org/apache/spark/ml/regression/GeneralizedLinearRegression.scala#L776]
---
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]