| xgb.slice.Booster | R Documentation |
Creates a new booster including only a selected range of rounds / iterations
from an existing booster, as given by the sequence seq(start, end, step).
xgb.slice.Booster(
model,
start,
end = xgb.get.num.boosted.rounds(model),
step = 1L
)
## S3 method for class 'xgb.Booster'
x[i]
model, x |
A fitted |
start |
Start of the slice (base-1 and inclusive, like R's |
end |
End of the slice (base-1 and inclusive, like R's |
step |
Step size of the slice. Passing '1' will take every round in the sequence defined by
|
i |
The indices - must be an increasing sequence as generated by e.g. |
Note that any R attributes that the booster might have, will not be copied into the resulting object.
A sliced booster object containing only the requested rounds.
data(mtcars)
y <- mtcars$mpg
x <- as.matrix(mtcars[, -1])
dm <- xgb.DMatrix(x, label = y, nthread = 1)
model <- xgb.train(data = dm, params = xgb.params(nthread = 1), nrounds = 5)
model_slice <- xgb.slice.Booster(model, 1, 3)
# Prediction for first three rounds
predict(model, x, predleaf = TRUE)[, 1:3]
# The new model has only those rounds, so
# a full prediction from it is equivalent
predict(model_slice, x, predleaf = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.