fastgbm is a compact gradient boosting engine with a
compiled (Rcpp + RcppParallel) backend, covering three task types with
one interface: regression (squared error), binary classification
(logistic), and right-censored survival analysis (Cox, AFT, or
piecewise-exponential objectives), with native missing-value routing
throughout. See vignette("regression"),
vignette("classification"), and
vignette("survival") for task-specific examples; this
vignette walks through the survival interface end to end since it has
the most moving parts (baseline hazard, survival-probability
prediction).
library(fastgbm)
library(survival)
lung_dat <- na.omit(lung[, c("time", "status", "age", "sex", "ph.ecog")])
x <- as.matrix(lung_dat[, c("age", "sex", "ph.ecog")])
fit <- fastgbm(
x,
time = lung_dat$time,
status = lung_dat$status,
objective = "cox",
ntrees = 100L,
learning_rate = 0.05,
max_depth = 3L,
seed = 1L,
verbose = FALSE
)
fit
#> fastgbm model
#> objective: cox
#> trees: 100
#> learning rate: 0.05
#> max depth: 3# Linear predictor (log relative risk)
lp <- predict(fit, x, type = "link")
head(lp)
#> [1] -0.1063293 0.2358925 -0.4168496 0.2601784 -0.3662904 -0.1063293
# Survival probabilities at specific horizons
predict(fit, x[1:5, ], type = "survival", times = c(90, 180, 365))
#> [,1] [,2] [,3]
#> [1,] 0.9231172 0.7981076 0.4904070
#> [2,] 0.8934682 0.7279397 0.3666750
#> [3,] 0.9430419 0.8476267 0.5931407
#> [4,] 0.8909975 0.7222795 0.3577420
#> [5,] 0.9401782 0.8403910 0.5772898