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

    https://github.com/apache/spark/pull/14182#discussion_r74681629
  
    --- Diff: R/pkg/R/mllib.R ---
    @@ -299,6 +308,91 @@ setMethod("summary", signature(object = 
"NaiveBayesModel"),
                 return(list(apriori = apriori, tables = tables))
               })
     
    +#' Isotonic Regression Model
    +#'
    +#' Fits an Isotonic Regression model against a Spark DataFrame, similarly 
to R's isoreg().
    +#' Users can print, make predictions on the produced model and save the 
model to the input path.
    +#'
    +#' @param data 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 isotonic Whether the output sequence should be 
isotonic/increasing (TRUE) or
    +#'                 antitonic/decreasing (FALSE)
    +#' @param featureIndex The index of the feature if \code{featuresCol} is a 
vector column (default: `0`),
    +#'                     no effect otherwise
    +#' @param weightCol The weight column name.
    +#' @return \code{spark.isoreg} returns a fitted Isotonic Regression model
    +#' @rdname spark.isoreg
    +#' @aliases spark.isoreg,SparkDataFrame,formula-method
    +#' @name spark.isoreg
    +#' @export
    +#' @examples
    +#' \dontrun{
    +#' sparkR.session()
    +#' data <- list(list(7.0, 0.0), list(5.0, 1.0), list(3.0, 2.0),
    +#'         list(5.0, 3.0), list(1.0, 4.0))
    +#' df <- createDataFrame(data, c("label", "feature"))
    +#' model <- spark.isoreg(df, label ~ feature, isotonic = FALSE)
    +#' # return model boundaries and prediction as lists
    +#' result <- summary(model, df)
    +#' # prediction based on fitted model
    +#' predict_data <- list(list(-2.0), list(-1.0), list(0.5),
    +#'                 list(0.75), list(1.0), list(2.0), list(9.0))
    +#' predict_df <- createDataFrame(predict_data, c("feature"))
    +#' # get prediction column
    +#' predict_result <- collect(select(predict(model, predict_df), 
"prediction"))
    +#'
    +#' # save fitted model to input path
    +#' path <- "path/to/model"
    +#' write.ml(model, path)
    +#'
    +#' # can also read back the saved model and print
    +#' savedModel <- read.ml(path)
    +#' summary(savedModel)
    +#' }
    +#' @note spark.isoreg since 2.1.0
    +setMethod("spark.isoreg", signature(data = "SparkDataFrame", formula = 
"formula"),
    +          function(data, formula, isotonic = TRUE, featureIndex = 0, 
weightCol = NULL) {
    +            formula <- paste0(deparse(formula), collapse = "")
    +
    +            if (is.null(weightCol)) {
    +              weightCol <- ""
    +            }
    +
    +            jobj <- 
callJStatic("org.apache.spark.ml.r.IsotonicRegressionWrapper", "fit",
    +            data@sdf, formula, as.logical(isotonic), 
as.integer(featureIndex),
    +              as.character(weightCol))
    +            return(new("IsotonicRegressionModel", jobj = jobj))
    +          })
    +
    +#  Predicted values based on an isotonicRegression model
    +
    +#' @param object a fitted IsotonicRegressionModel
    +#' @param newData SparkDataFrame for testing
    +#' @return \code{predict} returns a SparkDataFrame containing predicted 
values
    +#' @rdname spark.isoreg
    +#' @export
    +#' @note predict(IsotonicRegressionModel) since 2.1.0
    +setMethod("predict", signature(object = "IsotonicRegressionModel"),
    +          function(object, newData) {
    +            return(dataFrame(callJMethod(object@jobj, "transform", 
newData@sdf)))
    +          })
    +
    +#  Get the summary of an IsotonicRegressionModel model
    +
    +#' @param object a fitted IsotonicRegressionModel
    --- End diff --
    
    @felixcheung I added `@param` for `summary`. Did I misunderstand anything? 
Thanks!


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

Reply via email to