Skip to content

Commit

Permalink
Merge pull request #142 from pommedeterresautee/master
Browse files Browse the repository at this point in the history
avoid warning message when a tree is just made of one leaf
  • Loading branch information
tqchen committed Jan 12, 2015
2 parents 9a2ad91 + 48c1911 commit 166e752
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion R-package/R/xgb.model.dt.tree.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ xgb.model.dt.tree <- function(feature_names = NULL, filename_dump = NULL, model

tree <- text[(position[i]+1):(position[i+1]-1)]

# avoid tree made of a leaf only (no split)
if(length(tree) <2) next

treeID <- i-1

notLeaf <- str_match(tree, "leaf") %>% is.na
Expand Down Expand Up @@ -129,7 +132,7 @@ xgb.model.dt.tree <- function(feature_names = NULL, filename_dump = NULL, model
}

yes <- allTrees[!is.na(Yes),Yes]

set(allTrees, i = which(allTrees[,Feature]!= "Leaf"),
j = "Yes.Feature",
value = allTrees[ID == yes,Feature])
Expand Down

0 comments on commit 166e752

Please sign in to comment.