xai_compare.abstract.explainer
Classes
|
An abstract base class for creating explainers that can interpret the predictions made by machine learning models. |
- class xai_compare.abstract.explainer.Explainer(model, X_train: DataFrame, y_train: DataFrame | Series | ndarray, y_pred: DataFrame | Series | ndarray | None = None, mode: str = 'regression')
An abstract base class for creating explainers that can interpret the predictions made by machine learning models.
- Attributes:
- model:
A machine learning model whose predictions are to be interpreted.
- X_train (pd.DataFrame):
Training data used to fit the model.
- y_train (Union[pd.DataFrame, pd.Series, np.ndarray]):
Training labels or targets.
- y_pred (Union[pd.DataFrame, pd.Series, np.ndarray, None], optional):
Predicted values. Defaults to None.
- mode (str):
The mode of the explainer, which could be ‘regression’ or ‘classification’ from config.py.
- Methods:
- explain_global(x_data: pd.DataFrame) -> pd.DataFrame:
Abstract method to compute global explanations.
- explain_local(x_data: pd.DataFrame) -> pd.DataFrame:
Abstract method to compute local explanations.
- abstract explain_global(x_data: DataFrame) DataFrame
Generates a global explanation of the model predictions over the entire dataset.
- Attributes:
- x_data (pd.DataFrame):
Dataset for which the global explanation is required.
- Returns:
- pd.DataFrame:
A DataFrame containing the global explanation results.
- abstract explain_local(x_data: DataFrame) DataFrame
Generates a local explanation of the model predictions for individual samples.
- Attributes:
- x_data (pd.DataFrame):
Dataset for which local explanations are required.
- Returns:
- pd.DataFrame:
A DataFrame containing the local explanation results for each sample.