Learn R Programming

coefplot (version 1.2.6)

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

Description

Extract Coefficient Information from Models

Usage

# S3 method for xgb.Booster
extract.coef(model, feature_names = NULL,
  removeNonSelected = TRUE, ...)

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

Further arguments

Value

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

Details

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

Examples

Run this code
# NOT RUN {
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 <- xgboost(data=diaX, label=diaY, 
booster='gblinear',
objective='reg:linear', eval_metric='rmse',
nrounds=50
)
extract.coef(xg1)
extract.coef(xg1, feature_names=colnames(diaX))

# }

Run the code above in your browser using DataLab