-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
I attach a dbarts object and test data matrix to this message.
dbarts_debug_example.zip
The predicted value from dbarts is ``-0.977252'', which is less than the sum of the minimum terminal node values obtained from each tree.
load(file = "......./debugsampler.RData" )
load(file = "....../debugtempbind.RData" )
n.trees <- sampler$control@n.trees
tempsum <- 0
for(i in 1:n.trees){
treeexample1 <- sampler$getTrees(treeNums = i,
chainNums = 1,
sampleNums = 1)
tempsum <- tempsum + min(treeexample1[treeexample1$var== -1, ]$value)
}
tempsum
I think the prediction should be 0.1020762
getPredictionsForTree <- function(tree, x) {
predictions <- rep(NA_real_, nrow(x))
getPredictionsForTreeRecursive <- function(tree, indices) {
if (tree$var[1] == -1) {
# Assigns in the calling environment by using <<-
predictions[indices] <<- tree$value[1]
return(1)
}
goesLeft <- x[indices, tree$var[1]] <= tree$value[1]
headOfLeftBranch <- tree[-1,]
n_nodes.left <- getPredictionsForTreeRecursive(
headOfLeftBranch, indices[goesLeft])
headOfRightBranch <- tree[seq.int(2 + n_nodes.left, nrow(tree)),]
n_nodes.right <- getPredictionsForTreeRecursive(
headOfRightBranch, indices[!goesLeft])
return(1 + n_nodes.left + n_nodes.right)
}
getPredictionsForTreeRecursive(tree, seq_len(nrow(x)))
return(predictions)
}
getPredictionsForTree(treeexample1,as.matrix(rep(tempbind[1,1],100),100,1) )
n.trees <- sampler$control@n.trees
tempsum <- 0
for(i in 1:n.trees){
treeexample1 <- sampler$getTrees(treeNums = i,
chainNums = 1,
sampleNums = 1)
tempsum <- tempsum + getPredictionsForTree(treeexample1,as.matrix(rep(tempbind[1,1],100),100,1) )
}
tempsum
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels