Skip to main content

TRUST - Decision Trees with Sparse Elastic Net leaves, Random Forest accuracy and automated explanations

Project description

trust-free TRUST logo

PyPI version Python Downloads License User Manual

Model. Explain. TRUST. All in one package.

Overview

trust-free is a Python package for fitting interpretable regression models using Transparent, Robust, and Ultra-Sparse Trees (TRUST™) — a new generation of Linear Model Trees (LMTs) with Random-Forest (RF) accuracy and intuitive explanations. The core methods are based on the PRICAI 2025 paper that introduced the TRUST algorithm, forthcoming in Springer Nature (Lecture Notes in Artificial Intelligence).

It includes a state-of-the-art explainability suite, providing comprehensive, automatically-generated explanation reports. To see it in action, here are two 15-second demos showcasing the explain() and compare() methods applied to the famous Medical Insurance Charges dataset from Kaggle:

explain() method

TRUST™’s explain() method — Straightforward prediction explanations

compare() method

TRUST™’s compare() method — Comprehensive head-to-head profile comparisons

Proven Performance: Accuracy + Full Interpretability (60 Datasets)

Model Test R² ↑ Interpretable?
TRUST™ 0.67 ✅ Yes
Random Forest (RF) 0.62 ❌ No
Lasso 0.57 ✅ Yes
CART 0.49 ✅ Yes
Node Harvest (NH) 0.47 ✅ Yes
M5' (Linear Model Tree) 0.36 ⚠️ Partially

In the table above, TRUST™ is the only fully interpretable model statistically above 0.6 test R² across varied benchmark datasets — and 6× sparser than M5' (17 vs 109 coefficients on average).
Source: PRICAI 2025 (Springer LNAI)

See full benchmarks in the PRICAI 2025 paper


The package currently supports standard regression and experimental time-series regression tasks. Future releases will also tackle other tasks such as classification.

Key Advantages: RF Accuracy ⟡ Tree Transparency ⟡ Linear Interpretability

  • Hybrid power: Trees to capture non-linearity & interactions + sparse linear models (Adaptive or Relaxed Elastic Net) in leaves
  • Superior accuracy: RF-level accuracy, proven on 60 benchmark datasets
  • Full transparency: Every prediction is auditable via tree path + leaf equation
  • Inclusive: Explanation reports written in natural language accessible to all audiences
  • Compliant by design: 100% Compliant with the EU AI Act and the OECD AI Principles — ideal for high-stakes domains like finance and healthcare

Media

About this edition

  • ℹ️ Free-tier Dataset Limits: ≤ 5,000 rows and ≤ 20 columns (intended for proof-of-concept, R&D and teaching)
  • ✅ Full Functionality: All core features are fully functional within these bounds
  • ✅ Standalone Tools: Relaxed Net (Renet™), Adaptive Net, TurboSolve™ (fast OLS/ridge solver), Direct & Systemic Feature Importance
  • ⭐ No-Limit Utilities: TurboSolve™, Feature Importance methods, and our open-source Synthetic Dataset Generators (Toeplitz, Block-Correlated) can be used without restriction as standalone tools
  • 🚀 Need even more? We got you covered: Unlimited scale and additional features in the forthcoming trust-pro edition

Want early access to trust-pro?

Installation

You can install this package using pip:

pip install trust-free

📦 Note: The package name on PyPI is trust-free, but the module you import in Python is trust: from trust import TRUSTRegressor.

What's new in version 3.0.0? 5-20x faster training, new models in leaves (Adaptive or Relaxed Elastic Net), new Direct and Systemic Feature Importance, and more!

Check CHANGELOG.md on the project's GitHub to see this and all past release notes.

Platform Compatibility

Platform / Environment OS & Arch Python Status
macOS ARM64 (M1–M4) macOS 11+ ARM64 3.11–3.12 ✅ Working
macOS Intel (x86_64) macOS 11+ Intel 3.11–3.12 ✅ Working
Linux Intel/AMD manylinux x86_64 3.11–3.12 ✅ Working
Google Colab Linux x86_64 3.12 ✅ Working
Kaggle Notebooks Linux x86_64 3.11 ✅ Working*
Linux ARM64 manylinux ARM64 3.11–3.12 ✅ Working
Windows Intel/AMD Windows 11 x86_64 3.11–3.12 ✅ Working

*If Kaggle shows a dependency-compatibility issue message upon installation via %pip install trust-free you may safely ignore it and hit "Restart and run up to selected cell" (assuming your selected cell is the one installing trust-free).

For a fully reproducible development environment with all dependencies, see SETUP.md.

Usage

Here are two simple examples showing how to use the trust-free package:

from trust import TRUSTRegressor # note the import name is trust, not trust-free
from sklearn.datasets import make_regression
from sklearn.model_selection import train_test_split
from sklearn.metrics import r2_score, mean_squared_error

🧪 Example 1: Sparse Synthetic Regression (n=5000, p=20)

X, y, coefs = make_regression(n_samples=5000, n_features=20, n_informative=10, coef=True, noise=0.1, random_state=123)
print(coefs)

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=123)
# Instantiate and fit your model
model = TRUSTRegressor().fit(X_train, y_train)
# Predict and print results
y_pred = model.predict(X_test)
print("Predictions:", y_pred[:5])
print("True y values:", y_test[:5])
print("test R\u00B2:", r2_score(y_test, y_pred))
# Estimate direct variable importance for your fitted model
model.importance("direct", filename="Synthetic")
varImp
# Obtain a comprehensive prediction explanation for the first test observation
model.explain(X_test[0,:], mode="detailed", actual=y_test[0], filename="Synthetic") 
Explain1 PieChart

🩺 Example 2: Diabetes Dataset (n=442, p=10)

import pandas as pd
from sklearn import datasets
from sklearn.preprocessing import LabelEncoder

Diabetes = pd.DataFrame(datasets.load_diabetes().data)
Diabetes.columns = datasets.load_diabetes().feature_names
diab_target = datasets.load_diabetes().target
Diabetes.insert(len(Diabetes.columns), "Disease_marker", diab_target)
Diabetes_X = Diabetes.iloc[:,:-1]
# Binary encoding (0/1) for 'sex'
le = LabelEncoder()
Diabetes_X.loc[:, 'sex'] = le.fit_transform(Diabetes_X['sex']).astype(str)
Diabetes_y = Diabetes.iloc[:,-1]
model_Diabetes = TRUSTRegressor(max_depth=1).fit(Diabetes_X,Diabetes_y)
y_pred_TRUST = model_Diabetes.predict(Diabetes_X)
# Tree plotting requires Graphviz to be installed in your system path
# You can use e.g. Homebrew: brew install graphviz or Conda: conda install -c conda-forge graphviz
model_Diabetes.plot_tree("Diabetes") #will save "tree_plot_Diabetes.png" in your working directory
tree
# Obtain direct and systemic variable importance (with impact propagation heatmap) as well as ALE plots for all features
model_Diabetes.importance("direct", filename="Diabetes")
model_Diabetes.importance("systemic", filename="Diabetes")
varImp2 varImp3 varImp3b
ALEplot
# Obtain a prediction explanation for the second observation
model_Diabetes.explain(Diabetes_X.iloc[1,:], aim="decrease", actual=Diabetes_y[1], filename="Diabetes")
Explain2 Explain3a Explain3b Explain4
# Compare the second and fourth observations head-to-head
model_Diabetes.compare(Diabetes_X.iloc[1,:], Diabetes_X.iloc[3,:], filename="Diabetes")
Compare1 Radar Compare2 Pies

More Examples on Kaggle Datasets

License

This software is provided under a Proprietary - Permissive Binary Only license. For detailed terms, please refer to the LICENSE.txt file, which is also included with the distribution.

More Information

For more details, documentation, and information about the full upcoming 'pro' version of the TRUST™ algorithm, visit:

https://github.com/adc-trust-ai/trust-free

Further technical details about TRUST™, Renet™ and our novel variable importance algorithms can be found in our preprints on arXiv:

https://www.arxiv.org/abs/2506.15791

https://arxiv.org/abs/2602.11107

https://arxiv.org/abs/2512.13892

Copyright © 2025-2026 Albert Dorador Chalar. All rights reserved. TRUST™, Renet™ and TurboSolve™ are trademarks of Albert Dorador Chalar.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

trust_free-3.0.0-cp312-cp312-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.12Windows x86-64

trust_free-3.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

trust_free-3.0.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (1.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

trust_free-3.0.0-cp312-cp312-macosx_11_0_arm64.whl (863.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

trust_free-3.0.0-cp311-cp311-win_amd64.whl (852.5 kB view details)

Uploaded CPython 3.11Windows x86-64

trust_free-3.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

trust_free-3.0.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (1.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

trust_free-3.0.0-cp311-cp311-macosx_11_0_arm64.whl (843.9 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file trust_free-3.0.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: trust_free-3.0.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for trust_free-3.0.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 80a59f46cb7712f5409bb8b9ba70d3ccd45afd90c396caf7a881f9325838fee1
MD5 37a41b042c909bae6ffe82616d860c8f
BLAKE2b-256 1f29e6a2b09a7f9f5c7224233af90bb9555177a5500a664cd9587342b3f311ff

See more details on using hashes here.

File details

Details for the file trust_free-3.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for trust_free-3.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a382838f31f23005b5e410ede79e938f15d51e0a461b454aeb63318d554918b6
MD5 800fd6c9bdd99176a8a264d716ca32c9
BLAKE2b-256 cffcee89acf595526684e039e5f37815ff5cc0c7c05a2520cbad68d70b475365

See more details on using hashes here.

File details

Details for the file trust_free-3.0.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for trust_free-3.0.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 86d57c7f83f6dcaf7baf57b7481949e1c74fd13f340129599991d6acb3452c36
MD5 f35b951b26a5f853aeb87b7dcbc8d45f
BLAKE2b-256 cc94a1f81cd5c8b4a1383fdfa5d2e2395b06cc2fda989c9a71989980b47f103e

See more details on using hashes here.

File details

Details for the file trust_free-3.0.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for trust_free-3.0.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2499a80276765b0f33a82914a9565fa98226eb14d95906b89223f116144c3f85
MD5 8221d25f6ebd507aee8621ffcf39f650
BLAKE2b-256 26225c5a672e59c986dde6e8bb60f45606c9dbf24f2ead030e444e196a4636be

See more details on using hashes here.

File details

Details for the file trust_free-3.0.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: trust_free-3.0.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 852.5 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for trust_free-3.0.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1a7784a7724fb8e06108d76c40213ce74eac20c06a3136c4b40ed574b68a98a7
MD5 b501a3b10be18a44780ba3d086dd0366
BLAKE2b-256 5201fd71fbcd513bec10b2b88d26c9e24973c9decf631cc87a185a008c49eba2

See more details on using hashes here.

File details

Details for the file trust_free-3.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for trust_free-3.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8e71d5bd1c569a10c677ede1b59d776884bec0cc8f33bfb0e9c4e072e3a34b8f
MD5 c9407a7ed96f98086f6709875e06dc0e
BLAKE2b-256 fc0564f54a8167b86950969eea64a6e61f2d1f87a0861fbc57a6d3f9166f591d

See more details on using hashes here.

File details

Details for the file trust_free-3.0.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for trust_free-3.0.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 05ef678ffa603be37db045c53d72e7a0d4640beb0a93dd2b7ec22f404293bc7b
MD5 9360197120b612cb814abe2499ddc020
BLAKE2b-256 bdc37fa26209e65f93af178b68eff42e8f98a0e03c9efa53fbbcf07f4a0ed0f6

See more details on using hashes here.

File details

Details for the file trust_free-3.0.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for trust_free-3.0.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6ad4a0ec01d74b985ef7bdf3c7f806df32e6c28ac9e348d239cdb8d554d86a01
MD5 112cd76542e6eecfa64e5229724ac784
BLAKE2b-256 26400886b07d205c26a5d9b78e2ca24dbf019f81b6d4b2b383aae7f53a589d48

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page