ValidationResult - Visualization#

This example demonstrates how to configure and save visualization results from Modeva to different file formats (HTML and PNG).

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')

Imports

from modeva import DataSet
from modeva import TestSuite
from modeva.models import MoXGBClassifier

Load and prepare data

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

Train models

model = MoXGBClassifier()
model.fit(ds.train_x, ds.train_y)
MoXGBClassifier(base_score=None, booster=None, callbacks=None,
                colsample_bylevel=None, colsample_bynode=None,
                colsample_bytree=None, device=None, early_stopping_rounds=None,
                enable_categorical=False, eval_metric=None, feature_types=None,
                gamma=None, grow_policy=None, importance_type=None,
                interaction_constraints=None, learning_rate=None, max_bin=None,
                max_cat_threshold=None, max_cat_to_onehot=None,
                max_delta_step=None, max_depth=None, max_leaves=None,
                min_child_weight=None, missing=nan, monotone_constraints=None,
                multi_strategy=None, n_estimators=None, n_jobs=None,
                num_parallel_tree=None, objective='binary:logistic', ...)
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.


Generate and save plots#

Create TestSuite instances for single and multiple model analysis

ts = TestSuite(ds, model)

Limit the number of bars in bar plots#

pfi_result = ts.explain_pfi()
pfi_result.plot(n_bars=5)


List the available sub-figure names#

accuracy_results = ts.diagnose_accuracy_table()
accuracy_results.get_figure_names()
[('roc_auc', 'train'), ('precision_recall', 'train'), ('confusion_matrix', 'train'), ('roc_auc', 'test'), ('precision_recall', 'test'), ('confusion_matrix', 'test')]

Display one subplot by its name#

Note that name can be either string or tuple of string

accuracy_results.plot(name=('roc_auc', 'train'))


Save figures#

As html

pfi_result.plot_save(file_name='./image/pfi', format='html')

As png

accuracy_results.plot_save(name=('roc_auc', 'train'),
                           file_name='./image/compare_accuracy',
                           format='png')

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

Gallery generated by Sphinx-Gallery