From b29b7d1d76897ebad24837750715880457c7382a Mon Sep 17 00:00:00 2001 From: davidt0x Date: Tue, 30 May 2017 11:50:33 -0400 Subject: [PATCH] Fixed loop bound in create.new.tree.features (#2328) for loop in create.new.tree.features was referencing length(trees) as the upper bound of the loop. trees is a base R dataset and not the model that the code is generating. Changed loop boundary to model$niter which should be the number of trees. --- R-package/demo/predict_leaf_indices.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R-package/demo/predict_leaf_indices.R b/R-package/demo/predict_leaf_indices.R index 9aaa1a9ab..1bf8eabd1 100644 --- a/R-package/demo/predict_leaf_indices.R +++ b/R-package/demo/predict_leaf_indices.R @@ -27,7 +27,7 @@ head(pred_with_leaf) create.new.tree.features <- function(model, original.features){ pred_with_leaf <- predict(model, original.features, predleaf = TRUE) cols <- list() - for(i in 1:length(trees)){ + for(i in 1:model$niter){ # max is not the real max but it s not important for the purpose of adding features leaf.id <- sort(unique(pred_with_leaf[,i])) cols[[i]] <- factor(x = pred_with_leaf[,i], level = leaf.id)