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.
This commit is contained in:
parent
70be1e38c2
commit
1ca5698221
@ -38,6 +38,7 @@ create.new.tree.features <- function(model, original.features){
|
|||||||
# Convert previous features to one hot encoding
|
# Convert previous features to one hot encoding
|
||||||
new.features.train <- create.new.tree.features(bst, agaricus.train$data)
|
new.features.train <- create.new.tree.features(bst, agaricus.train$data)
|
||||||
new.features.test <- create.new.tree.features(bst, agaricus.test$data)
|
new.features.test <- create.new.tree.features(bst, agaricus.test$data)
|
||||||
|
colnames(new.features.test) <- colnames(new.features.train)
|
||||||
|
|
||||||
# learning with new features
|
# learning with new features
|
||||||
new.dtrain <- xgb.DMatrix(data = new.features.train, label = agaricus.train$label)
|
new.dtrain <- xgb.DMatrix(data = new.features.train, label = agaricus.train$label)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user