stackboost/core.py
def predict_value(self, X: np.ndarray, tree: DecisionNode = None) -> np.ndarray:
        """ Do a recursive search down the tree and make a prediction of the data sample by the
            value of the leaf that we end up at """

        if tree is None:
            tree = self.root

        # If we have a value (i.e we're at a leaf) => return value as the prediction
        if tree.is_leaf():
            return tree.value

        # Choose the feature that we will test
        feature_value = X[tree.feature_i]
        # Determine if we will follow left or right branch
        branch = tree.false_branch
        if isinstance(feature_value, int) or isinstance(feature_value, float):
            if feature_value >= tree.threshold:
                branch = tree.true_branch
        elif feature_value == tree.threshold:
            branch = tree.true_branch

        # Test subtree
        return self.predict_value(X, branch)
 Do a recursive search down the tree and make a prediction of the data sample by the
            value of the leaf that we end up at 
Do a recursive search down the tree and make a prediction of the data sample by the
value of the leaf that we end up at
Do a recursive search down the tree and make a prediction of the data sample by the value of the leaf that we end up at
def predict_value(self, X: np.ndarray, tree: DecisionNode = None) -> np.ndarray:
        if tree is None:
            tree = self.root
        if tree.is_leaf():
            return tree.value
        feature_value = X[tree.feature_i]
        branch = tree.false_branch
        if isinstance(feature_value, int) or isinstance(feature_value, float):
            if feature_value >= tree.threshold:
                branch = tree.true_branch
        elif feature_value == tree.threshold:
            branch = tree.true_branch
        return self.predict_value(X, branch)
def predict_value ( self , X : np . ndarray , tree : DecisionNode = None ) -> np . ndarray : if tree is None : tree = self . root if tree . is_leaf ( ) : return tree . value feature_value = X [ tree . feature_i ] branch = tree . false_branch if isinstance ( feature_value , int ) or isinstance ( feature_value , float ) : if feature_value >= tree . threshold : branch = tree . true_branch elif feature_value == tree . threshold : branch = tree . true_branch return self . predict_value ( X , branch )
Do a recursive search down the tree and make a prediction of the data sample by the
value of the leaf that we end up at
Do a recursive search down the tree and make a prediction of the data sample by the value of the leaf that we end up at
""" Do a recursive search down the tree and make a prediction of the data sample by the
            value of the leaf that we end up at """ # If we have a value (i.e we're at a leaf) => return value as the prediction # Choose the feature that we will test # Determine if we will follow left or right branch # Test subtree
self
X
np.ndarray
tree
DecisionNode