Data Dependent Explanation

Experiment initialization and data preparation

from piml import Experiment
from piml.models import XGB2Classifier

exp = Experiment()
exp.data_loader(data="SimuCredit", silent=True)
exp.data_summary(feature_exclude=["Gender", "Race"], silent=True)
exp.data_prepare(target="Approved", task_type="classification", silent=True)

Train Model

exp.model_train(model=XGB2Classifier(n_estimators=100), name="XGB2")

PFI with training data (by default)

exp.model_explain(model="XGB2", show="pfi", figsize=(5, 4))
Permutation Feature Importance

PFI with testing data

exp.model_explain(model="XGB2", show="pfi", use_test=True, figsize=(5, 4))
Permutation Feature Importance

H-statistics with training data (use training data by default)

exp.model_explain(model="XGB2", show="hstats",
                  grid_size=5, figsize=(5, 4))
Interaction Importance (H-Statistic)

H-statistics with testing data

exp.model_explain(model="XGB2", show="hstats", use_test=True,
                  grid_size=5, figsize=(5, 4))
Interaction Importance (H-Statistic)

PDP with training data (use training data by default)

exp.model_explain(model="XGB2", show="pdp", uni_feature="Balance",
                  grid_size=50, figsize=(5, 4))
Partial Dependence Plot

PDP with testing data

exp.model_explain(model="XGB2", show="pdp", uni_feature="Balance",
                  grid_size=50, use_test=True, figsize=(5, 4))
Partial Dependence Plot

ICE with training data (use training data by default)

exp.model_explain(model="XGB2", show="ice", uni_feature="Balance",
                  figsize=(5, 4))
Individual Conditional Expectation

ICE with testing data

exp.model_explain(model="XGB2", show="ice", uni_feature="Balance",
                  use_test=True, figsize=(5, 4))
Individual Conditional Expectation

ALE with training data (use training data by default)

exp.model_explain(model="XGB2", show="ale", uni_feature="Balance",
                  grid_size=50, figsize=(5, 4))
Accumulated Local Effects

ALE with testing data

exp.model_explain(model="XGB2", show="ale", uni_feature="Balance",
                  grid_size=50, use_test=True, figsize=(5, 4))
Accumulated Local Effects

LIME on training data (use training data by default)

exp.model_explain(model="XGB2", show="lime", sample_id=0, figsize=(5, 4))
Local Weights and Effects

LIME on testing data

exp.model_explain(model="XGB2", show="lime", sample_id=0, use_test=True, figsize=(5, 4))
Local Weights and Effects

SHAP on training data (use training data by default)

exp.model_explain(model="XGB2", show="shap_waterfall", sample_id=0, figsize=(5, 4))
plot 6 data dependent explain

SHAP on testing data

exp.model_explain(model="XGB2", show="shap_waterfall", sample_id=0, use_test=True, figsize=(5, 4))
plot 6 data dependent explain

Total running time of the script: ( 1 minutes 50.451 seconds)

Estimated memory usage: 70 MB

Gallery generated by Sphinx-Gallery