From 1ca56982218620fdc2d03e63ef4a13093ebf4c3f Mon Sep 17 00:00:00 2001 From: Jiaxiang Li Date: Fri, 5 Apr 2019 06:59:27 +0800 Subject: [PATCH] Make the train and test input with same colnames. (#4329) Fix the bug report of https://github.com/dmlc/xgboost/issues/4328. I am the beginner of the Git so just try my best to follows the guide, https://xgboost.readthedocs.io/en/latest/contribute.html#r-package. I find there is no `dev` branch, so I pull this fix from my master branch to the original master branch. --- R-package/demo/predict_leaf_indices.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R-package/demo/predict_leaf_indices.R b/R-package/demo/predict_leaf_indices.R index 6032138c366d..054bde7efbf7 100644 --- a/R-package/demo/predict_leaf_indices.R +++ b/R-package/demo/predict_leaf_indices.R @@ -38,6 +38,7 @@ create.new.tree.features <- function(model, original.features){ # Convert previous features to one hot encoding new.features.train <- create.new.tree.features(bst, agaricus.train$data) new.features.test <- create.new.tree.features(bst, agaricus.test$data) +colnames(new.features.test) <- colnames(new.features.train) # learning with new features new.dtrain <- xgb.DMatrix(data = new.features.train, label = agaricus.train$label)