-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Description
At step 2 of 2
Error in rbindlist(append(list(tree_breakdown), list(leaf_breakdown))) :
Item 2 has 4 columns, inconsistent with item 1 which has 2 columns. To fill missing columns use fill=TRUE.
Reproducible example:
library(xgboost)
library(mice)
set.seed(1)
df <- read.csv('https://raw.githubusercontent.com/jbrownlee/Datasets/master/pima-indians-diabetes.data.csv', header = F)
colnames(df) <- c('Pregnancies', 'Glucose', 'BloodPressure', 'SkinThickness',
'Insulin', 'BMI', 'DiabetesPedigreeFunction', 'Age', 'Outcome')
df[2:8] <- lapply(df[2:8], function(x) replace(x, x %in% 0, NA))
micedf <- mice::mice(df)
df <- mice::complete(micedf)
sample_size <- floor(0.75 * nrow(df))
train_index <- sample(seq_len(nrow(df)), size = sample_size)
train <- df[train_index,]
test <- df[-train_index,]
x <- train[, 1:8]
y <- train$Outcome
dtrain <- xgb.DMatrix(as.matrix(x), label = y)
xgbmodel <- xgboost(
data = dtrain,
nrounds = 42,
params = list(
objective = "binary:logistic",
eta = 0.40,
max_depth = 7,
gamma = 0.83,
colsample_bytree = 0.66,
min_child_weight = 9,
subsample = 0.44)
)
library(xgboostExplainer)
set.seed(1) # Reset random seed
xgb.preds <- predict(xgbmodel, dtrain)
explainer <- buildExplainer(xgbmodel, dtrain, type="binary",
base_score = 0.5, trees_idx = NULL)
Metadata
Metadata
Assignees
Labels
No labels