Improve feature importance on GLM model

This commit is contained in:
pommedeterresautee
2015-12-01 18:44:25 +01:00
parent 423764ca2e
commit b05d5d3f24
2 changed files with 13 additions and 2 deletions

View File

@@ -82,7 +82,9 @@ xgb.importance <- function(feature_names = NULL, model = NULL, data = NULL, labe
}
linearDump <- function(feature_names, text){
which(text == "weight:") %>% {a =. + 1; text[a:length(text)]} %>% as.numeric %>% data.table(Feature = feature_names, Weight = .)
weights <- which(text == "weight:") %>% {a =. + 1; text[a:length(text)]} %>% as.numeric
if(is.null(feature_names)) feature_names <- seq(to = length(weights))
data.table(Feature = feature_names, Weight = weights)
}
model.text.dump <- xgb.dump(model = model, with.stats = T)