Github user yanboliang commented on a diff in the pull request:
https://github.com/apache/spark/pull/18035#discussion_r117708969
--- Diff: R/pkg/R/mllib_classification.R ---
@@ -124,39 +125,30 @@ setMethod("predict", signature(object =
"LinearSVCModel"),
predict_internal(object, newData)
})
-# Get the summary of an LinearSVCModel
+# Get the summary of a linear SVM model.
-#' @param object an LinearSVCModel fitted by \code{spark.svmLinear}.
+#' @param object a linear SVM model fitted by \code{spark.svmLinear}.
#' @return \code{summary} returns summary information of the fitted model,
which is a list.
#' The list includes \code{coefficients} (coefficients of the
fitted model),
-#' \code{intercept} (intercept of the fitted model),
\code{numClasses} (number of classes),
-#' \code{numFeatures} (number of features).
+#' \code{numClasses} (number of classes), \code{numFeatures}
(number of features).
#' @rdname spark.svmLinear
#' @aliases summary,LinearSVCModel-method
#' @export
#' @note summary(LinearSVCModel) since 2.2.0
setMethod("summary", signature(object = "LinearSVCModel"),
function(object) {
jobj <- object@jobj
- features <- callJMethod(jobj, "features")
- labels <- callJMethod(jobj, "labels")
- coefficients <- callJMethod(jobj, "coefficients")
- nCol <- length(coefficients) / length(features)
- coefficients <- matrix(unlist(coefficients), ncol = nCol)
- intercept <- callJMethod(jobj, "intercept")
+ features <- callJMethod(jobj, "rFeatures")
+ coefficients <- callJMethod(jobj, "rCoefficients")
+ coefficients <- as.matrix(unlist(coefficients))
+ colnames(coefficients) <- c("Estimate")
+ rownames(coefficients) <- unlist(features)
numClasses <- callJMethod(jobj, "numClasses")
numFeatures <- callJMethod(jobj, "numFeatures")
- if (nCol == 1) {
--- End diff --
@felixcheung The change here is to make ```coefficients``` matrix has only
one column named ```Estimate```. I speculate the original code referred to
```spark.logit``` which supports multiple classification, so it should have
multiple columns and each columns' name should be corresponding label. However,
```LinearSVC``` will not support multiple classification in the future, so I
simplified it at here.
---
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]