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

    https://github.com/apache/spark/pull/13690#discussion_r82512787
  
    --- Diff: R/pkg/R/mllib.R ---
    @@ -1427,3 +1447,185 @@ print.summary.KSTest <- function(x, ...) {
       cat(summaryStr, "\n")
       invisible(x)
     }
    +
    +#' Decision Tree Model for Regression and Classification
    +#'
    +#' \code{spark.decisionTree} fits a Decision Tree Regression model or 
Classification model on
    +#' a SparkDataFrame. Users can call \code{summary} to get a summary of the 
fitted Decision Tree
    +#' model, \code{predict} to make predictions on new data, and 
\code{write.ml}/\code{read.ml} to
    +#' save/load fitted models.
    +#' For more details, see 
\href{https://en.wikipedia.org/wiki/Decision_tree_learning}{Decision Tree}
    +#'
    +#' @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 
'-'.
    +#' @param type type of model to fit
    +#' @param maxDepth Maximum depth of the tree (>= 0).
    +#' @param maxBins Maximum number of bins used for discretizing continuous 
features and for choosing
    +#'                how to split on features at each node. More bins give 
higher granularity. Must be
    +#'                >= 2 and >= number of categories in any categorical 
feature. (default = 32)
    +#' @param ... additional arguments passed to the method.
    +#' @aliases spark.decisionTree,SparkDataFrame,formula-method
    +#' @return \code{spark.decisionTree} returns a fitted Decision Tree model.
    +#' @rdname spark.decisionTree
    +#' @name spark.decisionTree
    +#' @export
    +#' @examples
    +#' \dontrun{
    +#' df <- createDataFrame(longley)
    +#'
    +#' # fit a Decision Tree Regression Model
    +#' model <- spark.decisionTree(data, Employed ~ ., type = "regression", 
maxDepth = 5, maxBins = 16)
    +#'
    +#' # 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.decisionTree since 2.1.0
    +setMethod("spark.decisionTree", signature(data = "SparkDataFrame", formula 
= "formula"),
    +          function(data, formula, type = c("regression", "classification"),
    +                   maxDepth = 5, maxBins = 32 ) {
    +            type <- match.arg(type)
    +            formula <- paste(deparse(formula), collapse = "")
    +            switch(type,
    +                   regression =  {
    +                     jobj <- 
callJStatic("org.apache.spark.ml.r.DecisionTreeRegressorWrapper",
    +                                         "fit", data@sdf, formula, 
as.integer(maxDepth),
    +                                         as.integer(maxBins))
    +                     new("DecisionTreeRegressionModel", jobj = jobj)
    +                   },
    +                   classification = {
    +                     jobj <- 
callJStatic("org.apache.spark.ml.r.DecisionTreeClassifierWrapper",
    +                                         "fit", data@sdf, formula, 
as.integer(maxDepth),
    +                                         as.integer(maxBins))
    +                     new("DecisionTreeClassificationModel", jobj = jobj)
    +                   }
    +            )
    +          })
    +
    +# Makes predictions from a Decision Tree Regression model or
    +# a model produced by spark.decisionTree()
    --- End diff --
    
    Isn't the `Decision Tree Regression model` produced by 
`spark.decisionTree()`? could you clarify?


---
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