Skip to main content

PILOT and RaFFLE: Piecewise Linear Organic Trees and Random Forest Featuring Linear Extensions

Project description

fast-model-trees

Fast implementation of PILOT (PIecewise Linear Organic Trees) and RaFFLE (Random Forest Featuring Linear Extensions) algorithms.

Overview

This package provides efficient C++-based implementations of:

  • PILOT: A linear model tree algorithm that builds piecewise linear models
  • RaFFLE: A random forest ensemble method using PILOT trees as base learners

Papers

  • PILOT: Raymaekers, J., Rousseeuw, P. J., Verdonck, T., & Yao, R. (2024). Fast linear model trees by PILOT. Machine Learning, 1-50. https://doi.org/10.1007/s10994-024-06590-3

  • RaFFLE: Raymaekers, J., Rousseeuw, P. J., Servotte, T., Verdonck, T., & Yao, R. (2025). A Powerful Random Forest Featuring Linear Extensions (RaFFLE). Under Review

Installation

pip install fast-model-trees

Building from Source

If you need to build from source, you'll need:

  • C++17 compatible compiler
  • CMake >= 3.12
  • Armadillo linear algebra library
  • BLAS and LAPACK libraries
  • pybind11
  • carma (C++ Armadillo/NumPy bridge)

See INSTALL.md for detailed installation instructions.

Development

For development setup, running benchmarks, and reproducing paper results, see DEVELOPMENT.md.

Quick Start

Using RaFFLE (Random Forest)

from pilot import RaFFLE
import numpy as np

# Create sample data
X = np.random.randn(1000, 10)
y = X[:, 0] + 0.5 * X[:, 1] ** 2 + np.random.randn(1000) * 0.1

# Train RaFFLE model
model = RaFFLE(
    n_estimators=100,
    max_depth=5,
    random_state=42
)
model.fit(X, y)

# Make predictions
predictions = model.predict(X)

# Get feature importances
importances = model.feature_importances_

Using PILOT (Single Tree)

from pilot import PILOT
import numpy as np

# Create sample data
X = np.random.randn(1000, 10)
y = X[:, 0] + 0.5 * X[:, 1] ** 2 + np.random.randn(1000) * 0.1

# Train PILOT model — all parameters have sensible defaults
model = PILOT(max_depth=5)
model.train(X, y)  # categorical defaults to all-numerical

# Make predictions
predictions = model.predict(X)

# Inspect the tree structure
print(model.tree_summary())

Key Features

  • Fast C++ implementation: Optimized for performance using Armadillo linear algebra
  • Scikit-learn compatible: Follows scikit-learn API conventions
  • Flexible model complexity: Control tree depth and piecewise linear behavior
  • Feature importance: Built-in feature importance calculation
  • Bootstrap aggregation: RaFFLE uses bootstrap sampling for robust predictions

Parameters

RaFFLE

  • n_estimators: Number of trees in the forest (default: 10)
  • max_depth: Maximum depth of each tree (default: 12)
  • min_sample_fit: Minimum samples needed to fit any node (default: 10)
  • min_sample_alpha: Minimum samples for piecewise nodes (default: 5)
  • min_sample_leaf: Minimum samples in each leaf (default: 5)
  • random_state: Random seed for reproducibility (default: 42)
  • n_features_tree: Fraction of features to consider per tree (default: 1.0)
  • n_features_node: Fraction of features to consider per node (default: 1.0)
  • alpha: Controls piecewise linear complexity (default: 1)

PILOT

  • df_settings: Degrees of freedom for node types [con, lin, pcon, blin, plin, pconc]. Defaults to [1, 2, 5, 5, 7, 5]. Set a value to -1 to disable that node type.
  • max_depth: Maximum split depth (default: 20)
  • max_model_depth: Maximum total depth including linear model nodes (default: 100)
  • max_features: Features considered per split; None (default) uses all features
  • min_sample_fit: Minimum samples to fit any node (default: 5)
  • min_sample_alpha: Minimum samples for piecewise nodes (default: 5)
  • min_sample_leaf: Minimum samples per leaf (default: 5)
  • rel_tolerance: Minimum relative RSS improvement to keep growing (default: 0.01)

License

MIT License - see LICENSE file for details

Citation

If you use this package in your research, please cite:

@article{raymaekers2024pilot,
  title={Fast linear model trees by PILOT},
  author={Raymaekers, J. and Rousseeuw, P.J. and Verdonck, T. and Yao, R.},
  journal={Machine Learning},
  pages={1--50},
  year={2024},
  doi={10.1007/s10994-024-06590-3}
}

Contributing

Contributions are welcome! Please see the GitHub repository for more information.

Support

For issues and questions, please use the GitHub issue tracker.

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

fast_model_trees-0.0.4.tar.gz (436.7 kB view details)

Uploaded Source

Built Distributions

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

fast_model_trees-0.0.4-cp314-cp314t-win_amd64.whl (6.0 MB view details)

Uploaded CPython 3.14tWindows x86-64

fast_model_trees-0.0.4-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (43.2 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

fast_model_trees-0.0.4-cp314-cp314t-macosx_15_0_arm64.whl (12.0 MB view details)

Uploaded CPython 3.14tmacOS 15.0+ ARM64

fast_model_trees-0.0.4-cp314-cp314-win_amd64.whl (6.0 MB view details)

Uploaded CPython 3.14Windows x86-64

fast_model_trees-0.0.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (43.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

fast_model_trees-0.0.4-cp314-cp314-macosx_15_0_arm64.whl (12.0 MB view details)

Uploaded CPython 3.14macOS 15.0+ ARM64

fast_model_trees-0.0.4-cp313-cp313-win_amd64.whl (5.9 MB view details)

Uploaded CPython 3.13Windows x86-64

fast_model_trees-0.0.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (43.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

fast_model_trees-0.0.4-cp313-cp313-macosx_15_0_arm64.whl (12.0 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

fast_model_trees-0.0.4-cp312-cp312-win_amd64.whl (5.9 MB view details)

Uploaded CPython 3.12Windows x86-64

fast_model_trees-0.0.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (43.2 MB view details)

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

fast_model_trees-0.0.4-cp312-cp312-macosx_15_0_arm64.whl (12.0 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

fast_model_trees-0.0.4-cp311-cp311-win_amd64.whl (5.9 MB view details)

Uploaded CPython 3.11Windows x86-64

fast_model_trees-0.0.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (43.2 MB view details)

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

fast_model_trees-0.0.4-cp311-cp311-macosx_15_0_arm64.whl (12.0 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

fast_model_trees-0.0.4-cp310-cp310-win_amd64.whl (5.9 MB view details)

Uploaded CPython 3.10Windows x86-64

fast_model_trees-0.0.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (43.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

fast_model_trees-0.0.4-cp310-cp310-macosx_15_0_arm64.whl (12.0 MB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

Details for the file fast_model_trees-0.0.4.tar.gz.

File metadata

  • Download URL: fast_model_trees-0.0.4.tar.gz
  • Upload date:
  • Size: 436.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for fast_model_trees-0.0.4.tar.gz
Algorithm Hash digest
SHA256 307cdd0045e6152a1cc3d171d3d7e117162d80773fc3e29df8753eaaf4919d5e
MD5 5a45daac3d40a12da3198d290d761066
BLAKE2b-256 2ea39e33243761c2e28c3e2464097913dcabf0620f9d60cb1975fa16b32f20c1

See more details on using hashes here.

File details

Details for the file fast_model_trees-0.0.4-cp314-cp314t-win_amd64.whl.

File metadata

File hashes

Hashes for fast_model_trees-0.0.4-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 586a49a372b7efdc3f8d097e5ba8c0f0e1ef8e6bc0da2bdb03207dc8c627d75a
MD5 ab5fbbb9ea43df9986b6a1ea43f6f3e7
BLAKE2b-256 208f08e663db87a69404ddc48f0edc20f7627228d2e079fdab7428e3ab07a832

See more details on using hashes here.

File details

Details for the file fast_model_trees-0.0.4-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fast_model_trees-0.0.4-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e75acb1d6acf57cc6d5e10bc17b4bb14186c9ea45f762259402a5c0907bf5f27
MD5 e16f1b8da03dc9877bc1850b6179d85e
BLAKE2b-256 0f8166d7026f86cac0389371db996a48a1eebd52b6115d516f2bdd90003c12b0

See more details on using hashes here.

File details

Details for the file fast_model_trees-0.0.4-cp314-cp314t-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for fast_model_trees-0.0.4-cp314-cp314t-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ad9063249836b3a6962545ba34c7cfd7804165d48f09a808efdf5d0d8ef49876
MD5 606328477b9ed021ee5a9eb656b84842
BLAKE2b-256 1d294546fb3cbc9a66df05db284cff4642f2ef373626896f252e4a09228e9863

See more details on using hashes here.

File details

Details for the file fast_model_trees-0.0.4-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for fast_model_trees-0.0.4-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 4e1de37652452ea0cd4be172d5edc64e8934c918f9b85ae9e940edda3f085e07
MD5 2acf75f98da67dba8b6b96f667443710
BLAKE2b-256 41378af30c0b4d9b4fb1a7cc6075b1533f696ed3ee8b5ff57448f380a058d00a

See more details on using hashes here.

File details

Details for the file fast_model_trees-0.0.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fast_model_trees-0.0.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b26eceb9342fdfa175691cda5738374626343c58a850d596245cc4ee523ef1d4
MD5 7c7ca77c42032c3b2631cd5d51a91c5e
BLAKE2b-256 b4d08d1b964f07a9988b4c9eeebf87d8530f0bce68c092123f712efb613394a5

See more details on using hashes here.

File details

Details for the file fast_model_trees-0.0.4-cp314-cp314-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for fast_model_trees-0.0.4-cp314-cp314-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 9d51f825bb20020d53946478c868bbb406e81bd5b549d8e699eb3f70298dce6b
MD5 dae1e54ccb372d45e2551b820999be90
BLAKE2b-256 63269d48f19aba120b2e712d5e75e689fbca9bea4e2df41ed9d23bb76a0ce491

See more details on using hashes here.

File details

Details for the file fast_model_trees-0.0.4-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for fast_model_trees-0.0.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 b287ebfd7ab6bfa4fa487cfbb47461ec962d9e0c00300007bd6d8f7ece5c120a
MD5 085f140b07ba6e8c3d8d1c71e6179684
BLAKE2b-256 070557b4b8b0e5d9f8750a2536213a1f54de19dcef646dd150235c54790ffa87

See more details on using hashes here.

File details

Details for the file fast_model_trees-0.0.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fast_model_trees-0.0.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b7a85179e28f58b1525cfc469b4383b02935ac695231dcf915b8d4b2f15d37bd
MD5 9a28e029d0db304c946654b719a82b2d
BLAKE2b-256 af3192048466d93914e0a4045c6f14ee32e75a6d909879771043addddc4c0e5a

See more details on using hashes here.

File details

Details for the file fast_model_trees-0.0.4-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for fast_model_trees-0.0.4-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 53573417e4c95a973b27e16a3d7edfc96676a83a4a1c968a9ae27c6cb0977626
MD5 6e33093e86868c99257025e3301ff309
BLAKE2b-256 1724b3673f942318ae445d0616817e18f2f77626f8c50e2110c8e67ecda83530

See more details on using hashes here.

File details

Details for the file fast_model_trees-0.0.4-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for fast_model_trees-0.0.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 757527ba7ec626f42bbeddddc66c0d892847c19b3e197c53d225aa69e472a76a
MD5 26405ab662dfb7c39499b05cb7a0454b
BLAKE2b-256 a6ae6ed15b9d5eab285452f463c023e30afffefb98d7966f3182418f13a7adc0

See more details on using hashes here.

File details

Details for the file fast_model_trees-0.0.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fast_model_trees-0.0.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5a6de6d1dfa93160e7b3d8f17ddd185c15658eb317330c7a2cb5ea7211ccf49b
MD5 7ffb98571e49d3845ce2a3be2f7e980d
BLAKE2b-256 4c836da7ba0dc11e6a9eb1f4be20331f9e227f27e63101bf5d853f954aeb7ec6

See more details on using hashes here.

File details

Details for the file fast_model_trees-0.0.4-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for fast_model_trees-0.0.4-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 d8420b8b6d03dfe5c37c331507d2bec16e204665014ed088da07bcafa1f96c99
MD5 744e5b8f2206994b47d251f00a4bd40d
BLAKE2b-256 801a0d7b4ba4aa0a8d5dc906c794d3a70de5c4252d36b7d7945462ab4f0bf084

See more details on using hashes here.

File details

Details for the file fast_model_trees-0.0.4-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for fast_model_trees-0.0.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f7789fbf60a3da9a26a4d53d371411029662b5332baa75b3562a34bd66369130
MD5 2aa58d7994d1647c37a4e856209f0e04
BLAKE2b-256 c1200d67a612eae564caee53667fef23e03faa92a4771bd3d80acfa3c792eb29

See more details on using hashes here.

File details

Details for the file fast_model_trees-0.0.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fast_model_trees-0.0.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 13ae59f9fd01e204df8a805202142583d340332f4e204fdbca2313e3189987bf
MD5 e71798077c0df81d75cc8c159517b659
BLAKE2b-256 c9bb22e66ea9d7f36314e887c05062cc8cdb1bdb6ae2fc382b2c2b679238df25

See more details on using hashes here.

File details

Details for the file fast_model_trees-0.0.4-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for fast_model_trees-0.0.4-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 405d6aff54bcb784e90f9e0a0c529b770da690261d4bc02cf04540263b9c73f0
MD5 3e864a93ecd6788e71746407670f18f5
BLAKE2b-256 6019d0e82def8d6dd3a0876c4fdf6475128f6ec51072836e664f7247d7930b02

See more details on using hashes here.

File details

Details for the file fast_model_trees-0.0.4-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for fast_model_trees-0.0.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 0ee040b6e14c06e32391e714eba4b7cf48408d8d4ccd1e95b142375549b5e981
MD5 39381488ed9dab531082099e4ec7349b
BLAKE2b-256 ffe551d58e8176817529fcd50ea00caf5b151f6bdccb08109f631135398f2dcc

See more details on using hashes here.

File details

Details for the file fast_model_trees-0.0.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fast_model_trees-0.0.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 79ae16612365184815627212eeaf4b967a3d01937ee248dae60ac615dd2096a2
MD5 e6c062a565e20b36d1cc73d81b01a8f0
BLAKE2b-256 7c5cb1aeb2ebfd8a80c8ac356aac16737cc7fe1a3c12ef2af6413d25f71060b8

See more details on using hashes here.

File details

Details for the file fast_model_trees-0.0.4-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for fast_model_trees-0.0.4-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 a1c29849b4bca2d802b6a066113be11ec6c4b2226171d7a37117ec0558ee282b
MD5 160e3ce8c877a0bc36bfd077e19658ce
BLAKE2b-256 3cbc792ef371d9559fd08dcc4fe7d911ead1860d0a5f7eed21d400b13aac1dba

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