Skip to content

[SPARK-16144][SPARKR] update R API doc for mllib #13993

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
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions R/pkg/R/generics.R
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,6 @@ setGeneric("spark.glm", function(data, formula, ...) { standardGeneric("spark.gl
#' @export
setGeneric("glm")

#' predict
#' @rdname predict
#' @export
setGeneric("predict", function(object, ...) { standardGeneric("predict") })
Expand All @@ -1272,7 +1271,6 @@ setGeneric("spark.naiveBayes", function(data, formula, ...) { standardGeneric("s
#' @export
setGeneric("spark.survreg", function(data, formula, ...) { standardGeneric("spark.survreg") })

#' write.ml
#' @rdname write.ml
#' @export
setGeneric("write.ml", function(object, path, ...) { standardGeneric("write.ml") })
36 changes: 30 additions & 6 deletions R/pkg/R/mllib.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,29 @@ setClass("AFTSurvivalRegressionModel", representation(jobj = "jobj"))
#' @note KMeansModel since 2.0.0
setClass("KMeansModel", representation(jobj = "jobj"))

#' Saves the MLlib model to the input path
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest shorter title like "Save Machine Learning Model"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the convention that has been suggested is that we have the page title being the same first sentence of the description?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sort of have some impression, but would this be too restrictive? @shivaram

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The write.ml can only be used for saving MLlib models, it can not save other machine learning model produced by native R functions. So I think the current description is accurate enough.

#'
#' Saves the MLlib model to the input path. For more information, see the specific
#' MLlib model below.
#' @rdname write.ml
#' @name write.ml
#' @export
#' @seealso \link{spark.glm}, \link{glm}
#' @seealso \link{spark.kmeans}, \link{spark.naiveBayes}, \link{spark.survreg}
#' @seealso \link{read.ml}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to add @seealso \link{write.ml} in the docs of read.ml.

NULL

#' Makes predictions from a MLlib model
#'
#' Makes predictions from a MLlib model. For more information, see the specific
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes -> Make?

Copy link
Member Author

@felixcheung felixcheung Jul 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, here, the "singular verb" with "s" is the convention. Please see eg. https://github.com/apache/spark/pull/13993/files#diff-7ede1519b4a56647801b51af33c2dd18R81

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch - agreed.

#' MLlib model below.
#' @rdname predict
#' @name predict
#' @export
#' @seealso \link{spark.glm}, \link{glm}
#' @seealso \link{spark.kmeans}, \link{spark.naiveBayes}, \link{spark.survreg}
NULL

#' Generalized Linear Models
#'
#' Fits generalized linear model against a Spark DataFrame. Users can print, make predictions on the
Expand Down Expand Up @@ -145,7 +168,7 @@ setMethod("glm", signature(formula = "formula", family = "ANY", data = "SparkDat
})

# Returns the summary of a model produced by glm() or spark.glm(), similarly to R's summary().
#'

#' @param object A fitted generalized linear model
#' @return \code{summary} returns a summary object of the fitted model, a list of components
#' including at least the coefficients, null/residual deviance, null/residual degrees
Expand Down Expand Up @@ -185,7 +208,7 @@ setMethod("summary", signature(object = "GeneralizedLinearRegressionModel"),
})

# Prints the summary of GeneralizedLinearRegressionModel
#'

#' @rdname spark.glm
#' @param x Summary object of fitted generalized linear model returned by \code{summary} function
#' @export
Expand Down Expand Up @@ -343,7 +366,7 @@ setMethod("fitted", signature(object = "KMeansModel"),
})

# Get the summary of a k-means model
#'

#' @param object A fitted k-means model
#' @return \code{summary} returns the model's coefficients, size and cluster
#' @rdname spark.kmeans
Expand All @@ -370,7 +393,7 @@ setMethod("summary", signature(object = "KMeansModel"),
})

# Predicted values based on a k-means model
#'

#' @return \code{predict} returns the predicted values based on a k-means model
#' @rdname spark.kmeans
#' @export
Expand Down Expand Up @@ -463,7 +486,7 @@ setMethod("write.ml", signature(object = "AFTSurvivalRegressionModel", path = "c
})

# Saves the generalized linear 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.
Expand All @@ -481,7 +504,7 @@ setMethod("write.ml", signature(object = "GeneralizedLinearRegressionModel", pat
})

# Save fitted MLlib 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.
Expand All @@ -506,6 +529,7 @@ setMethod("write.ml", signature(object = "KMeansModel", path = "character"),
#' @rdname read.ml
#' @name read.ml
#' @export
#' @seealso \link{write.ml}
#' @examples
#' \dontrun{
#' path <- "path/to/model"
Expand Down