autoprognosis.plugins.explainers.plugin_kernel_shap module
- class KernelSHAPPlugin(estimator: Any, X: pandas.core.frame.DataFrame, y: pandas.core.frame.DataFrame, task_type: str = 'classification', feature_names: Optional[List] = None, subsample: int = 10, prefit: bool = False, n_epoch: int = 10000, time_to_event: Optional[pandas.core.frame.DataFrame] = None, eval_times: Optional[List] = None, random_state: int = 0, **kwargs: Any)
Bases:
autoprognosis.plugins.explainers.base.ExplainerPlugin
Interpretability plugin based on KernelSHAP.
- Parameters
estimator – model. The model to explain.
X – dataframe. Training set
y – dataframe. Training labels
task_type – str. classification or risk_estimation
prefit – bool. If true, the estimator won’t be trained.
n_epoch – int. training epochs
subsample – int. Number of samples to use.
time_to_event – dataframe. Used for risk estimation tasks.
eval_times – list. Used for risk estimation tasks.
Example
>>> import pandas as pd >>> from sklearn.datasets import load_iris >>> from sklearn.model_selection import train_test_split >>>from autoprognosis.plugins.explainers import Explainers >>> from autoprognosis.plugins.prediction.classifiers import Classifiers >>> >>> X, y = load_iris(return_X_y=True) >>> >>> X = pd.DataFrame(X) >>> y = pd.Series(y) >>> >>> X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2) >>> model = Classifiers().get("logistic_regression") >>> >>> explainer = Explainers().get( >>> "kernel_shap", >>> model, >>> X_train, >>> y_train, >>> task_type="classification", >>> ) >>> >>> explainer.explain(X_test)
- explain(X: pandas.core.frame.DataFrame) numpy.ndarray
- static name() str
- plot(X: pandas.core.frame.DataFrame) None
- static pretty_name() str
- static type() str