Github user nakul02 commented on a diff in the pull request:
https://github.com/apache/spark/pull/9756#discussion_r46608766
--- Diff:
mllib/src/test/scala/org/apache/spark/ml/regression/LinearRegressionSuite.scala
---
@@ -592,21 +594,47 @@ class LinearRegressionSuite
}
/*
- Use the following R code to generate model training results.
-
- predictions <- predict(fit, newx=features)
- residuals <- label - predictions
- > mean(residuals^2) # MSE
- [1] 0.009720325
- > mean(abs(residuals)) # MAD
- [1] 0.07863206
- > cor(predictions, label)^2# r^2
- [,1]
- s0 0.9998749
+ # Use the following R code to generate model training results.
+
+ # path/part-00000 is the file generated by running
LinearDataGenerator.generateLinearInput
+ # as described before the beforeAll() method.
+ d1 <- read.csv("path/part-00000", header=FALSE,
stringsAsFactors=FALSE)
+ fit <- glm(V1 ~ V2 + V3, data = d1, family = "gaussian")
+ names(f1)[1] = c("V2")
+ names(f1)[2] = c("V3")
+ f1 <- data.frame(as.numeric(d1$V2), as.numeric(d1$V3))
+ predictions <- predict(fit, newdata=f1)
+ l1 <- as.numeric(d1$V1)
+
+ residuals <- l1 - predictions
+ > mean(residuals^2) # MSE
+ [1] 0.00985449
+ > mean(abs(residuals)) # MAD
+ [1] 0.07961668
+ > cor(predictions, l1)^2 # r^2
+ [1] 0.9998737
+
+ > summary(fit)
+
+ Call:
+ glm(formula = V1 ~ V2 + V3, family = "gaussian", data = d1)
+
+ Deviance Residuals:
+ Min 1Q Median 3Q Max
+ -0.47082 -0.06797 0.00002 0.06725 0.34635
+
+ Coefficients:
+ Estimate Std. Error t value Pr(>|t|)
+ (Intercept) 6.3022157 0.0018600 3388 <2e-16 ***
+ V2 4.6982442 0.0011805 3980 <2e-16 ***
+ V3 7.1994344 0.0009044 7961 <2e-16 ***
+ ---
+
+ ....
*/
- assert(model.summary.meanSquaredError ~== 0.00972035 relTol 1E-5)
- assert(model.summary.meanAbsoluteError ~== 0.07863206 relTol 1E-5)
- assert(model.summary.r2 ~== 0.9998749 relTol 1E-5)
+ assert(model.summary.meanSquaredError ~== 0.00985449 relTol 1E-5)
+ assert(model.summary.meanAbsoluteError ~== 0.07961668 relTol 1E-5)
+ assert(model.summary.r2 ~== 0.9998737 relTol 1E-5)
--- End diff --
@srowen - all of the tests in these 2 files (LinearRegressionSuite &
RegressionEvaluatorSuite) seed the Random number generator with a fixed number
(42 in this case).
The Random number generator then, for a given platform, should always
create the same pseudo random sequence. When this is true, the tests will pass
with the set thresholds (or maybe lower).
As luck would have it, tests haven't failed with either JDK7 or 8 on Linux
or Mac (or so I understand).
For a "principled" analysis, for all possible pseudo-random sequences of a
given size (10000 for one of the test cases), that are possible, one would
calculate the result and the threshold. The lowest threshold allowed would then
be set into the test. This is obviously a lot of work and could be set aside as
a separate JIRA if someone really wants it done this way.
As to increasing it 10x, IMHO - there is no more discipline (or reason) in
doing this than there was in setting it to the values that are present.
---
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]