GAMINet Classification

Installation

# To install the required package, use the following command:
# !pip install modeva

Authentication

# To get authentication, use the following command: (To get full access please replace the token to your own token)
# from modeva.utils.authenticate import authenticate
# authenticate(auth_code='eaaa4301-b140-484c-8e93-f9f633c8bacb')

Import required modules

from modeva import DataSet
from modeva import TestSuite
from modeva.models import MoGAMINetClassifier

Load and prepare dataset

ds = DataSet()
ds.load(name="TaiwanCredit")
ds.set_random_split()
ds.set_target("FlagDefault")

ds.scale_numerical(method="minmax")
ds.preprocess()

Train model

model = MoGAMINetClassifier(random_state=0)
model.fit(ds.train_x, ds.train_y.ravel())
MoGAMINetClassifier(device='cpu', name='MoGAMINetClassifier')
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.


Basic accuracy analysis

ts = TestSuite(ds, model)
results = ts.diagnose_accuracy_table()
results.table
AUC ACC F1 LogLoss Precision Recall Brier
train 0.782959 0.817333 0.451177 0.429718 0.680257 0.337516 0.134997
test 0.782681 0.826500 0.464231 0.420069 0.698142 0.347726 0.130807
GAP -0.000278 0.009167 0.013054 -0.009649 0.017886 0.010209 -0.004191


Feature importance analysis

results = ts.interpret_fi()
results.plot()


Global effects interpretation

For numerical feature

results = ts.interpret_effects(features="PAY_1")
results.plot()


For categorical feature

results = ts.interpret_effects(features="EDUCATION")
results.plot()


For 2 features

results = ts.interpret_effects(features=("PAY_1", "PAY_2"))
results.plot()


Local feature importance analysis

results = ts.interpret_local_fi(sample_index=1, centered=True)
results.plot()


Another sample in train set

results = ts.interpret_local_ei(dataset='train', sample_index=1)
results.plot()


Total running time of the script: (0 minutes 47.379 seconds)

Gallery generated by Sphinx-Gallery