We currently get only 1 leaf in leafFor, but it is possible we may want to allow paths to diverge during tree evaluation (eg feature is missing). To do this, we should add a new sumLeaves method which allows us traverse down multiple paths and aggregate the results using the prior probabilities of each diverging path.
During tree traversal, we'd always follow edges whose predicates return true. We would also allow nodes to have multiple true predicates. For each true edge, we'd determine their prior probabilities relative to all true edges and use it to scale the result returned for each edge, then sum the result. The method may look something like:
We currently get only 1 leaf in
leafFor
, but it is possible we may want to allow paths to diverge during tree evaluation (eg feature is missing). To do this, we should add a newsumLeaves
method which allows us traverse down multiple paths and aggregate the results using the prior probabilities of each diverging path.During tree traversal, we'd always follow edges whose predicates return
true
. We would also allow nodes to have multipletrue
predicates. For each true edge, we'd determine their prior probabilities relative to all true edges and use it to scale the result returned for each edge, then sum the result. The method may look something like: