Skip to main content

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? Compatibility with scikit-learn pipelines.

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 error message upon installation via %pip install trust-free you may safely ignore it and simply restart your kernel: Run / Restart & clear cell outputs.

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

Usage

Here are four 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 (scikit-learn compatible)
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))

📊 Example 4: 1-Permutation Feature Importance (n=100, p=10)

pip install --quiet tabicl # Only if tabicl is not installed yet
from tabicl import TabICLRegressor
from trust import FeatureImportance, datasets

X, y, coefs = datasets.make_block_correlated_regression(n_samples=100, n_features=10, n_informative=5, noise=1.0, rho=0.5, random_state=123)
model = TabICLRegressor().fit(X, y)
fi = FeatureImportance().fit(model.predict, X, y)
rel_importance = fi.direct_importance() # An order of magnitude faster than classical PFI
linear_scores = np.abs(coefs) / np.sum(np.abs(coefs))
print("Underlying linear model feature importance scores:", np.round(linear_scores, 2))
print("TabICL feature importance scores:", np.round(rel_importance, 2))
print("Underlying linear model feature importance directions:", np.sign(coefs))
print("TabICL feature importance directions:", fi.directions)

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.

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.2-cp312-cp312-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.12Windows x86-64

trust_free-3.1.2-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.2-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.2-cp312-cp312-macosx_11_0_arm64.whl (894.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

trust_free-3.1.2-cp311-cp311-win_amd64.whl (876.7 kB view details)

Uploaded CPython 3.11Windows x86-64

trust_free-3.1.2-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.2-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.2-cp311-cp311-macosx_11_0_arm64.whl (877.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: trust_free-3.1.2-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.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d05453f10f8814a0700a05773ecdcdde66e290e0fca2c7c754e6fba1d956978f
MD5 dcdfcc975f7e4bb96869f2efaa07a5a6
BLAKE2b-256 a667de98fb629cf51004e61b845557b63b673cbb317de899199f02d890237144

See more details on using hashes here.

File details

Details for the file trust_free-3.1.2-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.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 19361fe05d17b3eb640c4bfa3d1fe0fa346f83b5f55888fca9d378fcf95935b4
MD5 5f221a52f0b216e3824f607fa57790db
BLAKE2b-256 99630759b069c158ab9156100e56b5fd872d1320228e4020ffd5346c0bd34af6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trust_free-3.1.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 45630093ed2340038d823710f80f4a6b3cdffc8536b9937ccbbc43f52bc8ab8d
MD5 5e9cda499eb5edb8b207eb89437d6c47
BLAKE2b-256 fbc26aa2206180c064a217a3013578ba6f7ab36e339734b1feb2ea6bfe706b84

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trust_free-3.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 79ce3797fb2f12852b1c7fb43a5946d818367134666ada5769bbdea5877ca49e
MD5 12c0d7f556844c71e6d9fdab8eae09cd
BLAKE2b-256 5ce40d56ec2024e31f60e855f9b6629c999311ded15ec0b045c979597bdd6f23

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trust_free-3.1.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 876.7 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.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ed5ac2b37778487252f99ea811352febd33729c441baa7808e19ed39c2c88103
MD5 59af43aad2f1ab8f6d4b6d6722122a24
BLAKE2b-256 fdbc4d1adbe0827913c23fa425b59d0e68a01bb4cfcc2b8c01b9d35e2c6b5a53

See more details on using hashes here.

File details

Details for the file trust_free-3.1.2-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.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 48bdfb4e5beb2186d6172afb5cbf3bb70de32993f304b084afebd4ea50c2c48f
MD5 4ffab3491e5c7288e7d7cb1125424272
BLAKE2b-256 758645779c992771a5960e1b06e660ada6bbfed8ca1bf6a46279b9a48fe28acd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trust_free-3.1.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6fc9ca130c4a2d5469b94f0b01f0f4cd9f3193a5c598bff1e65a642c6cedd860
MD5 d3574c992a097ec3f0ab729c4166ad57
BLAKE2b-256 cf9d6d38a4ee014b564c2e601ef9a66701f951881a7482472c41db348d57216c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trust_free-3.1.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 737cbbc225669000de77c11ee401cd7d76ce59706a9005efa7179c73552a7a2d
MD5 76bfcbdd0fff6675c20e2e6f2f1c0896
BLAKE2b-256 257f54b00a14991b41dd23277afa4990d5c4d0259a2c4638581c92d87c95fb42

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 Sentry Error logging StatusPage Status page