public double regress ( DataPoint dp ) { TreeNodeVisitor node = this ; while ( ! node . isLeaf ( ) ) { int path = node . getPath ( dp ) ; if ( path < 0 ) //missing value case { double sum = 0 ; double resultSum = 0 ; for ( int child = 0 ; child < childrenCount ( ) ; child ++ ) { if ( node . isPathDisabled ( child ) ) continue ; double child_result = node . getChild ( child ) . regress ( dp ) ; sum += node . getPathWeight ( child ) ; resultSum += node . getPathWeight ( child ) * child_result ; } if ( sum == 0 ) //all paths disabled? break ; //break out and do local classify if ( sum < 1.0 - 1e-5 ) //re-normalize our result resultSum /= ( sum + 1e-6 ) ; return resultSum ; } if ( node . isPathDisabled ( path ) ) //if missing value makes path < 0, return local regression dec break ; node = node . getChild ( path ) ; } return node . localRegress ( dp ) ; }
Performs regression on the given data point by following it down the tree until it finds the correct terminal node .