[ https://issues.apache.org/jira/browse/SPARK-9005?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Feynman Liang updated SPARK-9005: --------------------------------- Description: {{RegressionMetrics}} currently computes explainedVariance using {{summary.variance(1)}} (variance of the residuals) where the [Wikipedia definition|https://en.wikipedia.org/wiki/Fraction_of_variance_unexplained] uses the residual sum of squares {{math.pow(summary.normL2(1), 2)}}. The two coincide only when the predictor is unbiased (e.g. an intercept term is included in a linear model), but this is not always the case. We should change to be consistent. The computation for r2 is also currently incorrect. Multiplying by {{summary.count - 1}} appears to be trying to compute an adjusted r2, but the lack of a DoF adjustment in the numerator makes the computation inconsistent with [Wikipedia's definition|https://en.wikipedia.org/wiki/Coefficient_of_determination]. Since {{RegresionMetrics}} is not given the number of regression variables, we should modify and explicitly document that this computes unadjusted R2. was: {{RegressionMetrics}} currently computes explainedVariance using {{summary.variance(1)}} (variance of the residuals) where the [Wikipedia definition|https://en.wikipedia.org/wiki/Fraction_of_variance_unexplained] uses the residual sum of squares {{math.pow(summary.normL2(1), 2)}}. We should change to be consistent. The computation for r2 is also currently incorrect. Multiplying by {{summary.count - 1}} appears to be trying to compute an adjusted r2, but the lack of a DoF adjustment in the numerator makes the computation inconsistent with [Wikipedia's definition|https://en.wikipedia.org/wiki/Coefficient_of_determination]. Since {{RegresionMetrics}} is not given the number of regression variables, we should modify and explicitly document that this computes unadjusted R2. > RegressionMetrics computing incorrect explainedVariance and r2 > -------------------------------------------------------------- > > Key: SPARK-9005 > URL: https://issues.apache.org/jira/browse/SPARK-9005 > Project: Spark > Issue Type: Bug > Components: MLlib > Reporter: Feynman Liang > > {{RegressionMetrics}} currently computes explainedVariance using > {{summary.variance(1)}} (variance of the residuals) where the [Wikipedia > definition|https://en.wikipedia.org/wiki/Fraction_of_variance_unexplained] > uses the residual sum of squares {{math.pow(summary.normL2(1), 2)}}. The two > coincide only when the predictor is unbiased (e.g. an intercept term is > included in a linear model), but this is not always the case. We should > change to be consistent. > The computation for r2 is also currently incorrect. Multiplying by > {{summary.count - 1}} appears to be trying to compute an adjusted r2, but the > lack of a DoF adjustment in the numerator makes the computation inconsistent > with [Wikipedia's > definition|https://en.wikipedia.org/wiki/Coefficient_of_determination]. Since > {{RegresionMetrics}} is not given the number of regression variables, we > should modify and explicitly document that this computes unadjusted R2. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org