diff options
author | Yanbo Liang <ybliang8@gmail.com> | 2016-12-02 12:16:57 -0800 |
---|---|---|
committer | Joseph K. Bradley <joseph@databricks.com> | 2016-12-02 12:16:57 -0800 |
commit | a985dd8e99d2663a3cb4745c675fa2057aa67155 (patch) | |
tree | 2655ae0d069ea9642b406618dc9401e60f94ba8a /R | |
parent | 48778976e0566d9c93a8c900825def82c6b81fd6 (diff) | |
download | spark-a985dd8e99d2663a3cb4745c675fa2057aa67155.tar.gz spark-a985dd8e99d2663a3cb4745c675fa2057aa67155.tar.bz2 spark-a985dd8e99d2663a3cb4745c675fa2057aa67155.zip |
[SPARK-18291][SPARKR][ML] Revert "[SPARK-18291][SPARKR][ML] SparkR glm predict should output original label when family = binomial."
## What changes were proposed in this pull request?
It's better we can fix this issue by providing an option ```type``` for users to change the ```predict``` output schema, then they could output probabilities, log-space predictions, or original labels. In order to not involve breaking API change for 2.1, so revert this change firstly and will add it back after [SPARK-18618](https://issues.apache.org/jira/browse/SPARK-18618) resolved.
## How was this patch tested?
Existing unit tests.
This reverts commit daa975f4bfa4f904697bf3365a4be9987032e490.
Author: Yanbo Liang <ybliang8@gmail.com>
Closes #16118 from yanboliang/spark-18291-revert.
Diffstat (limited to 'R')
-rw-r--r-- | R/pkg/inst/tests/testthat/test_mllib.R | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/R/pkg/inst/tests/testthat/test_mllib.R b/R/pkg/inst/tests/testthat/test_mllib.R index 0553e704bd..dcfeeb4cd2 100644 --- a/R/pkg/inst/tests/testthat/test_mllib.R +++ b/R/pkg/inst/tests/testthat/test_mllib.R @@ -64,16 +64,6 @@ test_that("spark.glm and predict", { rVals <- predict(glm(Sepal.Width ~ Sepal.Length + Species, data = iris), iris) expect_true(all(abs(rVals - vals) < 1e-6), rVals - vals) - # binomial family - binomialTraining <- training[training$Species %in% c("versicolor", "virginica"), ] - model <- spark.glm(binomialTraining, Species ~ Sepal_Length + Sepal_Width, - family = binomial(link = "logit")) - prediction <- predict(model, binomialTraining) - expect_equal(typeof(take(select(prediction, "prediction"), 1)$prediction), "character") - expected <- c("virginica", "virginica", "virginica", "versicolor", "virginica", - "versicolor", "virginica", "versicolor", "virginica", "versicolor") - expect_equal(as.list(take(select(prediction, "prediction"), 10))[[1]], expected) - # poisson family model <- spark.glm(training, Sepal_Width ~ Sepal_Length + Species, family = poisson(link = identity)) @@ -138,10 +128,10 @@ test_that("spark.glm summary", { expect_equal(stats$aic, rStats$aic) # Test spark.glm works with weighted dataset - a1 <- c(0, 1, 2, 3, 4) - a2 <- c(5, 2, 1, 3, 2) - w <- c(1, 2, 3, 4, 5) - b <- c(1, 0, 1, 0, 0) + a1 <- c(0, 1, 2, 3) + a2 <- c(5, 2, 1, 3) + w <- c(1, 2, 3, 4) + b <- c(1, 0, 1, 0) data <- as.data.frame(cbind(a1, a2, w, b)) df <- createDataFrame(data) @@ -168,7 +158,7 @@ test_that("spark.glm summary", { data <- as.data.frame(cbind(a1, a2, b)) df <- suppressWarnings(createDataFrame(data)) regStats <- summary(spark.glm(df, b ~ a1 + a2, regParam = 1.0)) - expect_equal(regStats$aic, 14.00976, tolerance = 1e-4) # 14.00976 is from summary() result + expect_equal(regStats$aic, 13.32836, tolerance = 1e-4) # 13.32836 is from summary() result # Test spark.glm works on collinear data A <- matrix(c(1, 2, 3, 4, 2, 4, 6, 8), 4, 2) |