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.

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

    • Up to 50% faster for datasets with float columns.
    • Up to 200% 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.0.6-cp313-cp313-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

obliquetree-1.0.6-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.0.6-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.0.6-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for obliquetree-1.0.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 6f9dc58f3c62c934e42fc3508a2a382019e4d4364de919e39e4cf4a7c899d251
MD5 df8cafe3570f272cff8c68283c0e5e70
BLAKE2b-256 4caee3733bd2f41061bd3aa6e9a4512e0090f57924c6a08257efa89faaa19911

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.6-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9594981332765b0f5777ef57c0991f7b0fe6151621a84b6017df424a0fcbd32b
MD5 30bb73279899d275de8217461745a046
BLAKE2b-256 04b74af3eac50cbcc1617b714535dac126f1dff80ab57223d9ef10e31812afe6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.6-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 748169eff09feabace420159f1d4f654d6e0a611dbd9e717954d0936e361021e
MD5 81bfb4dde9cfb2ffb7e892bcc4abc274
BLAKE2b-256 fddf34efcceb1c83c809032bfd0ab102009c6e8d1c13879de67e9f4d2337aa69

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.6-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 99fea34968f8d453b6e98ef3c800e41782a13c92bff1d6e3272eb168bd038cf9
MD5 8258b8fb6e2dceee2f02a8bda0ade690
BLAKE2b-256 2ca1d5907fcf137805c255600f8eb37b213e0d43ef380d47ec95e19092549441

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0875482554ec8f1f18a6fa82ac188b4a8172347649cb938ae8c9f56773c0ed88
MD5 941dda297c1ddfcd3b1381f13291332f
BLAKE2b-256 c5caf7347d5bf35ab9f1ad2b267c89871bceab4167f5fcee9d47d91e2660ac43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.6-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ec4b0f1a2e9526a332efd3a231f92b01eb67fbf038a37bb23b0f6c971e69e924
MD5 8969689f59ba6b55169a3ce9c4ac5f94
BLAKE2b-256 f54a2e91e303a80a175c8740b0d01a78105bb97d3efbc0628fddd3805dbb5d77

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.6-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 55b7874169753b6bb19eb0667e5529c258c1e6d9b57aaf55569090ec0ab2804a
MD5 58f631c3a70cfb5e3e4c8a8e0f33cb13
BLAKE2b-256 0bbf736e3e4b011bdf73cc4f6decd2c927921f259c56d95e71e4438059ca4225

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.6-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 374a1493488b2f07e2fa91cde1b01a5ffaddaafb0884749a9b7728e915db6d03
MD5 430726df4127d765cfa6b68b76a9238b
BLAKE2b-256 7b45cb6b7e69b77076f730f39af398c233328c3636e2d4156ca554871829ae5b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 75692b4933331476ce00dbd1c6ca2c1ba246733a11825060530bb322f7798316
MD5 c44971ddd6a094a408ac0c961580eec6
BLAKE2b-256 ea71b34cce284f96e0b0205b3566b57c8ab21218f0a6405a1ff2c15aecc414a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.6-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 926c932034efa3bb9557f5cea5ff67f757482c394658dcea2e9d15df5df17503
MD5 2ed685ee0e7dbd2a47d2465236ea244e
BLAKE2b-256 0ec4aea3be4c54eae9fb89d52a565a8908b74fe80fa581b937c808da6de054ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.6-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 39e17f1a06cda043a736a220561b3a3435d2a9ce8359d9f819d99ccafaad1566
MD5 784032d86dcea8dab004c5a9aab3b227
BLAKE2b-256 73e94d94e01a641bbd738ae86f00cf021661fd9bc105bc646f57d4f36237e92e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.6-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 5d4857f96034cf2ffa657ec692908720222492f3fd98eeb969c577ec05e285f6
MD5 24c4501bea8d3f7ed3fd87a23e39d50e
BLAKE2b-256 00decedad5bd98de16fe47fdcc031cd5e24adf15e9cfa42275514c74f2ae4e07

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4b9f319f219a09141075ad9eb0ebe30348b78b4e8f62ced9f51997cd6d8e40af
MD5 b4adb50f5915b331b1763cd922b7cfe3
BLAKE2b-256 ac00166056a92ed0b5d20c667f509295fe21f553a7cec9600a88a2cf30b8ebb0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.6-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b45fbd1908a482d40caae1bf471f30b809dfb54199b5b72a9d293f8a695fe411
MD5 10e9b9d4b71b17d9036c9226d12f9c64
BLAKE2b-256 770407f570375efc98085795fea28540205e01ca4d43aa2be256b993e9b5e763

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.6-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c7b242feee3013b336cc39c91759523e4d36f04b52961bed3adc67372f1e06e0
MD5 4aef5b450df9c80e4d04756ee7dc0769
BLAKE2b-256 03df87fb5ebcf1f9b0c7ca4e13863810c187e88ec339413c035399e5d4de9afb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.6-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 5d8a2a950435af40f8a9b1d10aea1d4b637d9d5cd771f40d34a6a8a7f5c582be
MD5 f5016b8f0de94da74e3e939ab68f55b8
BLAKE2b-256 9f078e707aa40588ff394645789a3514bfd594c70d14dd888dbaaf7fac73ece6

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