diff options
author | Yanbo Liang <ybliang8@gmail.com> | 2017-01-21 21:26:14 -0800 |
---|---|---|
committer | Yanbo Liang <ybliang8@gmail.com> | 2017-01-21 21:26:14 -0800 |
commit | 0c589e3713655f25547d6945a40786da900ec2fc (patch) | |
tree | fbf39946e63f951d815c4b8b423c305624985d96 /R/pkg/inst/tests | |
parent | 3dcad9fab17297f9966026f29fefb5c726965a13 (diff) | |
download | spark-0c589e3713655f25547d6945a40786da900ec2fc.tar.gz spark-0c589e3713655f25547d6945a40786da900ec2fc.tar.bz2 spark-0c589e3713655f25547d6945a40786da900ec2fc.zip |
[SPARK-19291][SPARKR][ML] spark.gaussianMixture supports output log-likelihood.
## What changes were proposed in this pull request?
```spark.gaussianMixture``` supports output total log-likelihood for the model like R ```mvnormalmixEM```.
## How was this patch tested?
R unit test.
Author: Yanbo Liang <ybliang8@gmail.com>
Closes #16646 from yanboliang/spark-19291.
Diffstat (limited to 'R/pkg/inst/tests')
-rw-r--r-- | R/pkg/inst/tests/testthat/test_mllib_clustering.R | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/R/pkg/inst/tests/testthat/test_mllib_clustering.R b/R/pkg/inst/tests/testthat/test_mllib_clustering.R index cfbdea5c04..9de8362cde 100644 --- a/R/pkg/inst/tests/testthat/test_mllib_clustering.R +++ b/R/pkg/inst/tests/testthat/test_mllib_clustering.R @@ -56,6 +56,10 @@ test_that("spark.gaussianMixture", { # [,1] [,2] # [1,] 0.2961543 0.160783 # [2,] 0.1607830 1.008878 + # + #' model$loglik + # + # [1] -46.89499 # nolint end data <- list(list(-0.6264538, 0.1836433), list(-0.8356286, 1.5952808), list(0.3295078, -0.8204684), list(0.4874291, 0.7383247), @@ -72,9 +76,11 @@ test_that("spark.gaussianMixture", { rMu <- c(0.11731091, -0.06192351, 10.363673, 9.897081) rSigma <- c(0.62049934, 0.06880802, 0.06880802, 1.27431874, 0.2961543, 0.160783, 0.1607830, 1.008878) + rLoglik <- -46.89499 expect_equal(stats$lambda, rLambda, tolerance = 1e-3) expect_equal(unlist(stats$mu), rMu, tolerance = 1e-3) expect_equal(unlist(stats$sigma), rSigma, tolerance = 1e-3) + expect_equal(unlist(stats$loglik), rLoglik, tolerance = 1e-3) p <- collect(select(predict(model, df), "prediction")) expect_equal(p$prediction, c(0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1)) @@ -88,6 +94,7 @@ test_that("spark.gaussianMixture", { expect_equal(stats$lambda, stats2$lambda) expect_equal(unlist(stats$mu), unlist(stats2$mu)) expect_equal(unlist(stats$sigma), unlist(stats2$sigma)) + expect_equal(unlist(stats$loglik), unlist(stats2$loglik)) unlink(modelPath) }) |