growingspheres/growingspheres.py
def feature_selection_all(self, counterfactual):
        """
        Try all possible combinations of projections to make the explanation as sparse as possible. 
        Warning: really long!
        """
        if self.verbose == True:
            print("Grid search for projections...")
        for k in range(self.obs_to_interprete.size):
            print('==========', k, '==========')
            for combo in combinations(range(self.obs_to_interprete.size), k):
                out = counterfactual.copy()
                new_enn = out.copy()
                for v in combo:
                    new_enn[v] = self.obs_to_interprete[v]
                if self.prediction_fn(new_enn.reshape(1, -1)) == self.target_class:
                    print('bim')
                    out = new_enn.copy()
                    reduced = k
        if self.verbose == True:
            print("Reduced %d coordinates"%reduced)
        return out

        Try all possible combinations of projections to make the explanation as sparse as possible. 
        Warning: really long!
        
Try all possible combinations of projections to make the explanation as sparse as possible.
Warning: really long!
Try all possible combinations of projections to make the explanation as sparse as possible . Warning : really long!
def feature_selection_all(self, counterfactual):
        if self.verbose == True:
            print("Grid search for projections...")
        for k in range(self.obs_to_interprete.size):
            print('==========', k, '==========')
            for combo in combinations(range(self.obs_to_interprete.size), k):
                out = counterfactual.copy()
                new_enn = out.copy()
                for v in combo:
                    new_enn[v] = self.obs_to_interprete[v]
                if self.prediction_fn(new_enn.reshape(1, -1)) == self.target_class:
                    print('bim')
                    out = new_enn.copy()
                    reduced = k
        if self.verbose == True:
            print("Reduced %d coordinates"%reduced)
        return out
def feature_selection_all ( self , counterfactual ) : if self . verbose == True : print ( "Grid search for projections..." ) for k in range ( self . obs_to_interprete . size ) : print ( '==========' , k , '==========' ) for combo in combinations ( range ( self . obs_to_interprete . size ) , k ) : out = counterfactual . copy ( ) new_enn = out . copy ( ) for v in combo : new_enn [ v ] = self . obs_to_interprete [ v ] if self . prediction_fn ( new_enn . reshape ( 1 , - 1 ) ) == self . target_class : print ( 'bim' ) out = new_enn . copy ( ) reduced = k if self . verbose == True : print ( "Reduced %d coordinates" % reduced ) return out
Try all possible combinations of projections to make the explanation as sparse as possible.
Try all possible combinations of projections to make the explanation as sparse as possible .
"""
        Try all possible combinations of projections to make the explanation as sparse as possible. 
        Warning: really long!
        """
self
counterfactual