First Example with Modeva#

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 modeva modules.

from modeva import DataSet
from modeva import TestSuite
from modeva.models import MoXGBRegressor, MoLGBMRegressor

Load BikeSharing Dataset

ds = DataSet()
ds.load(name="BikeSharing")
ds.set_random_split()
✓ Auth code found in local storage.
Authenticating Modeva...
✓ License is active and valid.
✓ Authenticated successfully!

Fit XGB and LGBM models

model1 = MoXGBRegressor(name="XGB")
model1.fit(ds.train_x, ds.train_y)

model2 = MoLGBMRegressor(name="LGBM-2", max_depth=2, verbose=-1)
model2.fit(ds.train_x, ds.train_y)
MoLGBMRegressor(boosting_type='gbdt', class_weight=None, colsample_bytree=1.0,
                importance_type='split', learning_rate=0.1, max_depth=2,
                min_child_samples=20, min_child_weight=0.001,
                min_split_gain=0.0, n_estimators=100, n_jobs=None,
                num_leaves=31, objective=None, random_state=None, reg_alpha=0.0,
                reg_lambda=0.0, subsample=1.0, subsample_for_bin=200000,
                subsample_freq=0, verbose=-1)
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.


Model Explainability (PDP for hr)

ts = TestSuite(ds, model1)
results = ts.explain_pdp("hr")
results.plot()


Model Explainability (PDP for season)

results = ts.explain_pdp("season")
results.plot()


Diagnostics (accuracy)

results = ts.diagnose_accuracy_table()
results.table
MSE MAE R2
train 803.002976 18.482872 0.975505
test 1718.229803 26.110423 0.948508
GAP 915.226826 7.627551 -0.026996


Diagnostics (slicing accuracy)

results = ts.diagnose_slicing_accuracy(features=(("hr", ), ("season", )), method="uniform",
                                       bins=10, metric="MSE")
results.plot()


Model comparison (slicing accuracy)

tsc = TestSuite(ds, models=[model1, model2])
results = tsc.compare_slicing_accuracy(features="hr", method="quantile",
                                       bins=10, metric="MSE")
results.plot()


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

Gallery generated by Sphinx-Gallery