irboost {irboost} | R Documentation |
fit a robust predictive model with iteratively reweighted boosting algorithm
Description
Fit a predictive model with the iteratively reweighted convex optimization (IRCO) that minimizes the robust loss functions in the CC-family (concave-convex). The convex optimization is conducted by functional descent boosting algorithm in the R package xgboost. The iteratively reweighted boosting (IRBoost) algorithm reduces the weight of the observation that leads to a large loss; it also provides weights to help identify outliers. Applications include the robust generalized linear models and extensions, where the mean is related to the predictors by boosting, and robust accelerated failure time models.
Usage
irboost(
data,
label,
weights,
params = list(),
z_init = NULL,
cfun = "ccave",
s = 1,
delta = 0.1,
iter = 10,
nrounds = 100,
del = 1e-10,
trace = FALSE,
...
)
Arguments
data |
input data, if |
label |
response variable. Quantitative for |
weights |
vector of nobs with non-negative weights |
params |
the list of parameters,
|
z_init |
vector of nobs with initial convex component values, must be non-negative with default values = weights if provided, otherwise z_init = vector of 1s |
cfun |
concave component of CC-family, can be |
s |
tuning parameter of |
delta |
a small positive number provided by user only if |
iter |
number of iteration in the IRCO algorithm |
nrounds |
boosting iterations within each IRCO iteration |
del |
convergency criteria in the IRCO algorithm, no relation to |
trace |
if |
... |
other arguments passing to |
Value
An object with S3 class xgboost
with the additional elments:
-
weight_update_log
a matrix ofnobs
row byiter
column of observation weights in each iteration of the IRCO algorithm -
weight_update
a vector of observation weights in the last IRCO iteration that produces the final model fit loss_log
sum of loss value of the composite function in each IRCO iteration. Note,cfun
requiresobjective
non-negative in some cases. Thus care must be taken. For instance, withobjective="reg:gamma"
, the loss value is defined by gamma-nloglik - (1+log(min(y))), where y=label. The second term is introduced such that the loss value is non-negative. In fact, gamma-nloglik=y/ypre + log(ypre) in thexgboost
, where ypre is the mean prediction value, can be negative. It can be derived that for fixedy
, the minimum value of gamma-nloglik is achived at ypre=y, or 1+log(y). Thus, among alllabel
values, the minimum of gamma-nloglik is 1+log(min(y)).
Author(s)
Zhu Wang
Maintainer: Zhu Wang zhuwang@gmail.com
References
Wang, Zhu (2021), Unified Robust Boosting, arXiv eprint, https://arxiv.org/abs/2101.07718
Examples
# regression, logistic regression, Poisson regression
x <- matrix(rnorm(100*2),100,2)
g2 <- sample(c(0,1),100,replace=TRUE)
fit1 <- irboost(data=x, label=g2, cfun="acave",s=0.5,
params=list(objective="reg:squarederror", max_depth=1), trace=TRUE,
verbose=0, nrounds=50)
fit2 <- irboost(data=x, label=g2, cfun="acave",s=0.5,
params=list(objective="binary:logitraw", max_depth=1), trace=TRUE,
verbose=0, nrounds=50)
fit3 <- irboost(data=x, label=g2, cfun="acave",s=0.5,
params=list(objective="binary:hinge", max_depth=1), trace=TRUE,
verbose=0, nrounds=50)
fit4 <- irboost(data=x, label=g2, cfun="acave",s=0.5,
params=list(objective="count:poisson", max_depth=1), trace=TRUE,
verbose=0, nrounds=50)
# Gamma regression
x <- matrix(rnorm(100*2),100,2)
g2 <- sample(rgamma(100, 1))
library("xgboost")
param <- list(objective="reg:gamma", max_depth=1)
fit5 <- xgboost(data=x, label=g2, params=param, nrounds=50)
fit6 <- irboost(data=x, label=g2, cfun="acave",s=5, params=param, trace=TRUE,
verbose=0, nrounds=50)
plot(predict(fit5, newdata=x), predict(fit6, newdata=x))
hist(fit6$weight_update)
plot(fit6$loss_log)
summary(fit6$weight_update)
# Tweedie regression
param <- list(objective="reg:tweedie", max_depth=1)
fit6t <- irboost(data=x, label=g2, cfun="acave",s=5, params=param,
trace=TRUE, verbose=0, nrounds=50)
# Gamma vs Tweedie regression
hist(fit6$weight_update)
hist(fit6t$weight_update)
plot(predict(fit6, newdata=x), predict(fit6t, newdata=x))
# multiclass classification in iris dataset:
lb <- as.numeric(iris$Species)-1
num_class <- 3
set.seed(11)
param <- list(objective="multi:softprob", max_depth=4, eta=0.5, nthread=2,
subsample=0.5, num_class=num_class)
fit7 <- irboost(data=as.matrix(iris[, -5]), label=lb, cfun="acave", s=50,
params=param, trace=TRUE, verbose=0, nrounds=10)
# predict for softmax returns num_class probability numbers per case:
pred7 <- predict(fit7, newdata=as.matrix(iris[, -5]))
# reshape it to a num_class-columns matrix
pred7 <- matrix(pred7, ncol=num_class, byrow=TRUE)
# convert the probabilities to softmax labels
pred7_labels <- max.col(pred7) - 1
# classification error: 0!
sum(pred7_labels != lb)/length(lb)
table(lb, pred7_labels)
hist(fit7$weight_update)