classification/tree_explainer.py
def _convert_to_decisions(self, node_ids: List[int], leaf: int, sample: DataFrame = None) \
            -> List[Decision]:
        """
        Convert the list of nodes to a list of decisions.
        :param node_ids: id's of the nodes in the tree. Are sorted leaf to root
        :param leaf: the id of the leaf to which this path leads
        :param sample: sample to take a value from. Can be left out for foils
        """
        tree = self.model.tree_
        decisions = list()

        for i, node_id in reversed(list(enumerate(node_ids))):
            child = node_ids[i-1] if i > 0 else leaf
            sign = Sign.seq if child == tree.children_left[node_id] else Sign.larger
            feature = self.feature_names[tree.feature[node_id]]
            value = sample.iloc[0][feature] if sample is not None else None
            decision = Decision(feature, tree.feature[node_id], sign,
                                tree.threshold[node_id], sample is not None, value)
            decisions.append(decision)

        return decisions

        Convert the list of nodes to a list of decisions.
        :param node_ids: id's of the nodes in the tree. Are sorted leaf to root
        :param leaf: the id of the leaf to which this path leads
        :param sample: sample to take a value from. Can be left out for foils
        
Convert the list of nodes to a list of decisions.
Convert the list of nodes to a list of decisions .
def _convert_to_decisions(self, node_ids: List[int], leaf: int, sample: DataFrame = None) \
            -> List[Decision]:
        tree = self.model.tree_
        decisions = list()
        for i, node_id in reversed(list(enumerate(node_ids))):
            child = node_ids[i-1] if i > 0 else leaf
            sign = Sign.seq if child == tree.children_left[node_id] else Sign.larger
            feature = self.feature_names[tree.feature[node_id]]
            value = sample.iloc[0][feature] if sample is not None else None
            decision = Decision(feature, tree.feature[node_id], sign,
                                tree.threshold[node_id], sample is not None, value)
            decisions.append(decision)
        return decisions
def _convert_to_decisions ( self , node_ids : List [ int ] , leaf : int , sample : DataFrame = None ) -> List [ Decision ] : tree = self . model . tree_ decisions = list ( ) for i , node_id in reversed ( list ( enumerate ( node_ids ) ) ) : child = node_ids [ i - 1 ] if i > 0 else leaf sign = Sign . seq if child == tree . children_left [ node_id ] else Sign . larger feature = self . feature_names [ tree . feature [ node_id ] ] value = sample . iloc [ 0 ] [ feature ] if sample is not None else None decision = Decision ( feature , tree . feature [ node_id ] , sign , tree . threshold [ node_id ] , sample is not None , value ) decisions . append ( decision ) return decisions
Convert the list of nodes to a list of decisions.
Convert the list of nodes to a list of decisions .
"""
        Convert the list of nodes to a list of decisions.
        :param node_ids: id's of the nodes in the tree. Are sorted leaf to root
        :param leaf: the id of the leaf to which this path leads
        :param sample: sample to take a value from. Can be left out for foils
        """
self
node_ids
List[int]
id's of the nodes in the tree. Are sorted leaf to root
id ' s of the nodes in the tree . Are sorted leaf to root
leaf
int
the id of the leaf to which this path leads
the id of the leaf to which this path leads
sample
DataFrame
sample to take a value from. Can be left out for foils
sample to take a value from . Can be left out for foils