# NOT RUN {
library("EIX")
library("Matrix")
sm <- sparse.model.matrix(left ~ . - 1, data = HR_data)
library("xgboost")
param <- list(objective = "binary:logistic", max_depth = 2)
xgb_model <- xgboost(sm, params = param, label = HR_data[, left] == 1, nrounds = 25, verbose=0)
imp <- importance(xgb_model, sm, option = "both")
imp
plot(imp, top = 10)
imp <- importance(xgb_model, sm, option = "variables")
imp
plot(imp, top = nrow(imp))
imp <- importance(xgb_model, sm, option = "interactions")
imp
plot(imp, top = nrow(imp))
imp <- importance(xgb_model, sm, option = "variables")
imp
plot(imp, top = NULL, radar = FALSE, xmeasure = "sumCover", ymeasure = "sumGain")
# }
Run the code above in your browser using DataLab