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

    https://github.com/apache/spark/pull/14392#discussion_r72994997
  
    --- Diff: R/pkg/R/mllib.R ---
    @@ -632,3 +659,106 @@ setMethod("predict", signature(object = 
"AFTSurvivalRegressionModel"),
               function(object, newData) {
                 return(dataFrame(callJMethod(object@jobj, "transform", 
newData@sdf)))
               })
    +
    +#' Multivariate Gaussian Mixture Model (GMM)
    +#'
    +#' Fits multivariate gaussian mixture model against a Spark DataFrame, 
similarly to R's
    +#' mvnormalmixEM(). 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.
    +#'
    +#' @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 '-'.
    +#'                Note that the response variable of formula is empty in 
spark.mvnormalmixEM.
    +#' @param k Number of independent Gaussians in the mixture model.
    +#' @param maxIter Maximum iteration number
    +#' @param tol The convergence tolerance
    +#' @aliases spark.mvnormalmixEM,SparkDataFrame,formula-method
    +#' @return \code{spark.mvnormalmixEM} returns a fitted multivariate 
gaussian mixture model
    +#' @rdname spark.mvnormalmixEM
    +#' @name spark.mvnormalmixEM
    +#' @export
    +#' @examples
    +#' \dontrun{
    +#' sparkR.session()
    +#' library(mvtnorm)
    +#' set.seed(100)
    +#' a <- rmvnorm(4, c(0, 0))
    +#' b <- rmvnorm(6, c(3, 4))
    +#' data <- rbind(a, b)
    +#' df <- createDataFrame(as.data.frame(data))
    +#' model <- spark.mvnormalmixEM(df, ~ V1 + V2, k = 2)
    +#' summary(model)
    +#'
    +#' # fitted values on training data
    +#' fitted <- predict(model, df)
    +#' head(select(fitted, "V1", "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.mvnormalmixEM since 2.1.0
    +#' @seealso mixtools: 
\url{https://cran.r-project.org/web/packages/mixtools/}
    +#' @seealso \link{predict}, \link{read.ml}, \link{write.ml}
    +setMethod("spark.mvnormalmixEM", signature(data = "SparkDataFrame", 
formula = "formula"),
    +          function(data, formula, k = 2, maxIter = 100, tol = 0.01) {
    +            formula <- paste(deparse(formula), collapse = "")
    +            jobj <- 
callJStatic("org.apache.spark.ml.r.GaussianMixtureWrapper", "fit", data@sdf,
    +                                formula, as.integer(k), 
as.integer(maxIter), tol)
    +            return(new("GaussianMixtureModel", jobj = jobj))
    +          })
    +
    +#  Get the summary of a multivariate gaussian mixture model
    +
    +#' @param object A fitted gaussian mixture model
    +#' @return \code{summary} returns the model's lambda, mu, sigma and 
posterior
    +#' @rdname spark.mvnormalmixEM
    --- End diff --
    
    We have grouped ```spark.mvnormalmixEM```, ```summary``` and ```predict``` 
together in docs, should we also need to add @aliases for each function? I saw 
we did not do this for  other SparkR ML wrappers such as ```spark.glm```. 
Please correct me if I have misunderstand.


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