Github user felixcheung commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14447#discussion_r74870995
  
    --- Diff: R/pkg/R/mllib.R ---
    @@ -414,6 +421,94 @@ setMethod("predict", signature(object = "KMeansModel"),
                 return(dataFrame(callJMethod(object@jobj, "transform", 
newData@sdf)))
               })
     
    +#' Multilayer Perceptron Classification Model
    +#'
    +#' \code{spark.mlp} fits a multi-layer perceptron neural network model 
against a SparkDataFrame.
    +#' Users can call \code{summary} to print a summary of the fitted model, 
\code{predict} to make
    +#' predictions on new data, and \code{write.ml}/\code{read.ml} to 
save/load fitted models.
    +#' Only categorical data is supported.
    +#' For more details, see
    +#' 
\href{http://spark.apache.org/docs/latest/ml-classification-regression.html
    +#' #multilayer-perceptron-classifier}{Multilayerperceptron classifier}.
    +#'
    +#' @param data A \code{SparkDataFrame} of observations and labels for 
model fitting
    +#' @param blockSize BlockSize parameter
    +#' @param layers Integer vector containing the number of nodes for each 
layer
    +#' @param solver Solver parameter, supported options: "gd" (minibatch 
gradient descent) or "l-bfgs"
    +#' @param maxIter Maximum iteration number
    +#' @param tol Convergence tolerance of iterations
    +#' @param stepSize StepSize parameter
    +#' @param seed Seed parameter for weights initialization
    +#' @return \code{spark.mlp} returns a fitted Multilayer Perceptron 
Classification Model
    +#' @rdname spark.mlp
    +#' @aliases spark.mlp,SparkDataFrame-method
    +#' @name spark.mlp
    +#' @seealso \link{read.ml}
    +#' @export
    +#' @examples
    +#' \dontrun{
    +#' df <- read.df("data/mllib/sample_multiclass_classification_data.txt", 
source = "libsvm")
    +#'
    +#' # fit a Multilayer Perceptron Classification Model
    +#' model <- spark.mlp(df, blockSize = 128, layers = c(4, 5, 4, 3), solver 
= "l-bfgs",
    +#'                    maxIter = 100, tol = 0.5, stepSize = 1, seed = 1)
    +#'
    +#' # get the summary of the model
    +#' summary(model)
    +#'
    +#' # make predictions
    +#' predictions <- predict(model, df)
    +#'
    +#' # save and load the model
    +#' path <- "path/to/model"
    +#' write.ml(model, path)
    +#' savedModel <- read.ml(path)
    +#' summary(savedModel)
    +#' }
    +#' @note spark.mlp since 2.1.0
    +setMethod("spark.mlp", signature(data = "SparkDataFrame"),
    +          function(data, blockSize = 128, layers = c(3, 5, 2), solver = 
"l-bfgs", maxIter = 100,
    +                   tol = 0.5, stepSize = 1, seed = 1, ...) {
    +            jobj <- 
callJStatic("org.apache.spark.ml.r.MultilayerPerceptronClassifierWrapper",
    +                                "fit", data@sdf, as.integer(blockSize), 
as.array(layers),
    +                                as.character(solver), as.integer(maxIter), 
as.numeric(tol),
    +                                as.numeric(stepSize), as.integer(seed))
    +            return(new("MultilayerPerceptronClassificationModel", jobj = 
jobj))
    +          })
    +
    +# Makes predictions from a model produced by spark.mlp().
    +
    +#' @param newData A SparkDataFrame for testing
    +#' @return \code{predict} returns a SparkDataFrame containing predicted 
labeled in a column named
    +#' "prediction"
    +#' @rdname spark.mlp
    +#' @aliases predict,MultilayerPerceptronClassificationModel-method
    +#' @export
    +#' @note predict(MultilayerPerceptronClassificationModel) since 2.1.0
    +setMethod("predict", signature(object = 
"MultilayerPerceptronClassificationModel"),
    +          function(object, newData) {
    +            return(dataFrame(callJMethod(object@jobj, "transform", 
newData@sdf)))
    +          })
    +
    +# Returns the summary of a Multilayer Perceptron Classification Model 
produced by \code{spark.mlp}
    +
    +#' @param object A Multilayer Perceptron Classification Model fitted by 
\code{spark.mlp}
    --- End diff --
    
    add `@param ... Currently not used` for CRAN check


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to