growingspheres/growingspheres.py
def feature_selection(self, counterfactual):
        """
        Projection step of the GS algorithm. Make projections to make (e* - obs_to_interprete) sparse. 
        Heuristic: sort the coordinates of np.abs(e* - obs_to_interprete) in ascending order and project as long as it does not change the predicted class
        
        Inputs:
        counterfactual: e*
        """
        if self.verbose == True:
            print("Feature selection...")
        move_sorted = sorted(enumerate(abs(counterfactual - self.obs_to_interprete)), key=lambda x: x[1])
        move_sorted = [x[0] for x in move_sorted if x[1] > 0.0]
        out = counterfactual.copy()
        reduced = 0
        
        for k in move_sorted:
            new_enn = out.copy()
            new_enn[k] = self.obs_to_interprete[k]
            if self.prediction_fn(new_enn.reshape(1, -1)) == self.target_class:
                out[k] = new_enn[k]
                reduced += 1
        if self.verbose == True:
            print("Reduced %d coordinates"%reduced)
        return out

        Projection step of the GS algorithm. Make projections to make (e* - obs_to_interprete) sparse. 
        Heuristic: sort the coordinates of np.abs(e* - obs_to_interprete) in ascending order and project as long as it does not change the predicted class
        
        Inputs:
        counterfactual: e*
        
Projection step of the GS algorithm. Make projections to make (e* - obs_to_interprete) sparse.
Heuristic: sort the coordinates of np.abs(e* - obs_to_interprete) in ascending order and project as long as it does not change the predicted class

e
Projection step of the GS algorithm . Make projections to make ( e * - obs_to_interprete ) sparse . Heuristic : sort the coordinates of np . abs ( e * - obs_to_interprete ) in ascending order and project as long as it does not change the predicted class e
def feature_selection(self, counterfactual):
        if self.verbose == True:
            print("Feature selection...")
        move_sorted = sorted(enumerate(abs(counterfactual - self.obs_to_interprete)), key=lambda x: x[1])
        move_sorted = [x[0] for x in move_sorted if x[1] > 0.0]
        out = counterfactual.copy()
        reduced = 0
        for k in move_sorted:
            new_enn = out.copy()
            new_enn[k] = self.obs_to_interprete[k]
            if self.prediction_fn(new_enn.reshape(1, -1)) == self.target_class:
                out[k] = new_enn[k]
                reduced += 1
        if self.verbose == True:
            print("Reduced %d coordinates"%reduced)
        return out
def feature_selection ( self , counterfactual ) : if self . verbose == True : print ( "Feature selection..." ) move_sorted = sorted ( enumerate ( abs ( counterfactual - self . obs_to_interprete ) ) , key = lambda x : x [ 1 ] ) move_sorted = [ x [ 0 ] for x in move_sorted if x [ 1 ] > 0.0 ] out = counterfactual . copy ( ) reduced = 0 for k in move_sorted : new_enn = out . copy ( ) new_enn [ k ] = self . obs_to_interprete [ k ] if self . prediction_fn ( new_enn . reshape ( 1 , - 1 ) ) == self . target_class : out [ k ] = new_enn [ k ] reduced += 1 if self . verbose == True : print ( "Reduced %d coordinates" % reduced ) return out
Projection step of the GS algorithm.
Projection step of the GS algorithm .
"""
        Projection step of the GS algorithm. Make projections to make (e* - obs_to_interprete) sparse. 
        Heuristic: sort the coordinates of np.abs(e* - obs_to_interprete) in ascending order and project as long as it does not change the predicted class
        
        Inputs:
        counterfactual: e*
        """
self
counterfactual