Skip to content

Commit

Permalink
version 2.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gregridgeway authored and cran-robot committed Jun 29, 2024
1 parent f7c7e41 commit 27ed18f
Show file tree
Hide file tree
Showing 39 changed files with 274 additions and 252 deletions.
34 changes: 15 additions & 19 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
Package: gbm
Version: 2.1.9
Version: 2.2.2
Title: Generalized Boosted Regression Models
Authors@R: c(
person("Ridgeway", "Greg",
person("Greg", "Ridgeway",
email = "gridge@upenn.edu",
role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-6911-0804")),
person("Daniel", "Edwards",
email = "unknown@unknown.com",
role = "ctb",
comment = c(ORCID = "0000-0002-8120-0084")),
role = "ctb"),
person("Brian", "Kriegler",
email = "bkriegler@econone.com",
role = "ctb",
comment = c(ORCID = "0000-0002-8120-0084")),
role = "ctb"),
person("Stefan", "Schroedl",
email = "stefan@atomwise.com",
role = "ctb",
comment = c(ORCID = "0000-0002-8120-0084")),
role = "ctb"),
person("Harry", "Southworth",
email = "harry@dataclarityconsulting.co.uk",
role = "ctb",
comment = c(ORCID = "0000-0002-8120-0084")),
role = "ctb"),
person("Brandon", "Greenwell",
email = "greenwell.brandon@gmail.com",
role = "ctb",
Expand Down Expand Up @@ -52,19 +48,19 @@ License: GPL (>= 2) | file LICENSE
URL: https://github.com/gbm-developers/gbm
BugReports: https://github.com/gbm-developers/gbm/issues
Encoding: UTF-8
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
VignetteBuilder: knitr
NeedsCompilation: yes
Packaged: 2024-01-10 16:15:43 UTC; greg_
Author: Ridgeway Greg [aut, cre] (<https://orcid.org/0000-0001-6911-0804>),
Daniel Edwards [ctb] (<https://orcid.org/0000-0002-8120-0084>),
Brian Kriegler [ctb] (<https://orcid.org/0000-0002-8120-0084>),
Stefan Schroedl [ctb] (<https://orcid.org/0000-0002-8120-0084>),
Harry Southworth [ctb] (<https://orcid.org/0000-0002-8120-0084>),
Packaged: 2024-06-26 12:33:00 UTC; greg_
Author: Greg Ridgeway [aut, cre] (<https://orcid.org/0000-0001-6911-0804>),
Daniel Edwards [ctb],
Brian Kriegler [ctb],
Stefan Schroedl [ctb],
Harry Southworth [ctb],
Brandon Greenwell [ctb] (<https://orcid.org/0000-0002-8120-0084>),
Bradley Boehmke [ctb] (<https://orcid.org/0000-0002-3611-8516>),
Jay Cunningham [ctb],
GBM Developers [aut] (https://github.com/gbm-developers)
Maintainer: Ridgeway Greg <gridge@upenn.edu>
Maintainer: Greg Ridgeway <gridge@upenn.edu>
Repository: CRAN
Date/Publication: 2024-01-10 21:23:15 UTC
Date/Publication: 2024-06-28 06:20:02 UTC
76 changes: 38 additions & 38 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
13d645ea5a474dec3c644512353ee958 *CHANGES
64b4a2e144395ffcaf8507f483754172 *DESCRIPTION
e8a38246290de8fe95c46ac1ebc38f2e *DESCRIPTION
73ed5410da67876bbccbc45fda025419 *LICENSE
8a3be7d6e9633a3f4a89c866a98df466 *NAMESPACE
7df0f18225094712a3d207c4486a7db7 *NEWS.md
30015ca11f94eab451fcfa77bf7283b6 *R/basehaz.gbm.R
3f6808cb2e1ed79239d9c2b6722399ca *R/calibrate.plot.R
08efd83992c074fb1c93f5140d80f508 *R/gbm-internals.R
bd5749be971d74833200f760ade7b286 *R/gbm-package.R
688bf34a31974b997020f6d3eae12cec *R/gbm-internals.R
e100ef1e30f39323e8fb5b37f4d8e287 *R/gbm-package.R
de5d551d0dcd8061a77cbd728bb915b3 *R/gbm.R
71c3b7b6ab249546493d78a7ac67f3b5 *R/gbm.fit.R
f2310d9a5225ecacd1a28b13720646b6 *R/gbm.fit.R
6647c2a0cf4b52f74282d4a30a28c782 *R/gbm.more.R
0eb9492a4889dd77c7b93ff268e75873 *R/gbm.object.R
5ddc9dfe12ff465c75b11330bdf4551b *R/gbm.perf.R
6506a4c195e33ea806a0719e058202a0 *R/gbmCrossVal.R
2dc03e69665e4599c7289f2993eb3250 *R/gbmCrossVal.R
b6d4e6c4e10836d532d2d5cf4e8d692b *R/interact.gbm.R
03f0e1b453cd47ce2da756d9c873627c *R/ir.measures.R
ca11cea5656713e463f95791318b498f *R/plot.gbm.R
Expand All @@ -22,10 +22,10 @@ b3400b409ef852a38f2c93eca941c42d *R/predict.gbm.R
37f93983b3789b3549b825b052746538 *R/reconstructGBMdata.R
933e88de5ef87ab875028c5dba6e5829 *R/relative.influence.R
08f46c17919f160031d6a2f18cd6ef19 *R/test.gbm.R
a8e091a6102cd9a111ce34609abf0c43 *R/utils.R
8d5424719baba6f979cc347268487581 *R/utils.R
b7c53e14f289dc6caa147cb80b381355 *R/zzz.R
9d96211a993278ccaa571850bf8e4209 *README.md
7ef4695348ab090cc701fdf459be41d5 *build/vignette.rds
2a555c7321f4ebc815961fd106c7c578 *build/vignette.rds
34473f8b2b3d89242031c1af2af38155 *demo/00Index
c8111e88c09d7a1b3729b41f67b871d1 *demo/OOB-reps.R
0b6bf4e6c515ffea8a137067f03724d7 *demo/bernoulli.R
Expand All @@ -36,15 +36,15 @@ ee94468e32b128e2b7689a61853a998b *demo/coxph.R
fe8f5f9946ae5cd80cf18c033488d5c5 *demo/printExamples.R
ac91cb39bbb7b8072ba65cf5933bcf68 *demo/robustReg.R
94b9c4c04c246fd60085115c9f5a7cf8 *inst/doc/gbm.Rnw
c1dc0bd6bce467c448752a4b17ed5bb3 *inst/doc/gbm.pdf
b0ff78e02298d83412611177b001f844 *inst/doc/gbm.pdf
d7dfb5eccdb0251ad7b9bda805040cdf *inst/tinytest/test_bernoulli.R
0ecf23a69c73dc027f34b243a9476eae *inst/tinytest/test_coxph.R
08794176cae150c50cc7bd8e36dbdd23 *inst/tinytest/test_least_squares.R
0015c0bb9b92caefb3233ca592ef26b8 *inst/tinytest/test_relative_influence.R
055bd4822b0fa0192e8252df774749f7 *man/basehaz.gbm.Rd
63c9c494f46f5435ba5929fc6635557c *man/calibrate.plot.Rd
c2ba2c010f3bf3b1b1d879a9a06fa263 *man/gbm-internals.Rd
bba5cca188affb5768e0a283a1d9a16b *man/gbm-package.Rd
710ff7b9b3914708202a6c31c4da448c *man/gbm-package.Rd
716427ed642502c7a633f6e691a02198 *man/gbm.Rd
2a033c4b1eb145278f354148c18183b7 *man/gbm.fit.Rd
b4728cd03e5ca0807ce012514c397747 *man/gbm.more.Rd
Expand All @@ -62,54 +62,54 @@ df48c14dc7d0f50f60d3e69eb79ed4fe *man/reconstructGBMdata.Rd
069434ff43e5f47a2cf584d51d61fd3b *man/relative.influence.Rd
eeb8e8f08f7d57a76c29169682128fd4 *man/summary.gbm.Rd
abb04bba52be23fc28a479c5052bcbf2 *man/test.gbm.Rd
93ccd2f42d70f9e9ad450cbf62b4877c *src/adaboost.cpp
2f5d22dc3043e69628763cbe303e6b5f *src/adaboost.h
c877a1d31fa93463ed5d3ccd2164aa80 *src/bernoulli.cpp
323f73ab809cff64ad5b4f336157f295 *src/bernoulli.h
088062cab2532d24fa3a9fc5affcf69a *src/buildinfo.h
9a8e2ff37f4bbc272786d7fb9f018f84 *src/adaboost.cpp
8bc0e7e6170218dc764317a071ff7929 *src/adaboost.h
1725d231e272a6353bc694525c5da0f7 *src/bernoulli.cpp
1b6ea8a45b1a6b9820bf0dbba721acd6 *src/bernoulli.h
91e43b317576bdf297617babbc600840 *src/buildinfo.h
e15f767c646f66e54eb5bb20ccd7cebd *src/coxph.cpp
c8b01f926ddafe1ff39f33f71aed5d0e *src/coxph.h
f1bea0a96e9bba97336f64aef316659d *src/coxph.h
3616890b5d7af2b3edd52dc5f29544b0 *src/dataset.cpp
d30f46362b1915f76e5a328ce95c7136 *src/dataset.h
b5824ccf353076bf59018429ae3ac6ac *src/distribution.cpp
91d88e455827695f63bf23df5dfb3108 *src/distribution.h
6d2bd44a11975c8f023640eb7a9036c3 *src/gaussian.cpp
6c2bf2616a3b4491aaaf501346246d3f *src/gaussian.h
ca699b9ef743d6f4c44a469a12dfc7b2 *src/gaussian.h
27ffff3bcc49d50e130083ef8f2081e5 *src/gbm-init.c
1d8d4e59887769602b1d3c8dc3d5f94f *src/gbm.cpp
0f49e8549558916322ec80e29b591a73 *src/gbm.h
884c1603e6c98b2ae795ed35b07556bd *src/gbm.cpp
37dfe9bd4a1d1d9e70b9d61c44949b91 *src/gbm.h
c0c572eb464dae70700ffe8fdc3f6b9f *src/gbm_engine.cpp
b3f1f49fa614ac6cfd52b28191bfdb70 *src/gbm_engine.h
c27a350cf827d2decc682ee8ece8332b *src/gbmentry.cpp
87f344712c06f95ca9ada358aaa3f74a *src/gbm_engine.h
55715ab97df43bf3f1e62ed2a17e2bb7 *src/gbmentry.cpp
1fba83f37e9f092d8b005e0c8f32a97b *src/huberized.cpp
141e5b762944c14a0b6294e15046296f *src/huberized.h
c5d517b5b38d60df04b9ca6bcc08211a *src/laplace.cpp
53b4d97c482517fbbc97162da1adf891 *src/laplace.h
d25bcfb8da3565604f902270b25eb470 *src/locationm.cpp
932f3d98f158ebf6ae11ed47e873a7f3 *src/locationm.h
39094967ceaabf7c744bc93d0b86d22f *src/matrix.h
3cf9f4cf7fe9388b6834b043f587d0e0 *src/multinomial.cpp
8798fe266a8bad59ac9b3e7019cebbe8 *src/multinomial.h
e2e3e25937cde555f9099b3099aecf82 *src/huberized.h
ad0c18190ee958063e3f68564e52b204 *src/laplace.cpp
a109ba9c2fd1f34dbd04033081580adf *src/laplace.h
45ede1eab442e5165ecde06bb5e0a028 *src/locationm.cpp
b79ca7b9c1ece1f8cad0f2958046f436 *src/locationm.h
5ce6e2bb396ca0b45b97270abae1bb36 *src/matrix.h
8036edaddcc69c2b8c3f130706f491c7 *src/multinomial.cpp
2ea82018296bb369e77f96ac9c31c483 *src/multinomial.h
75737afcbdd3162c62fcdd82b027e1d2 *src/node.cpp
3f7d35689f88a25a8f536d31c4ce172b *src/node.h
11d20f2bb5fad44684e8ceef011f490d *src/node.h
2e99439ebd925c2fe54e609ad93affea *src/node_categorical.cpp
98afbdcf5bb70211102e58ed262fcec1 *src/node_categorical.h
a04d827631d157efd47de6ef63633858 *src/node_continuous.cpp
f09bd89f861430f58cb80ccf0de77c6a *src/node_continuous.h
af2b9dd107d657344891521829c52243 *src/node_factory.cpp
3b80b8101a773a42a06eb41b5c6b01c9 *src/node_factory.h
b39d639f336508ce5b86a4539b754366 *src/node_factory.h
56dc9a7a6309294654e641c14a32023d *src/node_nonterminal.cpp
062cbcf913ad61d33048c36ab0b76735 *src/node_nonterminal.h
a99c0738f82cb857c87b45a65d4e8f25 *src/node_search.cpp
8cb0947734d82c4bd219ceb6f723c3bb *src/node_search.h
3f255ece01a44a03fa19e2a1cd4f1c79 *src/node_search.cpp
4e7e0301f857dae21654e3f1b352a638 *src/node_search.h
c6943942255ce8138259b6b47caa0c08 *src/node_terminal.cpp
084bcc63d1b33ca200460b88ef36b8f6 *src/node_terminal.h
b763976a9c68d9e975417a84b7e2b3c4 *src/pairwise.cpp
47fc321706b5bcd749bb5b6cc766c36b *src/pairwise.h
b9753b03cb6ac034a62ad24d7d86c82d *src/node_terminal.h
67575e1a6a961c63f3898e334bb5d46e *src/pairwise.cpp
a15faf94a4de6b6e5b7b82834766cc3b *src/pairwise.h
756422dc1f3f394260fa4d77ec42d1ed *src/poisson.cpp
0c901877981c1df8c4d82f6dd99c9231 *src/poisson.h
64e10460138c1b67923020b58cf1a599 *src/quantile.cpp
491d792d90d047d5a8c192253b632252 *src/quantile.h
f59ea02f9d947cbba7e37fdba58384b4 *src/poisson.h
6091d95aba012b027507708aebdaf899 *src/quantile.cpp
91e37941d9bcb59386adb5b2bc1ea350 *src/quantile.h
519b30584e7e752480750e86027aea7e *src/tdist.cpp
9ab15eb81fc9a18ee7d14a76f7aefd2a *src/tdist.h
276e36bf158250eb458a1cdabcf975b5 *src/tree.cpp
Expand Down
2 changes: 1 addition & 1 deletion R/gbm-internals.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
guessDist <- function(y){
# If distribution is not given, try to guess it
if (length(unique(y)) == 2){ d <- "bernoulli" }
else if ("Surv" %in% class(y)){ d <- "coxph" }
else if (inherits(y, "Surv")){ d <- "coxph" }
else if (is.factor(y)){ d <- "multinomial" }
else{ d <- "gaussian" }
cat(paste("Distribution not specified, assuming", d, "...\n"))
Expand Down
7 changes: 3 additions & 4 deletions R/gbm-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
#'
#' @useDynLib gbm, .registration = TRUE
#'
#' @name gbm-package
#'
#' @docType package
#'
#' @author Greg Ridgeway \email{gridge@@upenn.edu} with contributions by
#' Daniel Edwards, Brian Kriegler, Stefan Schroedl, Harry Southworth,
Expand All @@ -51,7 +48,9 @@
#' J.H. Friedman (2002). \dQuote{Stochastic Gradient Boosting,}
#' \emph{Computational Statistics and Data Analysis} 38(4):367-378.
#'
#' The \url{https://jerryfriedman.su.domains/R-MART.html} website.
#' The \href{https://jerryfriedman.su.domains/R-MART.html}{MART} website.
#'
#' @keywords package
"_PACKAGE"

NULL
36 changes: 14 additions & 22 deletions R/gbm.fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ gbm.fit <- function(x, y, offset = NULL, misc = NULL, distribution = "bernoulli"
cRows <- nrow(x)
cCols <- ncol(x)

if(nrow(x) != ifelse("Surv" %in% class(y), nrow(y), length(y))) {
if(nrow(x) != ifelse(inherits(y, "Surv"), nrow(y), length(y))) {
stop("The number of rows in x does not equal the length of y.")
}

Expand Down Expand Up @@ -247,7 +247,7 @@ gbm.fit <- function(x, y, offset = NULL, misc = NULL, distribution = "bernoulli"
# Check size of data
if(nTrain * bag.fraction <= 2 * n.minobsinnode + 1) {
stop("The data set is too small or the subsampling rate is too large: ",
"`nTrain * bag.fraction <= n.minobsinnode`")
"`nTrain * bag.fraction <= 2 * n.minobsinnode + 1`")
}

if (distribution$name != "pairwise") {
Expand Down Expand Up @@ -314,31 +314,23 @@ gbm.fit <- function(x, y, offset = NULL, misc = NULL, distribution = "bernoulli"
if(!is.element(distribution$name, supported.distributions)) {
stop("Distribution ",distribution$name," is not supported")
}
if((distribution$name == "bernoulli") && !all(is.element(y, 0:1)) &&
!is.numeric(y)) {
# NOTE: Including `!is.numeric(y)` will catch cases where y is a 0/1 factor
stop("Bernoulli requires the response to be in {0,1}")
if (is.factor(y)) {
y <- as.integer(y) - 1
}
if((distribution$name == "bernoulli") &&
(!is.numeric(y) || !all(is.element(y, 0:1)))) {
stop("Bernoulli requires the response to be numeric in {0,1}")
}
if((distribution$name == "huberized") && !all(is.element(y,0:1))) {
stop("Huberized square hinged loss requires the response to be in {0,1}")
if (is.factor(y)) {
y <- as.integer(y) - 1
}
if((distribution$name == "huberized") &&
(!is.numeric(y) || !all(is.element(y, 0:1)))) {
stop("Huberized square hinged loss requires the response to be numeric in {0,1}")
}
if((distribution$name == "poisson") && any(y<0)) {
stop("Poisson requires the response to be positive")
stop("Poisson requires the response to be non-negative")
}
if((distribution$name == "poisson") && any(y != trunc(y))) {
stop("Poisson requires the response to be a positive integer")
stop("Poisson requires the response to be non-negative")
}
if((distribution$name == "adaboost") && !all(is.element(y,0:1))) {
stop("This version of AdaBoost requires the response to be in {0,1}")
if (is.factor(y)) {
y <- as.integer(y) - 1
}
if((distribution$name == "adaboost") &&
(!is.numeric(y) || !all(is.element(y, 0:1)))) {
stop("This version of AdaBoost requires the response to be numeric in {0,1}")
}
if(distribution$name == "quantile") {
if(length(unique(w)) > 1) {
Expand All @@ -354,7 +346,7 @@ gbm.fit <- function(x, y, offset = NULL, misc = NULL, distribution = "bernoulli"
Misc <- c(alpha=distribution$alpha)
}
if(distribution$name == "coxph") {
if(!("Surv" %in% class(y))) {
if(!inherits(y, "Surv")) {
stop("Outcome must be a survival object Surv(time,failure)")
}
if(attr(y,"type")!="right") {
Expand Down
4 changes: 2 additions & 2 deletions R/gbmCrossVal.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ gbmCrossValPredictions <- function(cv.models, cv.folds, cv.group,

# The %in% here is to handle coxph
# my.data <- data[flag, !(data.names %in% model$response.name)]
my.data <- data[flag, model$var.names]
my.data <- data[flag, model$var.names, drop=FALSE]
predictions <- predict(model, newdata = my.data, n.trees = best.iter.cv) # FIXME
predictions <- matrix(predictions, ncol = num.cols)
res[flag, ] <- predictions
Expand Down Expand Up @@ -204,7 +204,7 @@ gbmDoFold <- function(X, i.train, x, y, offset, distribution, w, var.monotone,
# Setup
set.seed(s[[X]])
i <- order(cv.group == X)
x <- x[i.train, , drop = TRUE][i, , drop = FALSE]
x <- x[i.train, , drop = FALSE][i, , drop = FALSE]
y <- y[i.train][i]
offset <- offset[i.train][i]
nTrain <- length(which(cv.group != X))
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ best_iter_test <- function(object) {
best_iter_cv <- function(object) {
check_if_gbm_fit(object)
if(!has_cross_validation(object)) {
stop('In order to use method="cv" gbm must be called with cv_folds>1.')
stop('In order to use method="cv" gbm must be called with cv.folds>1.')
}
best_iter_cv <- which.min(object$cv.error)
return(best_iter_cv)
Expand Down
Binary file modified build/vignette.rds
Binary file not shown.
Binary file modified inst/doc/gbm.pdf
Binary file not shown.
10 changes: 9 additions & 1 deletion man/gbm-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/adaboost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ GBMRESULT CAdaBoost::ComputeWorkingResponse
double *adWeight,
bool *afInBag,
unsigned long nTrain,
int cIdxOff
int cIdxOff
)
{
unsigned long i = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/adaboost.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ class CAdaBoost : public CDistribution
unsigned long nTrain);

private:
vector<double> vecdNum;
vector<double> vecdDen;
std::vector<double> vecdNum;
std::vector<double> vecdDen;
};

#endif // ADABOOST_H
Expand Down
2 changes: 1 addition & 1 deletion src/bernoulli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ GBMRESULT CBernoulli::InitF
double dDen=0.0; // denominator
double dNewtonStep=1.0; // change
dInitF = 0.0;
while(dNewtonStep > 0.0001)
while(std::abs(dNewtonStep) > 0.0001)
{
dNum=0.0;
dDen=0.0;
Expand Down
4 changes: 2 additions & 2 deletions src/bernoulli.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ class CBernoulli : public CDistribution
unsigned long nTrain);

private:
vector<double> vecdNum;
vector<double> vecdDen;
std::vector<double> vecdNum;
std::vector<double> vecdDen;
};

#endif // BERNOULLI_H
Expand Down
1 change: 1 addition & 0 deletions src/buildinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define BUILDINFO_H

#undef ERROR
#define R_NO_REMAP // https://rstudio.github.io/r-manuals/r-exts/The-R-API.html
#include <R.h>

#define GBM_FAILED(hr) ((unsigned long)hr != 0)
Expand Down
Loading

0 comments on commit 27ed18f

Please sign in to comment.