Skip to main content

TRUST - Decision Trees with Lasso Leaves and Random Forest accuracy

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 (Relaxed Lasso) models 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)
  • ✅ All core features are fully functional within these bounds
  • ✅ 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 TRUST.

What's new in version 2.1.4? First version with expanded platform compatibility, plus minor improvements in many areas.

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

ℹ️ Currently, trust-free includes a precompiled binary for:

  • ✅ macOS11+ ARM64
  • ✅ macOS11+ Intel
  • ✅ Both Python 3.11 and 3.12 are supported. Support for Python 3.13+ will be added as soon as all trust-free dependencies support it.

Compatibility for Linux and Windows is coming soon for this release, projected for early December 2025:

  • ⏳ Linux Intel (e.g. for Google Colab compatibility)
  • ⏳ Linux ARM64
  • ⏳ Windows Intel

🚀 Stay tuned!

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

Usage

Here are two basic examples of how to use the TRUST™ algorithm:

from trust import TRUST # 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 = TRUST()
model.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))
# Obtain (conditional) variable importance by Ghost method (based on Delicado and Pena, 2023)
model.varImp(X_test, y_test, corAnalysis=True, filename="Synthetic")
# Unconditional variable importance by permutation (with added debiasing and uncertainty quantification steps)
model.varImpPerm(X_test, y_test, R=20, B=20, U=10, filename="Synthetic")
varImp varImpPerm
# Obtain prediction explanation for first 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]
RLT_Diabetes = TRUST(max_depth=1)
RLT_Diabetes.fit(Diabetes_X,Diabetes_y)
y_pred_TRUST = RLT_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
RLT_Diabetes.plot_tree("Diabetes") #will save "tree_plot_Diabetes.png" in your working directory
tree
# Obtain variable importance with 2 different methods: Ghost and permutation
RLT_Diabetes.varImp(Diabetes_X, Diabetes_y, corAnalysis=True, filename="Diabetes") #Ghost method
RLT_Diabetes.varImpPerm(Diabetes_X, Diabetes_y, filename="Diabetes") #Permutation method
varImp2 varImp3
# Obtain prediction explanation for second observation
RLT_Diabetes.explain(Diabetes_X.iloc[1,:], aim="decrease", actual=Diabetes_y[1], filename="Diabetes")
Explain2 Explain3 Explain4
# Compare the second and fourth observations head-to-head
RLT_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 details about the TRUST™ algorithm can be found in our preprint on arXiv:

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

Copyright © 2025 Albert Dorador Chalar. All rights reserved. TRUST™ is a trademark 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-2.1.4-cp312-cp312-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.12Windows x86-64

trust_free-2.1.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.4 MB view details)

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

trust_free-2.1.4-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-2.1.4-cp312-cp312-macosx_11_0_arm64.whl (832.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

trust_free-2.1.4-cp312-cp312-macosx_10_13_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

trust_free-2.1.4-cp311-cp311-win_amd64.whl (831.3 kB view details)

Uploaded CPython 3.11Windows x86-64

trust_free-2.1.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.3 MB view details)

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

trust_free-2.1.4-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (1.2 MB view details)

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

trust_free-2.1.4-cp311-cp311-macosx_11_0_arm64.whl (815.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

trust_free-2.1.4-cp311-cp311-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: trust_free-2.1.4-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-2.1.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 75e43adf997f4d47737ce9aefc94d44b8f76e4c8f80e24a37893ad1f9c4dd068
MD5 572ff1c517c09cbe071bbfd095647a5e
BLAKE2b-256 0e8952e794a934a7e2eed72a13804db3ccbb349dfe31730f4cfabed78c1a617e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trust_free-2.1.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 753787db38c4d2a13ad9ee1631395441f9c0082fc0e2de4ec7affb23e4bcd613
MD5 5f63c1bb70c6556b8a7cecedce1b8545
BLAKE2b-256 7a639897a9c655e992c90a419445ce1d83fbf4d64f99512a553f47cbbb41c79b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trust_free-2.1.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 805966ab42a6fb61c35b5498172fb208f4d76e08838e327106a194796116dc45
MD5 787ee41c5854957e19c7ab3e3d137a3d
BLAKE2b-256 f246f350a4b6a95d974fa6a25b4e85917cc6baad6342ebc85ba5ba2185ec1ffc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trust_free-2.1.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 287cfeff6e95e59e814b92ec2693f9b0f89ce5c560cc41cf5c398c0000ffbca4
MD5 a991afe1b7720b53b6806df47ffc363b
BLAKE2b-256 cf82a67fd2c9bc186324dd657236b5d3826c83bee46d98169f0fc349069955fb

See more details on using hashes here.

File details

Details for the file trust_free-2.1.4-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for trust_free-2.1.4-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1cd9d4b32a050dfea36cd79548ab8ceb041918ede5da8a8ab19bca8030d2f864
MD5 80ecc6c1c2eba909418d11b6e8770f6c
BLAKE2b-256 45b0343fedc82a6c1238df6cd9950fefdc814050c3f8a5eada319445409d0019

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trust_free-2.1.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 831.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-2.1.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 905bbe7c497902785570bd8d1c0444fd3ecb2627170584cb3d6802724d1bf304
MD5 57ffed9dfcead138e0e2ae373288e768
BLAKE2b-256 7cce6605a11ea2f194c44095d0205e7fffcaa712390ddbae0ca08a9bfb332e51

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trust_free-2.1.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 23e56c3d2b00069e2ee4d2679ffba7cdcd7d16fb1824a3f970ebc3bf558becd7
MD5 fb2d44d60728ac2dcf75b786b1cd7793
BLAKE2b-256 496246e39dfa1b335b663f20a4a02ae732b59a202e16978945176fc8a121cbf7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trust_free-2.1.4-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f62f19824607b2e46ae7325703e6f9ec6c12a3a0300f72a9e8c24cc0e4d5a935
MD5 7fd1db771cbb50851dc1c5806dd470fb
BLAKE2b-256 262933ed8686dae5db1f5a52386ad628835efdbd0d0e41fa44731769a184277f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trust_free-2.1.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 774f6b652b11f9731b42a43e9dd94bdaf3b1b3f861b0ddd4470c660fc5df5028
MD5 e563d4fbd3f1491e2328635f1d0c4e8b
BLAKE2b-256 80e6dae0fd05b8345542860bd5418936f783af51f8e7e7fe09c00e6f598e1fc0

See more details on using hashes here.

File details

Details for the file trust_free-2.1.4-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for trust_free-2.1.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 576eac522f26ecea7ddaffa5ced668630fbb4fcda687969afe346a35dd89afe4
MD5 2e45ec8fa9330aeddfd9797dd4cacf71
BLAKE2b-256 2533576c3fd6bc3ac5603e88ab549cef4eac589551cb52081f93816932ae2353

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