You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by felixcheung <gi...@git.apache.org> on 2017/03/12 20:19:27 UTC

[GitHub] spark pull request #16729: [SPARK-19391][SparkR][ML] Tweedie GLM API for Spa...

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

    https://github.com/apache/spark/pull/16729#discussion_r105567727
  
    --- Diff: R/pkg/R/mllib_regression.R ---
    @@ -84,14 +93,25 @@ setClass("IsotonicRegressionModel", representation(jobj = "jobj"))
     #' # can also read back the saved model and print
     #' savedModel <- read.ml(path)
     #' summary(savedModel)
    +#'
    +#' # fit tweedie model
    +#' model <- spark.glm(df, Freq ~ Sex + Age, family = "tweedie",
    +#'                    variancePower = 1.2, linkPower = 0)
    +#' summary(model)
     #' }
     #' @note spark.glm since 2.0.0
     #' @seealso \link{glm}, \link{read.ml}
     setMethod("spark.glm", signature(data = "SparkDataFrame", formula = "formula"),
               function(data, formula, family = gaussian, tol = 1e-6, maxIter = 25, weightCol = NULL,
    -                   regParam = 0.0) {
    +                   regParam = 0.0, variancePower = 0.0, linkPower = 1.0 - variancePower) {
    +
                 if (is.character(family)) {
    -              family <- get(family, mode = "function", envir = parent.frame())
    +              # Handle when family = "tweedie"
    +              if (tolower(family) == "tweedie") {
    +                family <- list(family = "tweedie", link = "linkNotUsed")
    --- End diff --
    
    nit: I think you can set link = NULL


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

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