Generate new features based on tree leafs

This commit is contained in:
Michaël Benesty
2015-12-07 11:30:19 +01:00
parent 115c63bcde
commit c1b2d9cb86
6 changed files with 185 additions and 6 deletions

View File

@@ -25,7 +25,7 @@ pred_with_leaf = predict(bst, dtest, predleaf = TRUE)
head(pred_with_leaf)
create.new.tree.features <- function(model, original.features){
pred_with_leaf = predict(model, original.features, predleaf = TRUE)
pred_with_leaf <- predict(model, original.features, predleaf = TRUE)
cols <- list()
for(i in 1:length(trees)){
# max is not the real max but it s not important for the purpose of adding features
@@ -49,4 +49,4 @@ bst <- xgb.train(params = param, data = new.dtrain, nrounds = nround, nthread =
accuracy.after <- sum((predict(bst, new.dtest) >= 0.5) == agaricus.test$label) / length(agaricus.test$label)
# Here the accuracy was already good and is now perfect.
print(paste("The accuracy was", accuracy.before, "before adding leaf features and it is now", accuracy.after, "!"))
cat(paste("The accuracy was", accuracy.before, "before adding leaf features and it is now", accuracy.after, "!\n"))