Repository: spark
Updated Branches:
  refs/heads/master 6ea5055fa -> 71b7d42f5


[SPARK-16445][MLLIB][SPARKR] Fix @return description for sparkR mlp summary() 
method

## What changes were proposed in this pull request?

Fix summary() method's `return` description for spark.mlp

## How was this patch tested?

Ran tests locally on my laptop.

Author: Xin Ren <[email protected]>

Closes #15015 from keypointt/SPARK-16445-2.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/71b7d42f
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/71b7d42f
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/71b7d42f

Branch: refs/heads/master
Commit: 71b7d42f5fa8d3a891ce831eedb308d1f407dd7e
Parents: 6ea5055
Author: Xin Ren <[email protected]>
Authored: Sat Sep 10 09:52:53 2016 -0700
Committer: Shivaram Venkataraman <[email protected]>
Committed: Sat Sep 10 09:52:53 2016 -0700

----------------------------------------------------------------------
 R/pkg/R/mllib.R                        | 6 +++---
 R/pkg/inst/tests/testthat/test_mllib.R | 2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/71b7d42f/R/pkg/R/mllib.R
----------------------------------------------------------------------
diff --git a/R/pkg/R/mllib.R b/R/pkg/R/mllib.R
index f8d1095..234b208 100644
--- a/R/pkg/R/mllib.R
+++ b/R/pkg/R/mllib.R
@@ -720,8 +720,9 @@ setMethod("predict", signature(object = 
"MultilayerPerceptronClassificationModel
 # Returns the summary of a Multilayer Perceptron Classification Model produced 
by \code{spark.mlp}
 
 #' @param object a Multilayer Perceptron Classification Model fitted by 
\code{spark.mlp}
-#' @return \code{summary} returns a list containing \code{layers}, the label 
distribution, and
-#'         \code{tables}, conditional probabilities given the target label.
+#' @return \code{summary} returns a list containing \code{labelCount}, 
\code{layers}, and
+#'         \code{weights}. For \code{weights}, it is a numeric vector with 
length equal to
+#'         the expected given the architecture (i.e., for 8-10-2 network, 100 
connection weights).
 #' @rdname spark.mlp
 #' @export
 #' @aliases summary,MultilayerPerceptronClassificationModel-method
@@ -732,7 +733,6 @@ setMethod("summary", signature(object = 
"MultilayerPerceptronClassificationModel
             labelCount <- callJMethod(jobj, "labelCount")
             layers <- unlist(callJMethod(jobj, "layers"))
             weights <- callJMethod(jobj, "weights")
-            weights <- matrix(weights, nrow = length(weights))
             list(labelCount = labelCount, layers = layers, weights = weights)
           })
 

http://git-wip-us.apache.org/repos/asf/spark/blob/71b7d42f/R/pkg/inst/tests/testthat/test_mllib.R
----------------------------------------------------------------------
diff --git a/R/pkg/inst/tests/testthat/test_mllib.R 
b/R/pkg/inst/tests/testthat/test_mllib.R
index ac896cf..5b1404c 100644
--- a/R/pkg/inst/tests/testthat/test_mllib.R
+++ b/R/pkg/inst/tests/testthat/test_mllib.R
@@ -369,6 +369,8 @@ test_that("spark.mlp", {
   expect_equal(summary$labelCount, 3)
   expect_equal(summary$layers, c(4, 5, 4, 3))
   expect_equal(length(summary$weights), 64)
+  expect_equal(head(summary$weights, 5), list(-0.878743, 0.2154151, -1.16304, 
-0.6583214, 1.009825),
+               tolerance = 1e-6)
 
   # Test predict method
   mlpTestDF <- df


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to