Note
Go to the end to download the full example code or to run this example in your browser via Binder
GAMI-Net Classification (Taiwan Credit)¶
Experiment initialization and data preparation
from piml import Experiment
from piml.models import GAMINetClassifier
exp = Experiment()
exp.data_loader(data="TaiwanCredit", silent=True)
exp.data_summary(feature_exclude=["LIMIT_BAL", "SEX", "EDUCATION", "MARRIAGE", "AGE"], silent=True)
exp.data_prepare(target="FlagDefault", task_type="classification", silent=True)
Train Model
exp.model_train(model=GAMINetClassifier(), name="GAMI-Net")
Train Model with monotonicity constraints on PAY_1
exp.model_train(model=GAMINetClassifier(mono_increasing_list=("PAY_1", )), name="Mono-GAMI-Net")
Evaluate predictive performance of GAMI-Net
exp.model_diagnose(model="GAMI-Net", show='accuracy_table')
ACC AUC F1 LogLoss Brier
Train 0.8169 0.7734 0.4465 0.4352 0.1366
Test 0.8228 0.7672 0.4478 0.4292 0.1334
Gap 0.0060 -0.0063 0.0012 -0.0060 -0.0032
Evaluate predictive performance of Mono-GAMI-Net
exp.model_diagnose(model="Mono-GAMI-Net", show='accuracy_table')
ACC AUC F1 LogLoss Brier
Train 0.8161 0.7713 0.4483 0.4373 0.1373
Test 0.8243 0.7650 0.4573 0.4310 0.1338
Gap 0.0082 -0.0063 0.0090 -0.0063 -0.0034
Global effect plot for PAY_1
exp.model_interpret(model="GAMI-Net", show="global_effect_plot", uni_feature="PAY_1",
original_scale=True, figsize=(5, 4))
Global effect plot for PAY_1 of Mono-GAMI-Net
exp.model_interpret(model="Mono-GAMI-Net", show="global_effect_plot", uni_feature="PAY_1",
original_scale=True, figsize=(5, 4))
Effect importance of Mono-GAMI-Net
exp.model_interpret(model="Mono-GAMI-Net", show="global_ei", figsize=(5, 4))
Feature importance of Mono-GAMI-Net
exp.model_interpret(model="Mono-GAMI-Net", show="global_fi", figsize=(5, 4))
Local interpretation by effect of Mono-GAMI-Net
exp.model_interpret(model="Mono-GAMI-Net", show="local_ei", sample_id=0, original_scale=True, figsize=(5, 4))
Local interpretation by feature of Mono-GAMI-Net
exp.model_interpret(model="Mono-GAMI-Net", show="local_fi", sample_id=0, original_scale=True, figsize=(5, 4))
Total running time of the script: (95 minutes 58.559 seconds)