anchors/limes/lime_tabular.py
def explain_instance_training_dataset(self,
                         data_row,
                         predict_fn,
                         labels=(1,),
                         top_labels=None,
                         num_features=10,
                         num_samples=5000,
                         distance_metric='euclidean',
                         model_regressor=None,
                         instances_in_sphere=[],
                         ape=None,
                         user_simulated=False):
        """Generates explanations for a prediction.

        First, we learn locally weighted linear models on 
        the instances from "instances_in_sphere" to explain each of the classes
        in an interpretable way (see lime_base.py).

        Args:
            data_row: 1d numpy array, corresponding to a row
            predict_fn: prediction function. For classifiers, this should be a
                function that takes a numpy array and outputs prediction
                probabilities. For regressors, this takes a numpy array and
                returns the predictions. For ScikitClassifiers, this is
                `classifier.predict_proba()`. For ScikitRegressors, this
                is `regressor.predict()`. The prediction function needs to work
                on multiple feature vectors (the vectors randomly perturbed
                from the data_row).
            labels: iterable with labels to be explained.
            top_labels: if not None, ignore labels and produce explanations for
                the K labels with highest prediction probabilities, where K is
                this parameter.
            num_features: maximum number of features present in explanation
            num_samples: size of the neighborhood to learn the linear model
            distance_metric: the distance metric to use for weights.
            model_regressor: sklearn regressor to use in explanation. Defaults
                to Ridge regression in LimeBase. Must have model_regressor.coef_
                and 'sample_weight' as a parameter to model_regressor.fit()
            instances_in_sphere: Matrix of instances on which we train the 
                linear model. If None we use the training dataset

        Returns:
            An Explanation object (see explanation.py) with the corresponding
            explanations.
        """
        #data, inverse = self.__data_inverse(data_row, num_samples)
        if instances_in_sphere != []:
            data, inverse = instances_in_sphere, instances_in_sphere
        else:
            data, inverse = self.training_data, self.training_data
        
        np.insert(data, 0, data_row)
        np.insert(inverse, 0, data_row)

        scaled_data = (data - self.scaler.mean_) / self.scaler.scale_

        if ape is None:
            distances = sklearn.metrics.pairwise_distances(
                scaled_data,
                scaled_data[0].reshape(1, -1),
                metric=distance_metric
        ).ravel()
        else:
            distances = []
            for instance in instances_in_sphere:
                distances.append(dista(scaled_data[0], instance, ape))
            distances = np.array(distances)
            

        yss = predict_fn(inverse)

        # for classification, the model needs to provide a list of tuples - classes
        # along with prediction probabilities
        if self.mode == "classification":
            if len(yss.shape) == 1:
                """
                raise NotImplementedError("LIME does not currently support "
                                          "classifier models without probability "
                                          "scores. If this conflicts with your "
                                          "use case, please let us know: "
                                          "https://github.com/datascienceinc/lime/issues/16")
                """

            elif len(yss.shape) == 2:
                if self.class_names is None:
                    self.class_names = [str(x) for x in range(yss[0].shape[0])]
                else:
                    self.class_names = list(self.class_names)
                if not np.allclose(yss.sum(axis=1), 1.0):
                    warnings.warn("""
                    Prediction probabilties do not sum to 1, and
                    thus does not constitute a probability space.
                    Check that you classifier outputs probabilities
                    (Not log probabilities, or actual class predictions).
                    """)
            else:
                raise ValueError("Your model outputs "
                                 "arrays with {} dimensions".format(len(yss.shape)))

        # for regression, the output should be a one-dimensional array of predictions
        else:
            try:
                assert isinstance(yss, np.ndarray) and len(yss.shape) == 1
            except AssertionError:
                raise ValueError("Your model needs to output single-dimensional \
                    numpyarrays, not arrays of {} dimensions".format(yss.shape))

            predicted_value = yss[0]
            min_y = min(yss)
            max_y = max(yss)

            # add a dimension to be compatible with downstream machinery
            yss = yss[:, np.newaxis]

        feature_names = copy.deepcopy(self.feature_names)
        if feature_names is None:
            feature_names = [str(x) for x in range(data_row.shape[0])]

        values = self.convert_and_round(data_row)

        for i in self.categorical_features:
            if self.discretizer is not None and i in self.discretizer.lambdas:
                continue
            name = int(data_row[i])
            if i in self.categorical_names:
                try:
                    name = self.categorical_names[i][name]
                except IndexError:
                    print("error in dataset categorical names", self.categorical_names)
                    print(i)
                    print(name)
            feature_names[i] = '%s=%s' % (feature_names[i], name)
            values[i] = 'True'
        categorical_features = self.categorical_features

        discretized_feature_names = None
        if self.discretizer is not None:
            categorical_features = range(data.shape[1])
            discretized_instance = self.discretizer.discretize(data_row)
            discretized_feature_names = copy.deepcopy(feature_names)
            for f in self.discretizer.names:
                discretized_feature_names[f] = self.discretizer.names[f][int(
                        discretized_instance[f])]
        """
        print("domain mapper")
        print("feature names", feature_names)
        print("ape encoded features names", ape.encoded_features_names)
        print("values", values)
        print("scaled data", scaled_data[0])
        print("categorical features", categorical_features)
        print("discretized", discretized_feature_names)
        """
        if ape.categorical_features == []:
            domain_mapper = TableDomainMapper(feature_names,
                                          values,
                                          scaled_data[0],
                                          categorical_features=categorical_features,
                                          discretized_feature_names=discretized_feature_names)
        
        else:
            domain_feature_names = ape.encoded_features_names
            #print(ape.enc.transform(scaled_data[0][ape.categorical_features].reshape(1, -1)).toarray())
            #print(list(range(len(ape.continuous_features))))
            domain_values = np.append(ape.enc.transform(scaled_data[0][ape.categorical_features].reshape(1, -1)).toarray()[0], 
                                                np.ones(len(ape.continuous_features)), axis=0)
            #domain_categorical_features = ape.enc.transform(scaled_data[0][ape.categorical_features].reshape(1, -1)).toarray()[0]
            """
            print("domain_categorical_features", domain_categorical_features)
            print("domain values", domain_values)
            print("target instance", scaled_data[0][ape.categorical_features].reshape(1, -1))
            print("TEST", range(len(scaled_data[0]) - len(ape.continuous_features)))
            print("2ND", range(len(domain_values) - len(ape.continuous_features)))
            #print("2DN", discretized_feature_names[:,ape.continuous_features])"""
            domain_mapper = TableDomainMapper(domain_feature_names,
                                            domain_values,
                                            ape.enc.transform(scaled_data[0][ape.categorical_features].reshape(1, -1)).toarray(),
                                            categorical_features=range(len(scaled_data[0][ape.categorical_features].reshape(1, -1)) - len(ape.continuous_features)),
                                            discretized_feature_names=discretized_feature_names)
        ret_exp = explanation.Explanation(domain_mapper,
                                          mode=self.mode,
                                          class_names=self.class_names)
        ret_exp.scaled_data = scaled_data
        if self.mode == "classification":
            ret_exp.predict_proba = yss[0]
            if top_labels:
                labels = np.argsort(yss[0])[-top_labels:]
                ret_exp.top_labels = list(labels)
                ret_exp.top_labels.reverse()
        else:
            ret_exp.predicted_value = predicted_value
            ret_exp.min_value = min_y
            ret_exp.max_value = max_y
            labels = [0]

        for label in labels:
            (ret_exp.intercept[label],
             ret_exp.local_exp[label],
             ret_exp.score, ret_exp.local_pred, 
             #ret_exp.data_print, ret_exp.prediction_print) 
             ret_exp.easy_model, ret_exp.used_features)= self.base.explain_instance_with_data(
                    scaled_data,
                    yss,
                    distances,
                    label,
                    num_features,
                    model_regressor=model_regressor,
                    feature_selection=self.feature_selection,
                    ape=ape)

        if self.mode == "regression":
            ret_exp.intercept[1] = ret_exp.intercept[0]
            ret_exp.local_exp[1] = [x for x in ret_exp.local_exp[0]]
            ret_exp.local_exp[0] = [(i, -1 * j) for i, j in ret_exp.local_exp[1]]
        if user_simulated:
            return ret_exp, self.base.used_features
        return ret_exp
Generates explanations for a prediction.

        First, we learn locally weighted linear models on 
        the instances from "instances_in_sphere" to explain each of the classes
        in an interpretable way (see lime_base.py).

        Args:
            data_row: 1d numpy array, corresponding to a row
            predict_fn: prediction function. For classifiers, this should be a
                function that takes a numpy array and outputs prediction
                probabilities. For regressors, this takes a numpy array and
                returns the predictions. For ScikitClassifiers, this is
                `classifier.predict_proba()`. For ScikitRegressors, this
                is `regressor.predict()`. The prediction function needs to work
                on multiple feature vectors (the vectors randomly perturbed
                from the data_row).
            labels: iterable with labels to be explained.
            top_labels: if not None, ignore labels and produce explanations for
                the K labels with highest prediction probabilities, where K is
                this parameter.
            num_features: maximum number of features present in explanation
            num_samples: size of the neighborhood to learn the linear model
            distance_metric: the distance metric to use for weights.
            model_regressor: sklearn regressor to use in explanation. Defaults
                to Ridge regression in LimeBase. Must have model_regressor.coef_
                and 'sample_weight' as a parameter to model_regressor.fit()
            instances_in_sphere: Matrix of instances on which we train the 
                linear model. If None we use the training dataset

        Returns:
            An Explanation object (see explanation.py) with the corresponding
            explanations.
        
Generates explanations for a prediction.
First, we learn locally weighted linear models on
the instances from "instances_in_sphere" to explain each of the classes
in an interpretable way .
Generates explanations for a prediction . First we learn locally weighted linear models on the instances from " instances_in_sphere " to explain each of the classes in an interpretable way .
def explain_instance_training_dataset(self,
                         data_row,
                         predict_fn,
                         labels=(1,),
                         top_labels=None,
                         num_features=10,
                         num_samples=5000,
                         distance_metric='euclidean',
                         model_regressor=None,
                         instances_in_sphere=[],
                         ape=None,
                         user_simulated=False):
        if instances_in_sphere != []:
            data, inverse = instances_in_sphere, instances_in_sphere
        else:
            data, inverse = self.training_data, self.training_data
        np.insert(data, 0, data_row)
        np.insert(inverse, 0, data_row)
        scaled_data = (data - self.scaler.mean_) / self.scaler.scale_
        if ape is None:
            distances = sklearn.metrics.pairwise_distances(
                scaled_data,
                scaled_data[0].reshape(1, -1),
                metric=distance_metric
        ).ravel()
        else:
            distances = []
            for instance in instances_in_sphere:
                distances.append(dista(scaled_data[0], instance, ape))
            distances = np.array(distances)
        yss = predict_fn(inverse)
        if self.mode == "classification":
            if len(yss.shape) == 1:
            elif len(yss.shape) == 2:
                if self.class_names is None:
                    self.class_names = [str(x) for x in range(yss[0].shape[0])]
                else:
                    self.class_names = list(self.class_names)
                if not np.allclose(yss.sum(axis=1), 1.0):
                    warnings.warn("""
                    Prediction probabilties do not sum to 1, and
                    thus does not constitute a probability space.
                    Check that you classifier outputs probabilities
                    (Not log probabilities, or actual class predictions).
                    """)
            else:
                raise ValueError("Your model outputs "
                                 "arrays with {} dimensions".format(len(yss.shape)))
        else:
            try:
                assert isinstance(yss, np.ndarray) and len(yss.shape) == 1
            except AssertionError:
                raise ValueError("Your model needs to output single-dimensional \
                    numpyarrays, not arrays of {} dimensions".format(yss.shape))
            predicted_value = yss[0]
            min_y = min(yss)
            max_y = max(yss)
            yss = yss[:, np.newaxis]
        feature_names = copy.deepcopy(self.feature_names)
        if feature_names is None:
            feature_names = [str(x) for x in range(data_row.shape[0])]
        values = self.convert_and_round(data_row)
        for i in self.categorical_features:
            if self.discretizer is not None and i in self.discretizer.lambdas:
                continue
            name = int(data_row[i])
            if i in self.categorical_names:
                try:
                    name = self.categorical_names[i][name]
                except IndexError:
                    print("error in dataset categorical names", self.categorical_names)
                    print(i)
                    print(name)
            feature_names[i] = '%s=%s' % (feature_names[i], name)
            values[i] = 'True'
        categorical_features = self.categorical_features
        discretized_feature_names = None
        if self.discretizer is not None:
            categorical_features = range(data.shape[1])
            discretized_instance = self.discretizer.discretize(data_row)
            discretized_feature_names = copy.deepcopy(feature_names)
            for f in self.discretizer.names:
                discretized_feature_names[f] = self.discretizer.names[f][int(
                        discretized_instance[f])]
        if ape.categorical_features == []:
            domain_mapper = TableDomainMapper(feature_names,
                                          values,
                                          scaled_data[0],
                                          categorical_features=categorical_features,
                                          discretized_feature_names=discretized_feature_names)
        else:
            domain_feature_names = ape.encoded_features_names
            domain_values = np.append(ape.enc.transform(scaled_data[0][ape.categorical_features].reshape(1, -1)).toarray()[0], 
                                                np.ones(len(ape.continuous_features)), axis=0)
            domain_mapper = TableDomainMapper(domain_feature_names,
                                            domain_values,
                                            ape.enc.transform(scaled_data[0][ape.categorical_features].reshape(1, -1)).toarray(),
                                            categorical_features=range(len(scaled_data[0][ape.categorical_features].reshape(1, -1)) - len(ape.continuous_features)),
                                            discretized_feature_names=discretized_feature_names)
        ret_exp = explanation.Explanation(domain_mapper,
                                          mode=self.mode,
                                          class_names=self.class_names)
        ret_exp.scaled_data = scaled_data
        if self.mode == "classification":
            ret_exp.predict_proba = yss[0]
            if top_labels:
                labels = np.argsort(yss[0])[-top_labels:]
                ret_exp.top_labels = list(labels)
                ret_exp.top_labels.reverse()
        else:
            ret_exp.predicted_value = predicted_value
            ret_exp.min_value = min_y
            ret_exp.max_value = max_y
            labels = [0]
        for label in labels:
            (ret_exp.intercept[label],
             ret_exp.local_exp[label],
             ret_exp.score, ret_exp.local_pred, 
             ret_exp.easy_model, ret_exp.used_features)= self.base.explain_instance_with_data(
                    scaled_data,
                    yss,
                    distances,
                    label,
                    num_features,
                    model_regressor=model_regressor,
                    feature_selection=self.feature_selection,
                    ape=ape)
        if self.mode == "regression":
            ret_exp.intercept[1] = ret_exp.intercept[0]
            ret_exp.local_exp[1] = [x for x in ret_exp.local_exp[0]]
            ret_exp.local_exp[0] = [(i, -1 * j) for i, j in ret_exp.local_exp[1]]
        if user_simulated:
            return ret_exp, self.base.used_features
        return ret_exp
def explain_instance_training_dataset ( self , data_row , predict_fn , labels = ( 1 , ) , top_labels = None , num_features = 10 , num_samples = 5000 , distance_metric = 'euclidean' , model_regressor = None , instances_in_sphere = [ ] , ape = None , user_simulated = False ) : if instances_in_sphere != [ ] : data , inverse = instances_in_sphere , instances_in_sphere else : data , inverse = self . training_data , self . training_data np . insert ( data , 0 , data_row ) np . insert ( inverse , 0 , data_row ) scaled_data = ( data - self . scaler . mean_ ) / self . scaler . scale_ if ape is None : distances = sklearn . metrics . pairwise_distances ( scaled_data , scaled_data [ 0 ] . reshape ( 1 , - 1 ) , metric = distance_metric ) . ravel ( ) else : distances = [ ] for instance in instances_in_sphere : distances . append ( dista ( scaled_data [ 0 ] , instance , ape ) ) distances = np . array ( distances ) yss = predict_fn ( inverse ) if self . mode == "classification" : if len ( yss . shape ) == 1 : """
                raise NotImplementedError("LIME does not currently support "
                                          "classifier models without probability "
                                          "scores. If this conflicts with your "
                                          "use case, please let us know: "
                                          "https://github.com/datascienceinc/lime/issues/16")
                """ elif len ( yss . shape ) == 2 : if self . class_names is None : self . class_names = [ str ( x ) for x in range ( yss [ 0 ] . shape [ 0 ] ) ] else : self . class_names = list ( self . class_names ) if not np . allclose ( yss . sum ( axis = 1 ) , 1.0 ) : warnings . warn ( """
                    Prediction probabilties do not sum to 1, and
                    thus does not constitute a probability space.
                    Check that you classifier outputs probabilities
                    (Not log probabilities, or actual class predictions).
                    """ ) else : raise ValueError ( "Your model outputs " "arrays with {} dimensions" . format ( len ( yss . shape ) ) ) else : try : assert isinstance ( yss , np . ndarray ) and len ( yss . shape ) == 1 except AssertionError : raise ValueError ( "Your model needs to output single-dimensional \
                    numpyarrays, not arrays of {} dimensions" . format ( yss . shape ) ) predicted_value = yss [ 0 ] min_y = min ( yss ) max_y = max ( yss ) yss = yss [ : , np . newaxis ] feature_names = copy . deepcopy ( self . feature_names ) if feature_names is None : feature_names = [ str ( x ) for x in range ( data_row . shape [ 0 ] ) ] values = self . convert_and_round ( data_row ) for i in self . categorical_features : if self . discretizer is not None and i in self . discretizer . lambdas : continue name = int ( data_row [ i ] ) if i in self . categorical_names : try : name = self . categorical_names [ i ] [ name ] except IndexError : print ( "error in dataset categorical names" , self . categorical_names ) print ( i ) print ( name ) feature_names [ i ] = '%s=%s' % ( feature_names [ i ] , name ) values [ i ] = 'True' categorical_features = self . categorical_features discretized_feature_names = None if self . discretizer is not None : categorical_features = range ( data . shape [ 1 ] ) discretized_instance = self . discretizer . discretize ( data_row ) discretized_feature_names = copy . deepcopy ( feature_names ) for f in self . discretizer . names : discretized_feature_names [ f ] = self . discretizer . names [ f ] [ int ( discretized_instance [ f ] ) ] """
        print("domain mapper")
        print("feature names", feature_names)
        print("ape encoded features names", ape.encoded_features_names)
        print("values", values)
        print("scaled data", scaled_data[0])
        print("categorical features", categorical_features)
        print("discretized", discretized_feature_names)
        """ if ape . categorical_features == [ ] : domain_mapper = TableDomainMapper ( feature_names , values , scaled_data [ 0 ] , categorical_features = categorical_features , discretized_feature_names = discretized_feature_names ) else : domain_feature_names = ape . encoded_features_names domain_values = np . append ( ape . enc . transform ( scaled_data [ 0 ] [ ape . categorical_features ] . reshape ( 1 , - 1 ) ) . toarray ( ) [ 0 ] , np . ones ( len ( ape . continuous_features ) ) , axis = 0 ) """
            print("domain_categorical_features", domain_categorical_features)
            print("domain values", domain_values)
            print("target instance", scaled_data[0][ape.categorical_features].reshape(1, -1))
            print("TEST", range(len(scaled_data[0]) - len(ape.continuous_features)))
            print("2ND", range(len(domain_values) - len(ape.continuous_features)))
            #print("2DN", discretized_feature_names[:,ape.continuous_features])""" domain_mapper = TableDomainMapper ( domain_feature_names , domain_values , ape . enc . transform ( scaled_data [ 0 ] [ ape . categorical_features ] . reshape ( 1 , - 1 ) ) . toarray ( ) , categorical_features = range ( len ( scaled_data [ 0 ] [ ape . categorical_features ] . reshape ( 1 , - 1 ) ) - len ( ape . continuous_features ) ) , discretized_feature_names = discretized_feature_names ) ret_exp = explanation . Explanation ( domain_mapper , mode = self . mode , class_names = self . class_names ) ret_exp . scaled_data = scaled_data if self . mode == "classification" : ret_exp . predict_proba = yss [ 0 ] if top_labels : labels = np . argsort ( yss [ 0 ] ) [ - top_labels : ] ret_exp . top_labels = list ( labels ) ret_exp . top_labels . reverse ( ) else : ret_exp . predicted_value = predicted_value ret_exp . min_value = min_y ret_exp . max_value = max_y labels = [ 0 ] for label in labels : ( ret_exp . intercept [ label ] , ret_exp . local_exp [ label ] , ret_exp . score , ret_exp . local_pred , ret_exp . easy_model , ret_exp . used_features ) = self . base . explain_instance_with_data ( scaled_data , yss , distances , label , num_features , model_regressor = model_regressor , feature_selection = self . feature_selection , ape = ape ) if self . mode == "regression" : ret_exp . intercept [ 1 ] = ret_exp . intercept [ 0 ] ret_exp . local_exp [ 1 ] = [ x for x in ret_exp . local_exp [ 0 ] ] ret_exp . local_exp [ 0 ] = [ ( i , - 1 * j ) for i , j in ret_exp . local_exp [ 1 ] ] if user_simulated : return ret_exp , self . base . used_features return ret_exp
Generates explanations for a prediction.
Generates explanations for a prediction .
"""Generates explanations for a prediction.

        First, we learn locally weighted linear models on 
        the instances from "instances_in_sphere" to explain each of the classes
        in an interpretable way (see lime_base.py).

        Args:
            data_row: 1d numpy array, corresponding to a row
            predict_fn: prediction function. For classifiers, this should be a
                function that takes a numpy array and outputs prediction
                probabilities. For regressors, this takes a numpy array and
                returns the predictions. For ScikitClassifiers, this is
                `classifier.predict_proba()`. For ScikitRegressors, this
                is `regressor.predict()`. The prediction function needs to work
                on multiple feature vectors (the vectors randomly perturbed
                from the data_row).
            labels: iterable with labels to be explained.
            top_labels: if not None, ignore labels and produce explanations for
                the K labels with highest prediction probabilities, where K is
                this parameter.
            num_features: maximum number of features present in explanation
            num_samples: size of the neighborhood to learn the linear model
            distance_metric: the distance metric to use for weights.
            model_regressor: sklearn regressor to use in explanation. Defaults
                to Ridge regression in LimeBase. Must have model_regressor.coef_
                and 'sample_weight' as a parameter to model_regressor.fit()
            instances_in_sphere: Matrix of instances on which we train the 
                linear model. If None we use the training dataset

        Returns:
            An Explanation object (see explanation.py) with the corresponding
            explanations.
        """ #data, inverse = self.__data_inverse(data_row, num_samples) # for classification, the model needs to provide a list of tuples - classes # along with prediction probabilities """
                raise NotImplementedError("LIME does not currently support "
                                          "classifier models without probability "
                                          "scores. If this conflicts with your "
                                          "use case, please let us know: "
                                          "https://github.com/datascienceinc/lime/issues/16")
                """ # for regression, the output should be a one-dimensional array of predictions # add a dimension to be compatible with downstream machinery """
        print("domain mapper")
        print("feature names", feature_names)
        print("ape encoded features names", ape.encoded_features_names)
        print("values", values)
        print("scaled data", scaled_data[0])
        print("categorical features", categorical_features)
        print("discretized", discretized_feature_names)
        """ #print(ape.enc.transform(scaled_data[0][ape.categorical_features].reshape(1, -1)).toarray()) #print(list(range(len(ape.continuous_features)))) #domain_categorical_features = ape.enc.transform(scaled_data[0][ape.categorical_features].reshape(1, -1)).toarray()[0] """
            print("domain_categorical_features", domain_categorical_features)
            print("domain values", domain_values)
            print("target instance", scaled_data[0][ape.categorical_features].reshape(1, -1))
            print("TEST", range(len(scaled_data[0]) - len(ape.continuous_features)))
            print("2ND", range(len(domain_values) - len(ape.continuous_features)))
            #print("2DN", discretized_feature_names[:,ape.continuous_features])""" #ret_exp.data_print, ret_exp.prediction_print) 
An Explanation object  with the corresponding
explanations.
An Explanation object with the corresponding explanations .
self
data_row
1d numpy array, corresponding to a row
1d numpy array corresponding to a row
predict_fn
prediction function. For classifiers, this should be a
function that takes a numpy array and outputs prediction
probabilities. For regressors, this takes a numpy array and
returns the predictions. For ScikitClassifiers, this is
`classifier.predict_proba()`. For ScikitRegressors, this
is `regressor.predict()`. The prediction function needs to work
on multiple feature vectors (the vectors randomly perturbed
from the data_row).
prediction function . For classifiers this should be a function that takes a numpy array and outputs prediction probabilities . For regressors this takes a numpy array and returns the predictions . For ScikitClassifiers this is ` classifier . predict_proba () ` . For ScikitRegressors this is ` regressor . predict () ` . The prediction function needs to work on multiple feature vectors ( the vectors randomly perturbed from the data_row ) .
labels
iterable with labels to be explained.
iterable with labels to be explained .
top_labels
if not None, ignore labels and produce explanations for
the K labels with highest prediction probabilities, where K is
this parameter.
if not None ignore labels and produce explanations for the K labels with highest prediction probabilities where K is this parameter .
num_features
maximum number of features present in explanation
maximum number of features present in explanation
num_samples
size of the neighborhood to learn the linear model
size of the neighborhood to learn the linear model
distance_metric
the distance metric to use for weights.
the distance metric to use for weights .
model_regressor
sklearn regressor to use in explanation. Defaults
to Ridge regression in LimeBase. Must have model_regressor.coef_
and 'sample_weight' as a parameter to model_regressor.fit()
sklearn regressor to use in explanation . Defaults to Ridge regression in LimeBase . Must have model_regressor . coef_ and ' sample_weight ' as a parameter to model_regressor . fit ()
instances_in_sphere
Matrix of instances on which we train the
linear model. If None we use the training dataset
Matrix of instances on which we train the linear model . If None we use the training dataset
ape
user_simulated