Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/7771#discussion_r35914255
--- Diff: R/pkg/R/mllib.R ---
@@ -71,3 +71,27 @@ setMethod("predict", signature(object = "PipelineModel"),
function(object, newData) {
return(dataFrame(callJMethod(object@model, "transform",
newData@sdf)))
})
+
+#' Get statistics on a model.
+#'
+#' Returns statistics on a model produced by glm(), similarly to R's
summary().
+#'
+#' @param model A fitted MLlib model
+#' @return data.frame containing model statistics
+#' @rdname glm
+#' @export
+#' @examples
+#'\dontrun{
+#' model <- glm(y ~ x, trainingData)
+#' summary(model)
+#'}
+setMethod("summary", signature(object = "PipelineModel"),
+ function(object) {
+ features <-
callJStatic("org.apache.spark.ml.api.r.SparkRWrappers",
+ "getModelFeatures", object@model)
+ weights <-
callJStatic("org.apache.spark.ml.api.r.SparkRWrappers",
+ "getModelWeights", object@model)
+ stats <- data.frame(unlist(features), unlist(weights))
--- End diff --
In R, `summary` returns a named list instead of a data.frame. It contains a
field called `coefficients`, which is an R matrix with row/col names. We should
implement `summary` the same way.
---
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]