xai_compare.explainers.lime_wrapper

Classes

LIME(model, X_train, y_train[, y_pred, mode])

A class that encapsulates the LIME (Local Interpretable Model-agnostic Explanations) method for explaining model predictions.

class xai_compare.explainers.lime_wrapper.LIME(model, X_train: DataFrame, y_train: DataFrame | Series | ndarray, y_pred: DataFrame | Series | ndarray | None = None, mode: str = 'regression')

A class that encapsulates the LIME (Local Interpretable Model-agnostic Explanations) method for explaining model predictions.

The method is detailed in the paper “Why Should I Trust You? Explaining the Predictions of Any Classifier” (https://arxiv.org/pdf/1602.04938).

Attributes:
model:

The machine learning model to be explained.

mode (str):

Indicates whether the explainer is used for ‘regression’ or ‘classification’.

explain_global(X_data: DataFrame) DataFrame

Provides a global explanation of the model by averaging the local explanations across all instances.

Attributes:
X_data (pd.DataFrame):

The dataset for which global explanations are generated.

Returns:
pd.DataFrame:

A DataFrame containing global importance scores for each feature.

explain_local(X_data: DataFrame) DataFrame

Provides local explanations for each instance in the dataset, explaining the contribution of each feature to the individual prediction.

Attributes:
X_data (pd.DataFrame):

The dataset for which local explanations are generated.

Returns:
pd.DataFrame:

A DataFrame where each row represents an instance with feature contributions for that specific prediction.