Github user actuaryzhang commented on a diff in the pull request:
https://github.com/apache/spark/pull/16699#discussion_r100976709
--- Diff:
mllib/src/main/scala/org/apache/spark/ml/regression/GeneralizedLinearRegression.scala
---
@@ -1139,54 +1189,52 @@ class GeneralizedLinearRegressionSummary
private[regression] (
/** Degrees of freedom. */
@Since("2.0.0")
- lazy val degreesOfFreedom: Long = {
- numInstances - rank
- }
+ lazy val degreesOfFreedom: Long = numInstances - rank
/** The residual degrees of freedom. */
@Since("2.0.0")
lazy val residualDegreeOfFreedom: Long = degreesOfFreedom
/** The residual degrees of freedom for the null model. */
@Since("2.0.0")
- lazy val residualDegreeOfFreedomNull: Long = if (model.getFitIntercept) {
- numInstances - 1
- } else {
- numInstances
+ lazy val residualDegreeOfFreedomNull: Long = {
+ if (model.getFitIntercept) numInstances - 1 else numInstances
}
- private def weightCol: Column = {
- if (!model.isDefined(model.weightCol) || model.getWeightCol.isEmpty) {
- lit(1.0)
- } else {
- col(model.getWeightCol)
- }
+ private def label: Column = col(model.getLabelCol).cast(DoubleType)
+
+ private def prediction: Column = col(predictionCol)
+
+ private def weight: Column = {
+ if (!isSetWeightCol(model)) lit(1.0) else col(model.getWeightCol)
--- End diff --
The computation is the same, but I just changed the name. The original name
was kind of confusing: the name `xxxCol` is used to refer the string name in
almost all other places, but here it was used as `Column`. Since I need to add
the offset column, I just updated the name so that they are consistent. Also,
the method `isSetWeightCol` is a simple wrapper of the old logic that checks
both setting and nonempty of weightCol. It is also used in a few other places,
hence the wrapper.
---
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]