Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/13927#discussion_r68638675
--- Diff: R/pkg/R/mllib.R ---
@@ -420,44 +440,96 @@ setMethod("spark.naiveBayes", signature(data =
"SparkDataFrame", formula = "form
return(new("NaiveBayesModel", jobj = jobj))
})
-# Saves the Bernoulli naive Bayes model to the input path.
-
-#' @param path The directory where the model is saved
-#' @param overwrite Overwrites or not if the output path already exists.
Default is FALSE
-#' which means throw exception if the output path exists.
+#' Accelerated Failure Time (AFT) Survival Regression Model.
#'
-#' @rdname spark.naiveBayes
+#' \code{spark.survreg} fits an accelerated failure time (AFT) survival
regression model on
+#' a SparkDataFrame. Users can call \code{summary} to get a summary of the
fitted AFT model,
+#' \code{predict} to make predictions on new data, and
\code{write.ml}/\code{read.ml} to
+#' save/load fitted models.
+#'
+#' @param data A SparkDataFrame for training.
+#' @param formula A symbolic description of the model to be fitted.
Currently only a few formula
+#' operators are supported, including '~', ':', '+', and
'-'.
+#' Note that operator '.' is not supported currently.
+#' @return \code{spark.survreg} returns a fitted AFT survival regression
model
+#' @rdname spark.survreg
+#' @seealso survival:
\url{https://cran.r-project.org/web/packages/survival/}
#' @export
-#' @seealso \link{read.ml}
-#' @note write.ml(NaiveBayesModel, character) since 2.0.0
-setMethod("write.ml", signature(object = "NaiveBayesModel", path =
"character"),
- function(object, path, overwrite = FALSE) {
- writer <- callJMethod(object@jobj, "write")
- if (overwrite) {
- writer <- callJMethod(writer, "overwrite")
- }
- invisible(callJMethod(writer, "save", path))
- })
-
-#' Save fitted MLlib model to the input path
+#' @examples
+#' \dontrun{
+#' library(survival)
+#' df <- createDataFrame(ovarian)
+#' model <- spark.survreg(df, Surv(futime, fustat) ~ ecog_ps + rx)
#'
-#' Save the AFT survival regression model to the input path.
+#' # get summary of the model
+#' summary(model)
+#'
+#' # make predictions
+#' predicted <- predict(model, df) ## fitted value on training data
+#' showDF(predicted)
#'
+#' # save and load the model
+#' path <- "path/to/model"
+#' write.ml(model, path)
+#' savedModel <- read.ml(path)
+#' summary(savedModel)
+#' }
+#' @note spark.survreg since 2.0.0
+setMethod("spark.survreg", signature(data = "SparkDataFrame", formula =
"formula"),
--- End diff --
Please do not move code blocks unless it is necessary. It makes it hard to
review the changes and causes conflicts with other PRs. If we want to
re-organize the ordering, we should do that in a separate PR without any real
code changes.
---
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]