avoid error when a tree is just made of one leaf
This commit is contained in:
parent
31a3b38ef8
commit
d441a9d382
@ -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)]
|
tree <- text[(position[i]+1):(position[i+1]-1)]
|
||||||
|
|
||||||
|
# avoid tree made of a leaf only (no split)
|
||||||
|
if(length(tree) <2) break
|
||||||
|
|
||||||
treeID <- i-1
|
treeID <- i-1
|
||||||
|
|
||||||
notLeaf <- str_match(tree, "leaf") %>% is.na
|
notLeaf <- str_match(tree, "leaf") %>% is.na
|
||||||
@ -129,7 +132,7 @@ xgb.model.dt.tree <- function(feature_names = NULL, filename_dump = NULL, model
|
|||||||
}
|
}
|
||||||
|
|
||||||
yes <- allTrees[!is.na(Yes),Yes]
|
yes <- allTrees[!is.na(Yes),Yes]
|
||||||
|
|
||||||
set(allTrees, i = which(allTrees[,Feature]!= "Leaf"),
|
set(allTrees, i = which(allTrees[,Feature]!= "Leaf"),
|
||||||
j = "Yes.Feature",
|
j = "Yes.Feature",
|
||||||
value = allTrees[ID == yes,Feature])
|
value = allTrees[ID == yes,Feature])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user