Skip to main content

Modern decision trees in Python

Project description

Code style: black CircleCI Main Checked with mypy codecov PyPI Download count Latest PyPI release DOI

treeple

treeple is a scikit-learn compatible API for building state-of-the-art decision trees. These include unsupervised trees, oblique trees, uncertainty trees, quantile trees and causal trees.

Tree-models have withstood the test of time, and are consistently used for modern-day data science and machine learning applications. They especially perform well when there are limited samples for a problem and are flexible learners that can be applied to a wide variety of different settings, such as tabular, images, time-series, genomics, EEG data and more.

Note that this package was originally named scikit-tree but was renamed to treeple after version 0.8.0. version <0.8.0 is still available at https://pypi.org/project/scikit-tree/.

Documentation

See here for the documentation for our dev version: https://docs.neurodata.io/treeple/dev/index.html

Why oblique trees and why trees beyond those in scikit-learn?

In 2001, Leo Breiman proposed two types of Random Forests. One was known as Forest-RI, which is the axis-aligned traditional random forest. One was known as Forest-RC, which is the random oblique linear combinations random forest. This leveraged random combinations of features to perform splits. MORF builds upon Forest-RC by proposing additional functions to combine features. Other modern tree variants such as Canonical Correlation Forests (CCF), Extended Isolation Forests, Quantile Forests, or unsupervised random forests are also important at solving real-world problems using robust decision tree models.

Installation

Our installation will try to follow scikit-learn installation as close as possible, as we contain Cython code subclassed, or inspired by the scikit-learn tree submodule.

Dependencies

We minimally require:

* Python (>=3.9)
* numpy
* scipy
* scikit-learn >= 1.3

Installation with Pip (https://pypi.org/project/treeple/)

Installing with pip on a conda environment is the recommended route.

pip install treeple

Building locally with Meson (For developers)

Make sure you have the necessary packages installed

# install build dependencies
pip install -r build_requirements.txt

# you may need these optional dependencies to build scikit-learn locally
conda install -c conda-forge joblib threadpoolctl pytest compilers llvm-openmp

We use the spin CLI to abstract away build details:

# run the build using Meson/Ninja
./spin build

# you can run the following command to see what other options there are
./spin --help
./spin build --help

# For example, you might want to start from a clean build
./spin build --clean

# or build in parallel for faster builds
./spin build -j 2

# you will need to double check the build-install has the proper path
# this might be different from machine to machine
export PYTHONPATH=${PWD}/build-install/usr/lib/python3.9/site-packages

# run specific unit tests
./spin test -- treeple/tree/tests/test_tree.py

# you can bring up the CLI menu
./spin --help

You can also do the same thing using Meson/Ninja itself. Run the following to build the local files:

# generate ninja make files
meson build --prefix=$PWD/build

# compile
ninja -C build

# install treeple package
meson install -C build

export PYTHONPATH=${PWD}/build/lib/python3.9/site-packages

# to check installation, you need to be in a different directory
cd docs;  
python -c "from treeple import tree"
python -c "import sklearn; print(sklearn.__version__);"

After building locally, you can use editable installs (warning: this only registers Python changes locally)

pip install --no-build-isolation --editable .

Or if you have spin v0.8+ installed, you can just run directly

spin install

Development

We welcome contributions for modern tree-based algorithms. We use Cython to achieve fast C/C++ speeds, while abiding by a scikit-learn compatible (tested) API. Moreover, our Cython internals are easily extensible because they follow the internal Cython API of scikit-learn as well.

Due to the current state of scikit-learn's internal Cython code for trees, we have to instead leverage a fork of scikit-learn at https://github.com/neurodata/scikit-learn when extending the decision tree model API of scikit-learn. Specifically, we extend the Python and Cython API of the tree submodule in scikit-learn in our submodule, so we can introduce the tree models housed in this package. Thus these extend the functionality of decision-tree based models in a way that is not possible yet in scikit-learn itself. As one example, we introduce an abstract API to allow users to implement their own oblique splits. Our plan in the future is to benchmark these functionalities and introduce them upstream to scikit-learn where applicable and inclusion criterion are met.

References

[1]: Li, Adam, et al. "Manifold Oblique Random Forests: Towards Closing the Gap on Convolutional Deep Networks" SIAM Journal on Mathematics of Data Science, 5(1), 77-96, 2023

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

treeple-0.9.1.tar.gz (15.4 MB view details)

Uploaded Source

Built Distributions

treeple-0.9.1-cp312-cp312-win_amd64.whl (4.9 MB view details)

Uploaded CPython 3.12 Windows x86-64

treeple-0.9.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

treeple-0.9.1-cp312-cp312-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

treeple-0.9.1-cp312-cp312-macosx_10_9_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

treeple-0.9.1-cp311-cp311-win_amd64.whl (5.0 MB view details)

Uploaded CPython 3.11 Windows x86-64

treeple-0.9.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

treeple-0.9.1-cp311-cp311-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

treeple-0.9.1-cp311-cp311-macosx_10_9_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

treeple-0.9.1-cp310-cp310-win_amd64.whl (5.0 MB view details)

Uploaded CPython 3.10 Windows x86-64

treeple-0.9.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

treeple-0.9.1-cp310-cp310-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

treeple-0.9.1-cp310-cp310-macosx_10_9_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

treeple-0.9.1-cp39-cp39-win_amd64.whl (5.0 MB view details)

Uploaded CPython 3.9 Windows x86-64

treeple-0.9.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

treeple-0.9.1-cp39-cp39-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

treeple-0.9.1-cp39-cp39-macosx_10_9_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

Details for the file treeple-0.9.1.tar.gz.

File metadata

  • Download URL: treeple-0.9.1.tar.gz
  • Upload date:
  • Size: 15.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for treeple-0.9.1.tar.gz
Algorithm Hash digest
SHA256 f07cd8338d2b7d35ab324cdf80cefc5860ed93f9b9436d12419834ca9b5793e3
MD5 c057776ff33fc50cb5c30f7c2fa9de8b
BLAKE2b-256 4d1b04bb267b1e30b2fe1ee98b9687929da3fb14afaacc3bcd1e55bdaf96bb8d

See more details on using hashes here.

File details

Details for the file treeple-0.9.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: treeple-0.9.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 4.9 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for treeple-0.9.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2fa03f0761063263cd98a8afb69a8c6b96c0ad7bca2442c56f206cb9d3cf483a
MD5 2a4a00f20db23a58ae6f0b408bff6526
BLAKE2b-256 b827d25a8c902fb8f410e58e531af07bb04010d6290ef34297e34c120a27dfd0

See more details on using hashes here.

File details

Details for the file treeple-0.9.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for treeple-0.9.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f93ad08684ab8be0d37083ab674db1afe9f548c3835afe7f599456fa0ad89400
MD5 513dc0caf199890b30b8060da8892868
BLAKE2b-256 b9ad60da51f9aab3e4a807ce5ae6ff367c9088224788ce73be0fc4b328637078

See more details on using hashes here.

File details

Details for the file treeple-0.9.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for treeple-0.9.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1bd20c1f8b4eb4097c40bb1d4d089c1bca4725320a5f3f384a2f8a8dd09a1875
MD5 b149b1e7eb09157e916eb6b51252c1bc
BLAKE2b-256 da1ca81e76c912517fab337c60e3d6d7bd92e08624197abe95b03f1c9b5c563d

See more details on using hashes here.

File details

Details for the file treeple-0.9.1-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for treeple-0.9.1-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ab5a7ac07b940062207061fc497bd1f3d365279a9b11aee2bf2ed874f6b800fe
MD5 49d2a968d8444dc1cc31c2d1582355ef
BLAKE2b-256 258a0411a102922b65dcde45a64d6a08682d25e3e8a2e7feece9d98f5adbc5bd

See more details on using hashes here.

File details

Details for the file treeple-0.9.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: treeple-0.9.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 5.0 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for treeple-0.9.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2752d5800206fccff50c066dbb7a4d13fb54f036c647843b23fd3074137c9428
MD5 7f9bdf1378ac84c179cf655643f4c218
BLAKE2b-256 923759ca54888e8f6d958a3861d2d1ef574822c886be5f6d5014a711a7d6ee5b

See more details on using hashes here.

File details

Details for the file treeple-0.9.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for treeple-0.9.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 179068fb60e786d95a447842e5a517110d9a3682f3e54ac4a3b4d453b8feb0f8
MD5 d1bab13fe3351ebbe2aae3e082bee044
BLAKE2b-256 cc99c502f208ed3abdd5ab82ab5ad6aac8fd28d63ca3f1cdf6b747f5d3a02129

See more details on using hashes here.

File details

Details for the file treeple-0.9.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for treeple-0.9.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2988949acdca524946c5fb0d702614b1ac87dcf1c5a0f7251995e2020456102c
MD5 6836f4c72214dc6e8184d157fc0a3809
BLAKE2b-256 80c77af5a9629c5ae4c73f16687461d0fecb2f6d46affe2c254edda52cd94633

See more details on using hashes here.

File details

Details for the file treeple-0.9.1-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for treeple-0.9.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f9b9176f8764a6dc8f96cb9ccdd112a7787f5fb18be3d26b90a762a76499579b
MD5 abce66f752741d49fef5ea6c0178fcda
BLAKE2b-256 e8e830a48269a2be16384b16222c4ed11b994160591b4926b47741cde2001db1

See more details on using hashes here.

File details

Details for the file treeple-0.9.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: treeple-0.9.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 5.0 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for treeple-0.9.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f89b58ae08815b0065d4e43ed684276a636ea854af1d89fd5468aa01a5250a6c
MD5 8b4f27fe809f8476ad548751af34f760
BLAKE2b-256 ee0cd8954514b095b366ca6b397b2372fba523cf0600d270cadc1c079e5b49f9

See more details on using hashes here.

File details

Details for the file treeple-0.9.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for treeple-0.9.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ca83f00b5b46bdea118fd2b20356fc45a5b8b457a2d95c5a4587214ce2e43081
MD5 4f9d504c119913cf35e396767c4e2ac6
BLAKE2b-256 91f58b72838abf21f05c83e8e18a06fa9a90a67c213299d83c6a2ec8b8adaa81

See more details on using hashes here.

File details

Details for the file treeple-0.9.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for treeple-0.9.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cc4fa7898daa02d7130868028e2696e137025a442e780ff3830c7a6249119239
MD5 7227de05ecfc73348a4b168a7428986d
BLAKE2b-256 7e3d106a24aa56453b982f350015389f94093ecc96c254dfdc68e16f082ab69f

See more details on using hashes here.

File details

Details for the file treeple-0.9.1-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for treeple-0.9.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ff0b52cfc2108fd9506cceaf2cc822a272f959eec86e16df8fadcdcaf6be62ba
MD5 a0f4b3d06792b3a35b64d8bf656dcf2a
BLAKE2b-256 49a79611823ac47c5a8bf2ecba74f14904eac63243a27a1e9fe0a68a47c7d955

See more details on using hashes here.

File details

Details for the file treeple-0.9.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: treeple-0.9.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 5.0 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for treeple-0.9.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e02e892db881767ec2ab2541784bec0219a64cb40bb8b9e4221797db4e1e73d0
MD5 3deb6ee84a88b00b76d406e74b232827
BLAKE2b-256 5c4dcacf6822efd3a0819e91bd86ce9ca713325529ed877ebdacde00cd8bbc16

See more details on using hashes here.

File details

Details for the file treeple-0.9.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for treeple-0.9.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 47ce5edf06d8ce8d026a49c4ea6602269e1c4ce7184706574ae2f0ce63ae53ef
MD5 6011894213db536347422260aeb9368b
BLAKE2b-256 1a9279f41095d7ef1eb41c2afcf2a2a25e128731ab81b91864b48f299aabb0fa

See more details on using hashes here.

File details

Details for the file treeple-0.9.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for treeple-0.9.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c79a633ee7391650896eb47c4569840265acb203a685bf8d786624c65c64e15c
MD5 271cb15da6ad70a44fc0d3ff1bd6647d
BLAKE2b-256 44be8528eff29fcb1159060d046402e5e1da6a2d7d737f95c80249c42d060265

See more details on using hashes here.

File details

Details for the file treeple-0.9.1-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for treeple-0.9.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 45abfbbd9a64e63f6bc0b33cc7eb71a5dd2319e9f657d5dd431e3cf4067f2c9d
MD5 9ab012e4f54cb26d8ae224f72014c463
BLAKE2b-256 6d3f1668131ed36a3a24820ea6a7977228bbedf5f5e8d5226023c2e396eb655d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page