classification/tree_explainer.py
def _aggregate_features(self, node_ids: List[int], leaf: int, sample: DataFrame = None) \
            -> List[Decision]:
        """
        Gets a list of node ids and sorts them according to the feature on which they split.
        Then filter out nodes that test the same value with the same sign (< or >), and keep
        the most specific one. If the same feature is tested with both > and <, a 'between' node
        is created.
        :return: all decisions, not sorted
        """
        features_sample = defaultdict(list)
        decisions = self._convert_to_decisions(node_ids, leaf, sample)
        for decision in decisions:
            features_sample[decision.feature_id].append(decision)

        for nodes in features_sample.values():
            while len(nodes) > 1:
                combs = itertools.product(nodes, repeat=2)
                for x, y in combs:
                    if x == y:
                        continue
                    new_node = x.aggregate(y)
                    if new_node is not None:
                        nodes.remove(x)
                        nodes.remove(y)
                        nodes.append(new_node)
                        break
                else:
                    break

        list_decisions = []
        for nodes in features_sample.values():
            list_decisions.extend(nodes)

        return list_decisions

        Gets a list of node ids and sorts them according to the feature on which they split.
        Then filter out nodes that test the same value with the same sign (< or >), and keep
        the most specific one. If the same feature is tested with both > and <, a 'between' node
        is created.
        :return: all decisions, not sorted
        
Gets a list of node ids and sorts them according to the feature on which they split.
Then filter out nodes that test the same value with the same sign (< or >), and keep
the most specific one. If the same feature is tested with both > and <, a 'between' node
is created.
Gets a list of node ids and sorts them according to the feature on which they split . Then filter out nodes that test the same value with the same sign ( < or > ) and keep the most specific one . If the same feature is tested with both > and < a ' between ' node is created .
def _aggregate_features(self, node_ids: List[int], leaf: int, sample: DataFrame = None) \
            -> List[Decision]:
        features_sample = defaultdict(list)
        decisions = self._convert_to_decisions(node_ids, leaf, sample)
        for decision in decisions:
            features_sample[decision.feature_id].append(decision)
        for nodes in features_sample.values():
            while len(nodes) > 1:
                combs = itertools.product(nodes, repeat=2)
                for x, y in combs:
                    if x == y:
                        continue
                    new_node = x.aggregate(y)
                    if new_node is not None:
                        nodes.remove(x)
                        nodes.remove(y)
                        nodes.append(new_node)
                        break
                else:
                    break
        list_decisions = []
        for nodes in features_sample.values():
            list_decisions.extend(nodes)
        return list_decisions
def _aggregate_features ( self , node_ids : List [ int ] , leaf : int , sample : DataFrame = None ) -> List [ Decision ] : features_sample = defaultdict ( list ) decisions = self . _convert_to_decisions ( node_ids , leaf , sample ) for decision in decisions : features_sample [ decision . feature_id ] . append ( decision ) for nodes in features_sample . values ( ) : while len ( nodes ) > 1 : combs = itertools . product ( nodes , repeat = 2 ) for x , y in combs : if x == y : continue new_node = x . aggregate ( y ) if new_node is not None : nodes . remove ( x ) nodes . remove ( y ) nodes . append ( new_node ) break else : break list_decisions = [ ] for nodes in features_sample . values ( ) : list_decisions . extend ( nodes ) return list_decisions
Gets a list of node ids and sorts them according to the feature on which they split.
Gets a list of node ids and sorts them according to the feature on which they split .
"""
        Gets a list of node ids and sorts them according to the feature on which they split.
        Then filter out nodes that test the same value with the same sign (< or >), and keep
        the most specific one. If the same feature is tested with both > and <, a 'between' node
        is created.
        :return: all decisions, not sorted
        """
all decisions, not sorted
all decisions not sorted
self
node_ids
List[int]
leaf
int
sample
DataFrame