Skip to main content

Traditional and Oblique Decision Tree

Project description

obliquetree

obliquetree is an advanced decision tree implementation designed to provide high-performance and interpretable models. It supports both classification and regression tasks, enabling a wide range of applications. By offering traditional and oblique splits, it ensures flexibility and improved generalization with shallow trees. This makes it a powerful alternative to regular decision trees.

Tree Visualization


Getting Started

obliquetree combines advanced capabilities with efficient performance. It supports oblique splits, leveraging L-BFGS optimization to determine the best linear weights for splits, ensuring both speed and accuracy.

In traditional mode, without oblique splits, obliquetree outperforms scikit-learn in terms of speed and adds support for categorical variables, providing a significant advantage over many traditional decision tree implementations.

When the oblique feature is enabled, obliquetree dynamically selects the optimal split type between oblique and traditional splits. If no weights can be found to reduce impurity, it defaults to an axis-aligned split, ensuring robustness and adaptability in various scenarios.

In very large trees (e.g., depth 10 or more), the performance of obliquetree may converge closely with traditional trees. The true strength of obliquetree lies in their ability to perform exceptionally well at shallower depths, offering improved generalization with fewer splits. Moreover, thanks to linear projections, obliquetree significantly outperform traditional trees when working with datasets that exhibit linear relationships.


Installation

To install obliquetree, use the following pip command:

pip install obliquetree

Using the obliquetree library is simple and intuitive. Here's a more generic example that works for both classification and regression:

from obliquetree import Classifier, Regressor

# Initialize the model (Classifier or Regressor)
model = Classifier(  # Replace "Classifier" with "Regressor" if performing regression
    use_oblique=True,       # Enable oblique splits
    max_depth=2,            # Set the maximum depth of the tree
    n_pair=2,               # Number of feature pairs for optimization
    random_state=42,        # Set a random state for reproducibility
    categories=[0, 10, 32], # Specify which features are categorical
)

# Train the model on the training dataset
model.fit(X_train, y_train)

# Predict on the test dataset
y_pred = model.predict(X_test)

Documentation

For example usage, API details, comparisons with axis-aligned trees, and in-depth insights into the algorithmic foundation, we strongly recommend referring to the full documentation.


Key Features

  • Oblique Splits
    Perform oblique splits using linear combinations of features to capture complex patterns in data. Supports both linear and soft decision tree objectives for flexible and accurate modeling.

  • Axis-Aligned Splits
    Offers conventional (axis-aligned) splits, enabling users to leverage standard decision tree behavior for simplicity and interpretability.

  • Feature Constraints
    Limit the number of features used in oblique splits with the n_pair parameter, promoting simpler, more interpretable tree structures while retaining predictive power.

  • Seamless Categorical Feature Handling
    Natively supports categorical columns with minimal preprocessing. Only label encoding is required, removing the need for extensive data transformation.

  • Robust Handling of Missing Values
    Automatically assigns NaN values to the optimal leaf for axis-aligned splits.

  • Customizable Tree Structures
    The flexible API empowers users to design their own tree architectures easily.

  • Exact Equivalence with scikit-learn
    Guarantees results identical to scikit-learn's decision trees when oblique and categorical splitting are disabled.

  • Parallel Split Search Utilizes OpenMP-based parallelism during tree construction to evaluate splits in parallel across features, enabling significant speedups on multi-core systems.

  • Optimized Performance Outperforms scikit-learn in terms of speed and efficiency when oblique and categorical splitting are disabled:

    • Up to 600% faster for datasets with float columns.
    • Up to 400% faster for datasets with integer columns.

    Performance Comparison (Float)

    Performance Comparison (Integer)


Contributing

Contributions are welcome! If you'd like to improve obliquetree or suggest new features, feel free to fork the repository and submit a pull request.


License

obliquetree is released under the MIT License. See the LICENSE file for more details.

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.

obliquetree-1.1.0-cp313-cp313-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.13Windows x86-64

obliquetree-1.1.0-cp313-cp313-musllinux_1_2_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

obliquetree-1.1.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (4.6 MB view details)

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

obliquetree-1.1.0-cp313-cp313-macosx_15_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

obliquetree-1.1.0-cp312-cp312-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.12Windows x86-64

obliquetree-1.1.0-cp312-cp312-musllinux_1_2_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

obliquetree-1.1.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (4.6 MB view details)

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

obliquetree-1.1.0-cp312-cp312-macosx_15_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

obliquetree-1.1.0-cp311-cp311-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.11Windows x86-64

obliquetree-1.1.0-cp311-cp311-musllinux_1_2_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

obliquetree-1.1.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (4.7 MB view details)

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

obliquetree-1.1.0-cp311-cp311-macosx_15_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

obliquetree-1.1.0-cp310-cp310-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.10Windows x86-64

obliquetree-1.1.0-cp310-cp310-musllinux_1_2_x86_64.whl (5.6 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

obliquetree-1.1.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (4.5 MB view details)

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

obliquetree-1.1.0-cp310-cp310-macosx_15_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

Details for the file obliquetree-1.1.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for obliquetree-1.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 6abe64f9453e20c11073e3f7a067dc7ad4a741881d0d2deefd832f313e03b654
MD5 7d59238d3677f3ea9f85564c12077d1e
BLAKE2b-256 cf44b221d4cc3f65b4b1378b55ae6b44876ac9d055743cacbe44baefa80481d9

See more details on using hashes here.

File details

Details for the file obliquetree-1.1.0-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for obliquetree-1.1.0-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6682b89fa61fbf417f13ca51c11e96d2de5ede3159d8bde4df48582d76f468c8
MD5 1fd6caaba5c138cbf21828e3844e81c0
BLAKE2b-256 541b542c365f07d6592434591ee380fc4902b8212ebcda68cf4e2e4273533c42

See more details on using hashes here.

File details

Details for the file obliquetree-1.1.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for obliquetree-1.1.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8d25911a2695c597d5008c82271e8daae087139b9fbf4d424aeee7f2f78c38cc
MD5 524f9782a1d25a156c57563908d50d2a
BLAKE2b-256 b2a59d6d78a45bcf33d04511b92ae5402305eb235d4c71add04d208b43bd6984

See more details on using hashes here.

File details

Details for the file obliquetree-1.1.0-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for obliquetree-1.1.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 8b741328cc9a01926a90569be6951cfe902dff4973c1fb2c0986efdfad438a46
MD5 3ee9c710b8cf267c0500b51eb6b87a24
BLAKE2b-256 19607a1b1c87ec29ea8fc81ffd4d3fa9d88df27e02bf732bd0ee857e5e53afd8

See more details on using hashes here.

File details

Details for the file obliquetree-1.1.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for obliquetree-1.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8cfcd00c308d3aedaafafaec21bb9e3b37d78b85217691f83a44f3b4332a3e87
MD5 231a498b8626c16e69c9f6f6cef1dd37
BLAKE2b-256 5a859e4e0b92f563afeab6122f1cb674f3b7a2a2b07a578b3d3424386d8b9006

See more details on using hashes here.

File details

Details for the file obliquetree-1.1.0-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for obliquetree-1.1.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9e25b049db3b7c54ac1c37d566019fec9c2bbcaad3c68600da20811b65224ad4
MD5 0774d42eef4906b3a9d17a453d1973d7
BLAKE2b-256 cf654cf62155526b54d6fcc937cffe3c42694273aa3d26fbc3c7c2b51dadfbaa

See more details on using hashes here.

File details

Details for the file obliquetree-1.1.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for obliquetree-1.1.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5b32c8a15f269164f94e90b6efd0cbecb272661dbfca92f4243515df8b02b676
MD5 5a1836c1d0ce814cddd2519755fb714f
BLAKE2b-256 e067dbba9fe49af89ab81c17d024dd9d3baad22632ad9724367d548a166630e5

See more details on using hashes here.

File details

Details for the file obliquetree-1.1.0-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for obliquetree-1.1.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 cfa5e2fee1d2c0a8669db744850461515f985be611ae8961fa1940980a020f14
MD5 bf87569c6c2a2162d65c61ef700daca2
BLAKE2b-256 2896f79adca5d8451c12f90340226e61ecc66fe2e8afba1e761b31882fed6bc1

See more details on using hashes here.

File details

Details for the file obliquetree-1.1.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for obliquetree-1.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c007e2d92106cd3672e5c17acae78d80aaa1027b3cf623fdd10d1c0db718be16
MD5 6e75b8a869fce4a6f7a9ea9183ae2c70
BLAKE2b-256 3389f7b5d8b5c9e3241ea8a9a8ed8fbf8822993860ec5c4449424eb03fc44616

See more details on using hashes here.

File details

Details for the file obliquetree-1.1.0-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for obliquetree-1.1.0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2e40eb2a561f3d44b8c393944ee8e4c5c7bad1a8ec7eb493b6b3d58ffbadbe3a
MD5 5d64c57eb614a1b65a150653080c1823
BLAKE2b-256 2b496684a26cb5aed1a48127d6ae9a18cb36dd5c5a625f0b5d87b0c0e197d5fb

See more details on using hashes here.

File details

Details for the file obliquetree-1.1.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for obliquetree-1.1.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dd129a4a082df27ff3d9950c5cdc52ffcb3b8eccf2d673f9a11ea26079cbb389
MD5 4c3f54619fe3516acd29a9b9d34ffdc6
BLAKE2b-256 f9bfae218faac03e9c556cedaf2fe73533e765d0bf684147a5518a4fdeb1b9c6

See more details on using hashes here.

File details

Details for the file obliquetree-1.1.0-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for obliquetree-1.1.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 72232fa442a09173d6e6141a6ba2c9e68cc8dbcbc2b39f5a60ed4022d0752f04
MD5 2f4e26005d43022e6b215e586b106783
BLAKE2b-256 90136dae42ae7317c970197519ccf5b042684ded2585aa15b24d91a7f724d271

See more details on using hashes here.

File details

Details for the file obliquetree-1.1.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for obliquetree-1.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 fb32a5e66d6ac7e476061f16055189a793e6d9bee67136ce3d05268d8bad406a
MD5 2382268bddf2c9bdcb95eb8e11d42182
BLAKE2b-256 080bd408b361685633837f28a210057ebe0a3aa5663b0eda72bc3daf98b34c08

See more details on using hashes here.

File details

Details for the file obliquetree-1.1.0-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for obliquetree-1.1.0-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 74a175d6de95cd4188e7eeed04be06e4db5d94912965a806286af45a7bbeb1b7
MD5 67e6f4032e110ae6e5539dc1eb28db72
BLAKE2b-256 f702ab8770a83cab4fee935c439ee2511709f1b586dbc5f000f3f52c135dfafb

See more details on using hashes here.

File details

Details for the file obliquetree-1.1.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for obliquetree-1.1.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cb764f5680c94184deca44bed086b31127e5d888de55da5ceb2b531c9da6603a
MD5 3a17c632ab4888745c4750cb403a14a8
BLAKE2b-256 0d3e4aac1f3eb4bca9422ef55ca4c34bbd803c4a0b0a02773caaf8b54842fa3a

See more details on using hashes here.

File details

Details for the file obliquetree-1.1.0-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for obliquetree-1.1.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 36598cc5d3ca917cc9ea1cdb0ba7cb924a33cb0c296c196fe10d758a004ce97b
MD5 c83d7c109f25f88e40708cbaaa3eabc8
BLAKE2b-256 f6a1a18c7f9435fefe2733960405b3f89a97a80380fd9752e9712b083e512876

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