Github user tengpeng commented on a diff in the pull request:
https://github.com/apache/spark/pull/19638#discussion_r148692614
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/evaluation/RegressionMetrics.scala
---
@@ -125,4 +125,14 @@ class RegressionMetrics @Since("2.0.0") (
1 - SSerr / SStot
}
}
+
+ /**
+ * Returns adjusted R^2^, the adjusted coefficient of determination.
+ * @see <a
href="https://en.wikipedia.org/wiki/Coefficient_of_determination#Adjusted_R2">
+ * Coefficient of determination (Wikipedia)</a>
+ */
+ @Since("2.3.0")
+ def r2adj: Double = {
+ 1 - (SSerr / (summary.count - summary.numParam - 1)) / (SStot /
(summary.count - 1))
--- End diff --
1. Will handle the no intercept case.
2. You are absolutely correct there is an issue in design.
> Ok, but then you can't use it when doing cross validation right?
- For linear regression, there is nothing to cross validate. For penalized
methods, like Lasso, `R^2` is not used for cross validation at any time.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]