Decision Tree Regression
# %%
# 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='YOUR_LICENSE_KEY')
# %%
# Import required modules
from modeva import DataSet
from modeva import TestSuite
from modeva.models import MoDecisionTreeRegressor
# %%
# Load and prepare dataset
ds = DataSet()
ds.load(name="BikeSharing") # Changed dataset name
ds.set_random_split()
ds.set_target("cnt")
ds.scale_numerical(features=("cnt",), method="log1p")
ds.preprocess()
# %%
# Train model
# ----------------------------------------------------------
model = MoDecisionTreeRegressor(max_depth=3)
model.fit(ds.train_x, ds.train_y)
# %%
# Basic accuracy analysis
# ----------------------------------------------------------
ts = TestSuite(ds, model)
results = ts.diagnose_accuracy_table()
results.table
# %%
# Global tree interpretation
# ----------------------------------------------------------
results = ts.interpret_global_tree()
results.plot()
# %%
# Local tree interpretation
# ----------------------------------------------------------
results = ts.interpret_local_tree(sample_index=0)
results.plot()