-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support for gamma and poisson regression #36
Comments
Hello @spedygiorgio, Certainly! It may be a few days before I can get around to it, but for now you can just use the # Setup
data(mtcars)
library(ggplot2)
library(pdp)
library(xgboost)
set.seed(101)
bst <- xgboost(data = as.matrix(mtcars[, -11]), label = mtcars[, 11],
objective = "count:poisson", nrounds = 50)
# PDP prediction function for XGBoost with Poisson deviance
pfun <- function(object, newdata) {
mean(exp(predict(object, newdata = as.matrix(newdata))))
}
# One variable
bst %>%
partial(pred.var = "mpg", pred.fun = pfun, train = mtcars[, -11]) %>%
autoplot() +
ylab("Number of carburetors") +
theme_light()
# Two variables
pdp.mpg.hp <- partial(bst, pred.var = c("mpg", "hp"), pred.fun = pfun,
chull = TRUE, train = mtcars[, -11])
autoplot(pdp.mpg.hp, contour = TRUE, legend.title = "Number of\ncarburetors") In the meantime, please let me know if you need anything else. Thanks for using the package and thanks for offering useful feedback about how it can be improved. Best, Brandon |
Note, I used |
I'll probably remove the restriction for non-Gaussian cases for all supported models and add an partial(poisson.bst, pred.var = "mpg", pred.fun = pfun, train = mtcars[, -11], inv.link = exp) |
Hi, @bgreenwell thank you for your feedback and sorry for my late answer. I believed to have alrready thanked you. I would like to provide some more suggestions... Always on xgboost models, for some problems it is used to create data with weight (e.g. when modeling claim severity) and base margin (eg. offset for poisson rate regression). For example, I transform data.frame to xgboost matrices using the following function:
Does the pdp package allows for base_margin and weight? |
The |
Thank you really very much for your attention
Il ven 31 mar 2017, 19:46 Brandon Greenwell <notifications@github.com> ha
scritto:
… The partial function internally calls predict.xgb.Booster for
"xgb.Booster" objects, so offsets and weights should be accounted for.
I'll look into further this weekend to be sure.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#36 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAyWxjwvQU_ex4ZkVtcG22evSV2M9nJgks5rrTwAgaJpZM4Mcmc5>
.
|
On second thought, |
Hi @spedygiorgio, So it looks like the sample weights only contribute to the loss function while building an XGBoost model, so |
Hi, maybe we can assume a default value for the offset...
For poisson regression I know that it is zero, so I would expose it as a
function parameter with default value zero. Also we can assume a default
value of 1 for weight...
Il mar 4 apr 2017, 15:20 Brandon Greenwell <notifications@github.com> ha
scritto:
… Hi @spedygiorgio <https://github.com/spedygiorgio>,
So it looks like the sample weights only contribute to the loss function
while building an XGBoost model, so partial should take that into
account. However, I am still trying to figure out how to incorporate
offsets. partial makes predictions over a grid, so an offset would need
to be supplies for each grid point and I'm not sure how realistic that is.
I think, however, that the best option for incorporating offsets is to just
compute PDPs for over the original training data. More to come and how this
might be accomplished...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#36 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAyWxi4sEwoyppRiY5qpwxiYqwsdpnpCks5rskOCgaJpZM4Mcmc5>
.
|
Closing this issue. Opened another regarding handling offsets (#38). |
Hi @bgreenwell thank you so much for your awesome package... Really fantastic..
Nevertheless, we have noticed that it only supports gaussian regression and classification. Is it possible to further implement gamma and poisson regressions? I am using xgboost 0.6.x
Thank in advance for your attention
Giorgio
The text was updated successfully, but these errors were encountered: