Skip to content

Commit

Permalink
Merge pull request #569 from ilia-kats/xgb_varimp
Browse files Browse the repository at this point in the history
return full list of variables in xgb*$varImp
  • Loading branch information
topepo committed Jan 9, 2017
2 parents bf5d8c8 + 91d7a83 commit 854d128
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions models/files/xgbLinear.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ modelInfo <- list(label = "eXtreme Gradient Boosting",
rownames(imp) <- as.character(imp[,1])
imp <- imp[,2,drop = FALSE]
colnames(imp) <- "Overall"

missing <- object$xNames[!(object$xNames %in% rownames(imp))]
missing_imp <- data.frame(Overall=rep(0, times=length(missing)))
rownames(missing_imp) <- missing
imp <- rbind(imp, missing_imp)

imp
},
levels = function(x) x$obsLevels,
Expand Down
6 changes: 6 additions & 0 deletions models/files/xgbTree.R
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ modelInfo <- list(label = "eXtreme Gradient Boosting",
rownames(imp) <- as.character(imp[,1])
imp <- imp[,2,drop = FALSE]
colnames(imp) <- "Overall"

missing <- object$xNames[!(object$xNames %in% rownames(imp))]
missing_imp <- data.frame(Overall=rep(0, times=length(missing)))
rownames(missing_imp) <- missing
imp <- rbind(imp, missing_imp)

imp
},
levels = function(x) x$obsLevels,
Expand Down

0 comments on commit 854d128

Please sign in to comment.