Skip to content

Commit ca1fe68

Browse files
committed
Release agtboost 0.9.2
See NEWS.md for details - Patch fixing slow gbt.save() functionality. - Obtain XGBoost and LightGBM hyperparameters from gbt.complexity(). - Include attribute "offset" in gbt.train() and predict(). - Throw error when gb-loss-approximation deviates from true loss. Suggest lower learning_rate. - Solves $\arg\min_\eta \sum_i l(y_i, g^{-1}(offset_i+\eta))$ numerically instead of simple average to obtain initial prediction - Deprecate warnings for zero-inflation - Decrease package size drastically by stripping debugging information
1 parent 0f1e82f commit ca1fe68

20 files changed

+177
-132
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,6 @@ rsconnect/
8383

8484
*.html
8585

86-
*.zip
86+
*.zip
87+
88+
.DS_Store

R-package/.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
^\.Rproj\.user$
33
^\.travis\.yml$
44
^NEWS\.md$ # A news file written in Markdown
5+
^cran-comments\.md$
56
^LICENSE

R-package/DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Package: agtboost
22
Type: Package
33
Title: Adaptive and Automatic Gradient Boosting Computations
44
Version: 0.9.2
5-
Date: 2020-09-06
5+
Date: 2021-11-09
66
Author: Berent Ånund Strømnes Lunde
77
Maintainer: Berent Ånund Strømnes Lunde <lundeberent@gmail.com>
88
Description: Fast and automatic gradient tree boosting designed

R-package/NEWS.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
------------------------------------------------------------------------
2-
agtboost 0.9.0 (2020-08-12)
2+
agtboost 0.9.2 (2021-11-12)
33
------------------------------------------------------------------------
44

5-
- Initial release.
5+
- Patch fixing slow gbt.save() functionality.
6+
- Obtain XGBoost and LightGBM hyperparameters from gbt.complexity().
7+
- Include attribute "offset" in gbt.train() and predict().
8+
- Throw error when gb-loss-approximation deviates from true loss. Suggest lower learning_rate.
9+
- Solves $\arg\min_\eta \sum_i l(y_i, g^{-1}(offset_i+\eta))$ numerically instead of simple average to obtain initial prediction
10+
- Deprecate warnings for zero-inflation
11+
- Decrease package size drastically by stripping debugging information
612

713
------------------------------------------------------------------------
814
agtboost 0.9.1 (2020-10-04)
@@ -13,11 +19,7 @@ agtboost 0.9.1 (2020-10-04)
1319
- Checked with rhub::check_with_sanitizers() and rhub::check_on_solaris()
1420

1521
------------------------------------------------------------------------
16-
agtboost 0.9.2 (2021-11-01)
22+
agtboost 0.9.0 (2020-08-12)
1723
------------------------------------------------------------------------
1824

19-
- Patch fixing slow gbt.save() functionality.
20-
- Obtain XGBoost and LightGBM hyperparameters from gbt.complexity().
21-
- Include attribute "offset" in gbt.train() and predict().
22-
- Throw error when gb-loss-approximation deviates from true loss. Suggest lower learning_rate.
23-
- Solves $\arg\min_\eta \sum_i l(y_i, g^{-1}(offset_i+\eta))$ numerically instead of simple average to obtain initial prediction
25+
- Initial release.

R-package/R/gbt.complexity.R

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,22 @@ gbt.model.complexity <- function(model){
6868
initial_raw_prediction = model$initialPred
6969

7070
res <- list(
71-
loss_function = loss_function,
72-
nrounds = model$get_num_trees(),
73-
learning_rate = model$get_learning_rate(),
74-
initial_raw_prediction = initial_raw_prediction,
75-
initial_prediction = transform_prediction(initial_raw_prediction, loss_function),
71+
"loss_function" = loss_function,
72+
"nrounds" = model$get_num_trees(),
73+
"learning_rate" = model$get_learning_rate(),
74+
"initial_raw_prediction" = initial_raw_prediction,
75+
"initial_prediction" = transform_prediction(initial_raw_prediction, loss_function),
7676
# # tree parameters
77-
max_depth = max(model$get_tree_depths()),
78-
min_loss_reductions = model$get_max_node_optimism(),
79-
sum_hessian_weights = model$get_min_hessian_weights(),
80-
number_of_leaves = max(model$get_num_leaves()),
77+
"max_depth" = max(model$get_tree_depths()),
78+
"min_loss_reductions" = model$get_max_node_optimism(),
79+
"sum_hessian_weights" = model$get_min_hessian_weights(),
80+
"number_of_leaves" = max(model$get_num_leaves()),
8181
# # objective
82-
l1_regularization = 0.0,
83-
l2_regularization = 0.0,
82+
"l1_regularization" = 0.0,
83+
"l2_regularization" = 0.0,
8484
# # sampling
85-
row_subsampling = 1.0,
86-
column_subsampling = 1.0
85+
"row_subsampling" = 1.0,
86+
"column_subsampling" = 1.0
8787
)
8888
return(res)
8989
}
@@ -114,8 +114,9 @@ gbt.model.complexity <- function(model){
114114
#' yte <- rnorm(n, xte, 1)
115115
#' model <- gbt.train(ytr, xtr, learning_rate = 0.1)
116116
#' gbt.complexity(model, type="xgboost")
117-
#' gbt.complexity(model, type="lightgbm)
117+
#' gbt.complexity(model, type="lightgbm")
118118
#' ## See demo(topic="gbt-complexity", package="agtboost")
119+
#' }
119120
#'
120121
#' @importFrom graphics barplot mtext par
121122
#' @rdname gbt.complexity
@@ -129,51 +130,50 @@ gbt.complexity <- function(model, type){
129130
# Setup or get agtboost implicit parameters/complexity measures
130131
model_complexity <- gbt.model.complexity(model)
131132

132-
133133
# Transform parameters/complexity into library-specific parameters
134-
attach(model_complexity)
135-
if(type=="xgboost"){
136-
# Transform agtboost parameters/complexity measures to xgboost parameters
137-
parameters = list(
138-
# ensemble param
139-
"base_score" = initial_prediction,
140-
"nrounds" = nrounds,
141-
"learning_rate" = learning_rate,
142-
# tree param
143-
"max_depth" = max_depth,
144-
"gamma" = min_loss_reductions,
145-
"min_child_weight" = sum_hessian_weights,
146-
"max_leaves" = number_of_leaves,
147-
"grow_policy" = "lossguide",
148-
# objective
149-
"objective" = loss_to_xgbloss(loss_function),
150-
"alpha" = 0.0,
151-
"lambda" = 0.0,
152-
# subsampling
153-
"subsample" = 1.0,
154-
"colsample_bytree" = 1.0
155-
)
156-
}else if(type=="lightgbm"){
157-
# Transform agtboost parameters/complexity measures to lightgbm parameters
158-
parameters = list(
159-
# ensemble param
160-
"init_score" = initial_prediction,
161-
"nrounds" = nrounds,
162-
"learning_rate" = learning_rate,
163-
# tree param
164-
"max_depth" = max_depth,
165-
"min_gain_to_split" = min_loss_reductions,
166-
"min_sum_hessian_in_leaf" = sum_hessian_weights,
167-
"num_leaves" = number_of_leaves,
168-
# objective
169-
"objective" = loss_to_lgbloss(loss_function),
170-
"lambda_l1" = 0.0,
171-
"lambda_l2" = 0.0,
172-
# subsampling
173-
"bagging_fraction" = 1.0,
174-
"feature_fraction" = 1.0
175-
)
176-
}
177-
detach(model_complexity)
134+
parameters = with(model_complexity,
135+
if(type=="xgboost"){
136+
# Transform agtboost parameters/complexity measures to xgboost parameters
137+
list(
138+
# ensemble param
139+
"base_score" = initial_prediction,
140+
"nrounds" = nrounds,
141+
"learning_rate" = learning_rate,
142+
# tree param
143+
"max_depth" = max_depth,
144+
"gamma" = min_loss_reductions,
145+
"min_child_weight" = sum_hessian_weights,
146+
"max_leaves" = number_of_leaves,
147+
"grow_policy" = "lossguide",
148+
# objective
149+
"objective" = loss_to_xgbloss(loss_function),
150+
"alpha" = 0.0,
151+
"lambda" = 0.0,
152+
# subsampling
153+
"subsample" = 1.0,
154+
"colsample_bytree" = 1.0
155+
)
156+
}else if(type=="lightgbm"){
157+
# Transform agtboost parameters/complexity measures to lightgbm parameters
158+
list(
159+
# ensemble param
160+
"init_score" = initial_prediction,
161+
"nrounds" = nrounds,
162+
"learning_rate" = learning_rate,
163+
# tree param
164+
"max_depth" = max_depth,
165+
"min_gain_to_split" = min_loss_reductions,
166+
"min_sum_hessian_in_leaf" = sum_hessian_weights,
167+
"num_leaves" = number_of_leaves,
168+
# objective
169+
"objective" = loss_to_lgbloss(loss_function),
170+
"lambda_l1" = 0.0,
171+
"lambda_l2" = 0.0,
172+
# subsampling
173+
"bagging_fraction" = 1.0,
174+
"feature_fraction" = 1.0
175+
)
176+
}
177+
)
178178
return(parameters)
179179
}

R-package/R/gbt.train.R

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#' @param previous_pred prediction vector for training. Boosted training given predictions from another model.
2727
#' @param weights weights vector for scaling contributions of individual observations. Default \code{NULL} (the unit vector).
2828
#' @param force_continued_learning Boolean: \code{FALSE} (default) stops at information stopping criterion, \code{TRUE} stops at \code{nround} iterations.
29-
#' @param offset add offset to the model \code(g(mu) = offset + F(x)).
29+
#' @param offset add offset to the model g(mu) = offset + F(x).
3030
#' @param ... additional parameters passed.
3131
#' \itemize{
3232
#' \item if loss_function is 'negbinom', dispersion must be provided in \code{...}
@@ -102,6 +102,9 @@ gbt.train <- function(y, x, learning_rate = 0.01,
102102
algorithm = "vanilla"
103103
}
104104
}
105+
if(loss_function %in% c("count::auto")){
106+
warning("The `count::auto` option to the `loss_function` argument of `gbt.train()` will be deprecated as of 0.9.3")
107+
}
105108

106109
error_messages <- c()
107110
error_messages_type <- c(
@@ -151,8 +154,6 @@ gbt.train <- function(y, x, learning_rate = 0.01,
151154
if(
152155
loss_function %in% c("mse", "logloss", "poisson", "gamma::neginv",
153156
"gamma::log", "negbinom",
154-
#"poisson::zip", "zero_inflation", "zero_inflation::poisson",
155-
#"zero_inflation::negbinom", "zero_inflation::auto",
156157
"count::auto")
157158
){}else{
158159
error_messages <- c(error_messages, error_messages_type["loss_fun"])
@@ -271,8 +272,15 @@ gbt.train <- function(y, x, learning_rate = 0.01,
271272
# train ensemble
272273
if(is.null(previous_pred)){
273274
# train from scratch
274-
mod$train(y,x, verbose, gsub_compare, force_continued_learning,
275-
weights, offset, !all(offset==0))
275+
mod$train(
276+
y,
277+
x,
278+
verbose,
279+
gsub_compare,
280+
force_continued_learning,
281+
weights,
282+
offset
283+
)
276284
}else{
277285

278286
# train from previous predictions

R-package/README.md

Lines changed: 0 additions & 31 deletions
This file was deleted.

R-package/cran-comments.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
------------------------------------------------------------------------
2+
agtboost 0.9.2 (2021-11-09)
3+
------------------------------------------------------------------------
4+
## Test environments
5+
* local darwin17 install, R 4.1.1
6+
* winbuilder
7+
* devtools check
8+
* rhub check_for_cran, check_on_solaris, check_with_sanitizers
9+
10+
## R CMD check results
11+
12+
0 errors | 0 warnings | 1 notes
13+
14+
* checking CRAN incoming feasibility ... NOTE
15+
Maintainer: 'Berent Ånund Strømnes Lunde <lundeberent@gmail.com>'
16+
17+
## Changes in agtboost 0.9.2
18+
Some patching of serialization/deserialization of model objects, along with new features for model training. A deprecation notice is included, and package should be smaller on some OS due to stripping debugging information.

R-package/inst/include/agtboost.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525
#include "initial_prediction.hpp"
2626

2727

28-
#endif // __GMGTB_HPP_INCLUDED__
28+
#endif // __GMGTB_HPP_INCLUDED__

R-package/inst/include/cir.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,4 @@ double simpson(Tvec<double>& fval, Tvec<double>& grid){
251251

252252
}
253253

254-
#endif
254+
#endif

0 commit comments

Comments
 (0)