| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/callbacks.R |
| 3 |
\name{xgb.gblinear.history} |
| 4 |
\alias{xgb.gblinear.history} |
| 5 |
\title{Extract gblinear coefficients history} |
| 6 |
\usage{ |
| 7 |
xgb.gblinear.history(model, class_index = NULL) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{model}{Either an \code{xgb.Booster} or a result of \code{\link[=xgb.cv]{xgb.cv()}}, trained |
| 11 |
using the \link{xgb.cb.gblinear.history} callback, but \strong{not} a booster |
| 12 |
loaded from \code{\link[=xgb.load]{xgb.load()}} or \code{\link[=xgb.load.raw]{xgb.load.raw()}}.} |
| 13 |
|
| 14 |
\item{class_index}{zero-based class index to extract the coefficients for only that |
| 15 |
specific class in a multinomial multiclass model. When it is \code{NULL}, all the |
| 16 |
coefficients are returned. Has no effect in non-multiclass models.} |
| 17 |
} |
| 18 |
\value{ |
| 19 |
For an \code{\link[=xgb.train]{xgb.train()}} result, a matrix (either dense or sparse) with the columns |
| 20 |
corresponding to iteration's coefficients and the rows corresponding to boosting iterations. |
| 21 |
|
| 22 |
For an \code{\link[=xgb.cv]{xgb.cv()}} result, a list of such matrices is returned with the elements |
| 23 |
corresponding to CV folds. |
| 24 |
|
| 25 |
When there is more than one coefficient per feature (e.g. multi-class classification) |
| 26 |
and \code{class_index} is not provided, |
| 27 |
the result will be reshaped into a vector where coefficients are arranged first by features and |
| 28 |
then by class (e.g. first 1 through N coefficients will be for the first class, then |
| 29 |
coefficients N+1 through 2N for the second class, and so on). |
| 30 |
} |
| 31 |
\description{ |
| 32 |
A helper function to extract the matrix of linear coefficients' history |
| 33 |
from a gblinear model created while using the \link{xgb.cb.gblinear.history} |
| 34 |
callback (which must be added manually as by default it is not used). |
| 35 |
} |
| 36 |
\details{ |
| 37 |
Note that this is an R-specific function that relies on R attributes that |
| 38 |
are not saved when using XGBoost's own serialization functions like \code{\link[=xgb.load]{xgb.load()}} |
| 39 |
or \code{\link[=xgb.load.raw]{xgb.load.raw()}}. |
| 40 |
|
| 41 |
In order for a serialized model to be accepted by this function, one must use R |
| 42 |
serializers such as \code{\link[=saveRDS]{saveRDS()}}. |
| 43 |
} |
| 44 |
\seealso{ |
| 45 |
\link{xgb.cb.gblinear.history}, \link{coef.xgb.Booster}. |
| 46 |
} |