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 and classification 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 (Springer Nature, Lecture Notes in Artificial Intelligence) that introduced the TRUST algorithm.

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, multiclass classification, as well as experimental time-series regression tasks.

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 regression and 15 classification benchmarks
  • Full transparency: Every prediction is auditable via tree path + leaf equation
  • Inclusive: Regression 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 Logistic Regression (AdaLogit™), 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: e.g. from trust import TRUSTRegressor.

What's new in this version? Extension to multiclass classification (AdaLogit™)!

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

Platform Compatibility

Platform / Environment OS & Arch Python Status
Windows Intel/AMD Windows 11 x86_64 3.11–3.12 ✅ Working
macOS ARM64 (M1–M5) macOS 11+ ARM64 3.11–3.12 ✅ Working
Linux Intel/AMD manylinux x86_64 3.11–3.12 ✅ Working
Linux ARM64 manylinux ARM64 3.11–3.12 ✅ Working
Google Colab Linux x86_64 3.12 ✅ Working
Kaggle Notebooks Linux x86_64 3.11 ✅ 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 three simple examples showing how to use the trust-free package:

from trust import TRUSTRegressor, AdaLogitCV # 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, roc_auc_score

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

# Make Train-Test split
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

🆎 Example 3: Sparse Synthetic Classification (n=1000, p=20)

from trust.datasets import generate_block_corr_data_binY
X, y, beta, nonzero_ix, zero_ix = generate_block_corr_data_binY(n=1000, p=20, signal_scale=2.0, pi=0.5, random_state=0)

# Make Train-Test split
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
ALR = AdaLogitCV(l1_ratios=(0.95,), class_weight="balanced", scoring="neg_log_loss").fit(X_train, y_train)
print("Estimated coefficients:", np.round(ALR.coef_[0]))
print("True coefficients:", beta)

# Predict and print results
ALR_predictions = ALR.predict_proba(X_test)[:, 1]
print("Predictions:", np.round(ALR_predictions[:5],2))
print("True y values:", y_test[:5])
print("AdaLogit Test AUC =", round(roc_auc_score(y_test, ALR_predictions), 2))

More Examples on Kaggle Datasets

License

This software is provided under a Proprietary 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

Built with ❤️ by ADC at Whiteboxlab - Copyright © 2025-2026 Albert Dorador Chalar. All rights reserved. TRUST™, Renet™, AdaLogit™, 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.1.1-cp312-cp312-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.12Windows x86-64

trust_free-3.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.6 MB view details)

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

trust_free-3.1.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (1.4 MB view details)

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

trust_free-3.1.1-cp312-cp312-macosx_11_0_arm64.whl (894.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

trust_free-3.1.1-cp311-cp311-win_amd64.whl (875.3 kB view details)

Uploaded CPython 3.11Windows x86-64

trust_free-3.1.1-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.1.1-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.1.1-cp311-cp311-macosx_11_0_arm64.whl (876.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: trust_free-3.1.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.4 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.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6afc38bb47efb7798ff9b31378063beb2b5659076e0b102047998300e5faa855
MD5 38183e2277753e23db9249e8271de208
BLAKE2b-256 82fb356bbe0bf51e3b1955c28c9f2c9ab6837d59349d9bdd5f20088d002f848a

See more details on using hashes here.

File details

Details for the file trust_free-3.1.1-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.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 76ccfe6bbb7b99fbc28d75e382eb4ccbd0c29f9f71a043771442a51b9f7b27ef
MD5 bcdbe24022438ebbfe0967de79ad8f09
BLAKE2b-256 28328c2dfe717d113e29e843c56a3d8e00b8c9f67a9d58e8e1601abf2dd280f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trust_free-3.1.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2fc4e0341d120f7505357d8c567517360712ffe5aceabf187e9fea2b43334a2f
MD5 77d88126f79afc1241413916ba25fb40
BLAKE2b-256 9870dea229053d4b944fba9abf7a11bf4150066e747a5d20c68a62781bd9062c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trust_free-3.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 135d0c79c9c3b243a9c28d314c05546ddc7c6a101192ec7a4176de94a3202033
MD5 91e08f8aeb021d36b4f6917256168ddc
BLAKE2b-256 d578f8e4de4245c75d3d8cb6c7ddfb0f2e8a11912f7b858be31d84818da211c0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trust_free-3.1.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 875.3 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.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a3acf575850c06fa68d0496aafbba00a533af934571776b30525b94c40612583
MD5 fcaf2d56d7a293e4ba90befea99ebfd6
BLAKE2b-256 fabb96b4be6dcb87d4716803b45643cc4512b00368def0958a475aa52f921e85

See more details on using hashes here.

File details

Details for the file trust_free-3.1.1-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.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c9e3cc0073c78246ad08a55bf9e961be51bccde8818270c1564490eb9a04d660
MD5 ef64746ececfd298aa9667c66b1087a9
BLAKE2b-256 2724f3c41478df0aba3f6e86e5e69a9f3f21db0088e2d6859ca4d759047c7dab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trust_free-3.1.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 06cbdb1f9d13b2fb97ac50a35e61a56e5b636585baaec3f9b7d756651e6ba399
MD5 2c768000597b7fb8e62eb80a7b935693
BLAKE2b-256 b80cd1a16358189797dd937d79b5ecef0c837f24b09bf6e954237fb132c4aefc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trust_free-3.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9e079cecf02c190310550466261f7722fae4f30664aca5034d84bbd9c29cd3b4
MD5 0a21cbdcc41a1b261cef20dee6e1da81
BLAKE2b-256 5075fc25dcb8124f116e85b83de51bfbdb1214231951a6608b0f400d1204182f

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