-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-16143][R] group AFT survival regression methods docs in a single Rd #13927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -233,9 +233,10 @@ setMethod("predict", signature(object = "GeneralizedLinearRegressionModel"), | |
| # Makes predictions from a naive Bayes model or a model produced by spark.naiveBayes(), | ||
| # similarly to R package e1071's predict. | ||
|
|
||
| #' @rdname spark.naiveBayes | ||
| #' @param newData A SparkDataFrame for testing | ||
| #' @return \code{predict} returns a SparkDataFrame containing predicted labeled in a column named | ||
| #' "prediction" | ||
| #' @rdname spark.naiveBayes | ||
| #' @export | ||
| #' @note predict(NaiveBayesModel) since 2.0.0 | ||
| setMethod("predict", signature(object = "NaiveBayesModel"), | ||
|
|
@@ -439,25 +440,16 @@ setMethod("write.ml", signature(object = "NaiveBayesModel", path = "character"), | |
| invisible(callJMethod(writer, "save", path)) | ||
| }) | ||
|
|
||
| #' Save fitted MLlib model to the input path | ||
| #' | ||
| #' Save the AFT survival regression model to the input path. | ||
| #' | ||
| #' @param object A fitted AFT survival regression model | ||
| #' @param path The directory where the model is saved | ||
| #' @param overwrite Overwrites or not if the output path already exists. Default is FALSE | ||
| # Saves the AFT survival regression model to the input path. | ||
|
|
||
| #' @param path The directory where the model is savedist containing the model's coefficien | ||
| #' which means throw exception if the output path exists. | ||
| #' | ||
| #' @rdname write.ml | ||
| #' @rdname spark.survreg | ||
| #' @name write.ml | ||
| #' @export | ||
| #' @examples | ||
| #' \dontrun{ | ||
| #' model <- spark.survreg(trainingData, Surv(futime, fustat) ~ ecog_ps + rx) | ||
| #' path <- "path/to/model" | ||
| #' write.ml(model, path) | ||
| #' } | ||
| #' @note write.ml(AFTSurvivalRegressionModel, character) since 2.0.0 | ||
| #' @seealso \link{read.ml} | ||
| setMethod("write.ml", signature(object = "AFTSurvivalRegressionModel", path = "character"), | ||
| function(object, path, overwrite = FALSE) { | ||
| writer <- callJMethod(object@jobj, "write") | ||
|
|
@@ -542,22 +534,38 @@ read.ml <- function(path) { | |
| } | ||
| } | ||
|
|
||
| #' Fit an accelerated failure time (AFT) survival regression model. | ||
| #' Accelerated Failure Time (AFT) Survival Regression Model | ||
| #' | ||
| #' Fit an accelerated failure time (AFT) survival regression model on a Spark DataFrame. | ||
| #' \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 SparkDataFrame for training. | ||
| #' @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 a fitted AFT survival regression model | ||
| #' 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 | ||
| #' @examples | ||
| #' \dontrun{ | ||
| #' df <- createDataFrame(ovarian) | ||
| #' model <- spark.survreg(df, Surv(futime, fustat) ~ ecog_ps + rx) | ||
| #' | ||
| #' # get a summary of the model | ||
| #' summary(model) | ||
| #' | ||
| #' # make predictions | ||
| #' predicted <- predict(model, df) | ||
| #' 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"), | ||
|
|
@@ -569,20 +577,14 @@ setMethod("spark.survreg", signature(data = "SparkDataFrame", formula = "formula | |
| }) | ||
|
|
||
|
|
||
| #' Get the summary of an AFT survival regression model | ||
| #' | ||
| #' Returns the summary of an AFT survival regression model produced by spark.survreg(), | ||
| #' similarly to R's summary(). | ||
| #' | ||
| #' @param object a fitted AFT survival regression model | ||
| #' @return coefficients the model's coefficients, intercept and log(scale). | ||
| #' @rdname summary | ||
| # Returns a summary of the AFT survival regression model produced by spark.survreg, | ||
| # similarly to R's summary(). | ||
|
|
||
| #' @param object A fitted AFT survival regression model | ||
| #' @return \code{summary} returns a list containing the model's coefficients, | ||
| #' intercept and log(scale) | ||
| #' @rdname spark.survreg | ||
| #' @export | ||
| #' @examples | ||
| #' \dontrun{ | ||
| #' model <- spark.survreg(trainingData, Surv(futime, fustat) ~ ecog_ps + rx) | ||
| #' summary(model) | ||
| #' } | ||
| #' @note summary(AFTSurvivalRegressionModel) since 2.0.0 | ||
| setMethod("summary", signature(object = "AFTSurvivalRegressionModel"), | ||
| function(object, ...) { | ||
|
|
@@ -595,20 +597,14 @@ setMethod("summary", signature(object = "AFTSurvivalRegressionModel"), | |
| return(list(coefficients = coefficients)) | ||
| }) | ||
|
|
||
| #' Predicted values based on model | ||
| #' | ||
| #' Makes predictions from an AFT survival regression model or a model produced by spark.survreg(), | ||
| #' similarly to R package survival's predict. | ||
| #' | ||
| #' @param object A fitted AFT survival regression model | ||
| #' @rdname predict | ||
| # Makes predictions from an AFT survival regression model or a model produced by | ||
| # spark.survreg, similarly to R package survival's predict. | ||
|
|
||
| #' @param newData A SparkDataFrame for testing | ||
| #' @return \code{predict} returns a SparkDataFrame containing predicted values (median of | ||
|
||
| #' survival time) | ||
| #' @rdname spark.survreg | ||
| #' @export | ||
| #' @examples | ||
| #' \dontrun{ | ||
| #' model <- spark.survreg(trainingData, Surv(futime, fustat) ~ ecog_ps + rx) | ||
| #' predicted <- predict(model, testData) | ||
| #' showDF(predicted) | ||
| #' } | ||
| #' @note predict(AFTSurvivalRegressionModel) since 2.0.0 | ||
| setMethod("predict", signature(object = "AFTSurvivalRegressionModel"), | ||
| function(object, newData) { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flip the order - otherwise the newData parameter doesn't show in the generated doc.