From bfb6fd2fe6baff75b49e6a5b456919cf63e370f6 Mon Sep 17 00:00:00 2001 From: Simon Coulombe Date: Fri, 22 May 2020 08:27:29 -0400 Subject: [PATCH] add count:poisson and reg:tweedie to build_fit_formula_xgb() --- R/model-xgboost.R | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/R/model-xgboost.R b/R/model-xgboost.R index 38f713e..158dd3e 100644 --- a/R/model-xgboost.R +++ b/R/model-xgboost.R @@ -141,9 +141,16 @@ build_fit_formula_xgb <- function(parsedmodel) { } else if (objective %in% c("binary:logistic", "reg:logistic")) { assigned <- 1 f <- expr(1 - 1 / (1 + exp(!!f))) + } else if (objective %in% c("count:poisson")) { + assigned <- 1 + f <- expr(exp(!!f)) + } else if (objective %in% c("reg:tweedie")) { + assigned <- 1 + f <- expr(0.5 * exp(!!f)) ## I'm not sure why one has to multiply by 0.5, but it works. + } if (assigned == 0) { - stop("Only objectives 'binary:logistic', 'reg:linear', 'reg:logistic', 'binary:logitraw' are supported yet.") + stop("Only objectives 'binary:logistic', 'reg:linear', 'reg:logistic', 'binary:logitraw', 'count:poisson','reg:tweedie' are supported yet.") } f }