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 a custom L-BFGS optimization routine 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
    top_k=None,             # Optional: keep the default oblique feature screening heuristic
    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.1-cp313-cp313-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.13Windows x86-64

obliquetree-1.1.1-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.1-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.1-cp313-cp313-macosx_15_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

obliquetree-1.1.1-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.1-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.1-cp312-cp312-macosx_15_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

obliquetree-1.1.1-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.1-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.1-cp311-cp311-macosx_15_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

obliquetree-1.1.1-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.1-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.1-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.1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for obliquetree-1.1.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2c21ef0f7d89ac2421d56dcd354d1c269fcf8626abb88306629117b23b904dfb
MD5 15f6de8137af6761c87d3e5ca2053c93
BLAKE2b-256 fd0a6986bf63b7fa2d4b2e7e24fe353c172bf52fb3a2e102f4f315847eb035ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.1.1-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 02abbca08a09f86ad4e8fb67b3144084595249c674f3c92e8390e988d33c9982
MD5 df6a01105935e39ce5c46bf761bb1a65
BLAKE2b-256 f0327ed65e9607e75aadb18d1c0ed3103c0521aa783ed13396d706cb5c704dc3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.1.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b3615305c21819e97817d170d59b8d5790950d977864373b726c828b8567dc15
MD5 38295852bf91a3928b254cb22afbd2b8
BLAKE2b-256 4d281f676ca8fddef6a1c1577d1700015158a8bc8491f790a9a08402fdb91124

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.1.1-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ca67d2d4b21d0f399dd3f89248b0fef7b4cdd88622cf3bb0a54072877d6b2597
MD5 7065f5534bcdc9ac531677a112091840
BLAKE2b-256 5542fa17f680b930ee5a49249ed85dbc513a6189b6be749126d3e3b9bc31ed4f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2fa33fdf8739352239264c5eace7b2f1307cd08d8276a335b8f5acda9cbde2f7
MD5 d6ab0e5dc6a26292caaa1bf3f938a7af
BLAKE2b-256 7a06124d263535b124159e1c68f3f8c0b4795a04089bf449cffd3b1eec45c3c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.1.1-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2964fc4c44b61dbde9232ccbf131aaa90ddeb0e3b03f54bca65de118bb2f35dd
MD5 07c4f78bdcfe263613582df36ad3f0a8
BLAKE2b-256 d6951f54a3054d700c199165eeb3cc4cb74ebeecf09944e60e84aa9440aa349e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.1.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6d61cd3c7943b93b11e5b77cac2804c6992d6941db73ecbc521817b4a51d37a4
MD5 2911d26f288a926f9b3727ed2a74d19d
BLAKE2b-256 3cb35074eb795165188868ea476410bd147cc79ad82dd014004c35de1937c30f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.1.1-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 bb98f4faf5adf1af17dfc3347993800ac02dd4b4a8b57c593341c19d5b8be8e5
MD5 901a56e49380683c7cf9c024d0b9ad87
BLAKE2b-256 0950e3013b89a8e905333077aece6cf430ab5f28c27d389e48314129999271a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0e6db113891959065d96b7ac52b69872555d7581abd7aee33d8e6dc0da4c0380
MD5 1bc7ef2aafb0449916c3c734c767fa8a
BLAKE2b-256 41b4da5f43efddc62c70b203243aae81088bf58328ee1e13e4673b5b3bf07d98

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.1.1-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ccf2f949800097ecca0538d5f995f548707ff286b2e8b2932d6f3dc18265e0ab
MD5 511613a4ec6180219a19e979fbec9cdf
BLAKE2b-256 d338822315933aee8a17d45234fc5d03308f526fe15c2917a36f6b95b5915d20

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.1.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 02ef7486327a61e075a8ea7536fc8c5a2aff447370bb2581f1a380f37aa0bab9
MD5 121bbbf6b01e67b629b21bf6c155710e
BLAKE2b-256 a63ac01b0dfa2798349ff20a547907e8d82304b8c718082c60d1d66cbb01b79b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.1.1-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1c9ea72331b658f39f15a2cccebdef1317892fcab12f7ca3e16cc7151036d5a2
MD5 6c696c2aec6fb7c79c16f07eab41bc20
BLAKE2b-256 c16149419bfbf379eefb34e134fcad358cb1805a85ce4fbf3ade5b5de3977b87

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.1.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3b9849bd9af5f6ddc165e495cc351d99f742a6d85a3e387f29363c00b16b73e8
MD5 7293b6ddcaeca7737d6c7fd3fe5639b3
BLAKE2b-256 63837769516a6d0b8edd92cb985c16f0f9b535378f3d1dece4a5500817152e08

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.1.1-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d4653bfdc5196dc5cc5022fa6cd44e85a66fd6712b245282fea38d8a920160e5
MD5 c0c52efc98050c3a818ff60537548a45
BLAKE2b-256 d15d3563e9d4a5552e64fe9b4914cefddb7892b48e35cf2aafc626dce5f03022

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.1.1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1e3d9ab847f48b586ad3d6f6e77113408674fc571eb65f2ecf4c109d90157311
MD5 b0ca492bf1b48a4e675309c595af9579
BLAKE2b-256 5d206765a4ff1d7455b234f022b8f661c1294cf2de8953fbad1e0dc80d3a371e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.1.1-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 66326ff3e82b2d4e4c8ee969156769da61b2dca4cbcc6f4949cca0dd911e8986
MD5 08098014d08d85047a28cc2f8e3002d1
BLAKE2b-256 6a15bb459c7494cb58eadaf5286629dbeb8f5543ea9dd66c372143e46b529002

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