extract.coef.xgb.Booster: extract.coef.xgb.Booster

Description Usage Arguments Details Value Author(s) Examples

View source: R/extractCoef.r

Description

Extract Coefficient Information from Models

Usage

1
2
3
4
5
6
7
8
## S3 method for class 'xgb.Booster'
extract.coef(
  model,
  feature_names = NULL,
  removeNonSelected = TRUE,
  zero_threshold = 0.001,
  ...
)

Arguments

model

Model object from which to extract information.

feature_names

Names of coefficients

removeNonSelected

If TRUE (default) do not return the non-selected (0) coefficients

zero_threshold

Since coefficients from xgboost are not exactly zero, this is the threshold under which a coefficient is considered zero

...

Further arguments

Details

Gets the coefficient values and variable names from a model. Since xgboost does not have standard errors, those will just be NA.

Value

A data.frame containing the coefficient, the standard error and the variable name.

Author(s)

Jared P. Lander

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(xgboost)
data(diamonds, package='ggplot2')
diaX <- useful::build.x(price ~ carat + cut + x, data=diamonds, contrasts=FALSE)
diaY <- useful::build.y(price ~ carat + cut + x, data=diamonds)
xg1 <- xgb.train(data=xgb.DMatrix(data=diaX, label=diaY), 
booster='gblinear',
objective='reg:squarederror', eval_metric='rmse',
nrounds=50
)
extract.coef(xg1)
extract.coef(xg1, zero_threshold=0)
extract.coef(xg1, feature_names=colnames(diaX))

coefplot documentation built on Jan. 16, 2021, 5:09 p.m.