Skip to main content

Optimal Model Trees using OR-Tools

Project description

OptimalModelTree (OMT)

A mixed-integer optimization-based decision tree framework for classification and regression.

OMT implements Optimal Model Trees, where both the tree structure and the prediction models at the leaves are learned jointly by solving a Mixed-Integer Linear Programming (MILP) problem.

🚀 Features

  • Globally optimized decision tree construction via MILP
  • Supports:
    • Binary classification
    • Multiclass classification
    • Regression
  • Parallel and oblique decision boundaries
  • Sparse and regularized leaf models
  • Warm-start support for faster optimization
  • Scikit-learn-style API (fit, predict, score)

📦 Installation

Install the latest release from PyPI:

pip install optimal-omt

⚙️ Solver Backend

OMT is built on top of Google OR-Tools, which provides interfaces to several Mixed-Integer Linear Programming (MILP) solvers.

By default, OMT uses SCIP, an open-source solver that is distributed with OR-Tools and requires no additional installation.

Commercial solvers such as Gurobi are also supported and can substantially improve performance on larger optimization problems. However, Gurobi is not included with OMT and must be installed and licensed separately.

To use Gurobi:

  1. Obtain a valid Gurobi license.
  2. Install the Python interface:

pip install gurobipy

  1. Configure OMT to use Gurobi as the optimization backend.

If Gurobi is not installed, OMT automatically falls back to SCIP.

Note: OMT solves optimization problems exactly and is therefore intended primarily for small-to-medium datasets.

🧪 Minimal Working Example

The following example trains an Optimal Model Tree on the Wine dataset from scikit-learn.


from sklearn.datasets import load_wine
from sklearn.model_selection import train_test_split
from omt import OptimalModelTreeClassifier
X, y = load_wine(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(
    X,
    y,
    test_size=0.2,
    random_state=42,
    stratify=y
)
clf = OptimalModelTreeClassifier(Splits=2,solver='SCIP')
clf.fit(X_train, y_train)
print("Test accuracy:", clf.score(X_test, y_test))

Example output:


Test accuracy: 0.944

📚 Citation

If you use OMT in your research, please cite:

@article{roselli2025experiments,
  title={Experiments with Optimal Model Trees},
  author={Roselli, Sabino Francesco and Frank, Eibe},
  journal={arXiv preprint arXiv:2503.12902},
  year={2025}
  url = {https://github.com/sabinoroselli/OptimalModelTree}
}

Project details


Download files

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

Source Distribution

optimal_omt-0.1.5.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

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

optimal_omt-0.1.5-py3-none-any.whl (38.1 kB view details)

Uploaded Python 3

File details

Details for the file optimal_omt-0.1.5.tar.gz.

File metadata

  • Download URL: optimal_omt-0.1.5.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for optimal_omt-0.1.5.tar.gz
Algorithm Hash digest
SHA256 c03dda4361d36545ec073c5448e438a9c437a33d753721cee6684661c1f058cd
MD5 f6145c2c275a78d8de474b4fb8a4d41d
BLAKE2b-256 b179ee8b6a5ab3c4a9ab3f14ff566d6523b3d1779efa6e026f7a8484d3e72240

See more details on using hashes here.

Provenance

The following attestation bundles were made for optimal_omt-0.1.5.tar.gz:

Publisher: release.yml on sabinoroselli/OptimalModelTree

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file optimal_omt-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: optimal_omt-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 38.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for optimal_omt-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2d31cd339c7039a24bd39e206c4525662bc55e788e0eefb2242d9d4cb63eeeac
MD5 8ddf167b7e8923d2c25e0c105b745abc
BLAKE2b-256 8fb6edd160be5fb60da9f48759a1ee88211c36f1cb055d7eee34dbb73a5cb697

See more details on using hashes here.

Provenance

The following attestation bundles were made for optimal_omt-0.1.5-py3-none-any.whl:

Publisher: release.yml on sabinoroselli/OptimalModelTree

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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