lime_tabular

LIME tabular explainer.

Module Contents

Classes

LIMETabular

Wrapper around the LIME explainer for tabular data.

class lime_tabular.LIMETabular(training_data: numpy.array, mode: str = 'classification', feature_names: List[int] = None, categorical_features: List[int] = None, kernel_width: int = 25, kernel: callable = None, verbose: bool = False, class_names: List[str] = None, feature_selection: str = 'auto', random_state: int = None, **kwargs)[source]

Wrapper around the LIME explainer for tabular data.

explain(model_or_function: str | callable, input_tabular: numpy.array, labels: Iterable[int] = (1,), num_samples: int = 5000, **kwargs) numpy.array[source]

Run the LIME explainer.

Parameters:
  • model_or_function (callable or str) – The function that runs the model to be explained or the path to a ONNX model on disk.

  • input_tabular (np.ndarray) – Data to be explained.

  • labels (Iterable(int), optional) – Indices of classes to be explained.

  • num_samples (int, optional) – Number of samples

  • kwargs – These parameters are passed on

Other keyword arguments: see the documentation for LimeTabularExplainer.explain_instance: https://lime-ml.readthedocs.io/en/latest/lime.html#lime.lime_tabular.LimeTabularExplainer.explain_instance

Returns:

An array (np.ndarray) containing LIME explanations for each class.