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.7-cp313-cp313-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

File metadata

File hashes

Hashes for obliquetree-1.0.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c238669ca8e1f798cbb023562ed5eec73dd8825a3845a739e365e3f4a2ed2e74
MD5 57a8ad68fd020172c7b473a86f55cba2
BLAKE2b-256 23d2aab74dfdcf3ba538e3ec6dd0369063f422be753b640de8f82f2c07a88a57

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.7-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3e27e181b0a4db376dfca65092df96898160759d0a523027ded436af200da03b
MD5 e6cad9835047f5044aba6c12bdf4c615
BLAKE2b-256 0f450e57f6c7314ea9702543670b4d83e7b1789b445217538bb9c3c80ff487da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.7-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f708042559ed0c043a9b3bcec6d3c7cdff77cc32075eef6f5d027597d54d23e0
MD5 725995da0a1aa5bbbd4034db86f6a31d
BLAKE2b-256 3be7f0ec7dee9a1266969bf4bcc0f561c4c52ccb253afcfcf85fb43aeb28ff71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.7-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ed31a7c02f43d8c283bdaa3ddc9cb3fb3483797b52a7d9acb232e006a61a6afb
MD5 fa206db67e7fc26796317879db3917b1
BLAKE2b-256 514573bed03dc7bc90ed66db83a62370198bbaab9c4e749c87e02db5424e37bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 dff58fb3ff6b655f5f75b2e0a57d1de1cf3f73437f79c749f2b0bd5d78942e6b
MD5 f088dbee6b059181edc8bfb6f94c80c9
BLAKE2b-256 3bd093a900de6d19882d32c5a91be0cf6d9e6447fa53088781fcac9ab9b6de15

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.7-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 fd9d774ea9c891c3a64a10f93c739157c7483baf377f291f82d1b6c60b456301
MD5 2db70edd6bb14097fb290c78124c5e53
BLAKE2b-256 10048a1a000e72bf6bd85f29e2f47959eb1128bfecdac666a4ecba45788188ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.7-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bab96980cf8c2801aba12cf5857d47594e9a0949b44426cfc4f2365e2f7cdf57
MD5 7f8906e8a898548dab0cbcf6e9bcb468
BLAKE2b-256 be6ff37d8c17095db61668607e4dbfb3d0283c86a0be3d4fdfdfedf4549456b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.7-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 0e6dbd139c8eeb5245f116807dfe7cad989c527ddb03c36cb40ba19d4deb1fa4
MD5 d935f8891ff7850a65e3da07663544a1
BLAKE2b-256 1f694af39b2ad39cf0d8839cae2bfdc9d60cd66886b95a25e9960c2c3f149347

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 55200966b1a6c002a12e39b67c3c900d016f9c0fb9e753c45cc6aad3e0e529d7
MD5 ad438ee017fb6684e432adb151944688
BLAKE2b-256 a7606743e3f70a9c3268913790d949bf4a50b326fbf66d936be05f1ffed13891

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.7-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4ba9eebe75fa9526876f820942c27e46e5286759a8c02fcba80fc2c3088ad0c5
MD5 b19bd1cbb8b8ca3cf78f2fc536e94b9d
BLAKE2b-256 88b48c28795efb312ee40c5b82a60b807497e5c873f9cadee22b108aad2d7b8d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.7-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3f2d98a2013f571606ed4c481a7b4b0ddc06553ea57272fb741126c160995d56
MD5 812b94310e37e484e5530e829389373e
BLAKE2b-256 10a7bdeec2d2f5b79a4b29662902a2cbbc30fa37d76d3b0b7f154a1b4809b3ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.7-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 74c59ce34ff0c8c8f7e3315236217dcbf5cc348469282e611a23e0422972e1fa
MD5 672391d4fd2911924e2c8121a43f3136
BLAKE2b-256 7f0133f3b4e4d6ae7a1d8316c29b04082aea3ade4dd54cec7157a3385982ca44

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 35c1f80cdef782bbe0816ed25074d83a956ff4c5927c9280938c06694074ea61
MD5 dd423c96133f62cb2c5e87c1f89d4854
BLAKE2b-256 2ffd8b4773a8b9f412ed834a98283d3ee64bf2590be0ac65a95715472895cb89

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.7-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9d4b40abc6eb259b291fb2866c862e2bce4feac374eae0f1c9300b47f9d93b1e
MD5 722eb19bb8eb0df7a97cdc354594cac0
BLAKE2b-256 31cb2c7d83fd414197851d4ea37844db8584fb4f4626e9e04c56411388d9df04

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.7-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bb63689370c8953d22c355e97f8cba4c67161aab2dd9ae2b418125c32c73023c
MD5 924b46b482b4db9bad0d902b45a105b7
BLAKE2b-256 9ace48b6dc8d38ed579f6cd0044d5be61756e71a069aded2c8b5987aeb274a94

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for obliquetree-1.0.7-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 c66e5552322abf636aefe66c4ed5ebae07bfa779cea3b14e410b658d96db27c7
MD5 1ed94361695eb7b71c7d00741d788235
BLAKE2b-256 0c1138358c5f91b03a6ed0b392e04a68d6090c0351b5ac3faaa826b388c72a06

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