obliquetree 1.0.3__cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of obliquetree might be problematic. Click here for more details.
- obliquetree/__init__.py +4 -0
- obliquetree/_pywrap.py +747 -0
- obliquetree/src/__init__.py +0 -0
- obliquetree/src/base.cpp +36355 -0
- obliquetree/src/base.cpython-313-x86_64-linux-gnu.so +0 -0
- obliquetree/src/ccp.cpp +25678 -0
- obliquetree/src/ccp.cpython-313-x86_64-linux-gnu.so +0 -0
- obliquetree/src/metric.cpp +31853 -0
- obliquetree/src/metric.cpython-313-x86_64-linux-gnu.so +0 -0
- obliquetree/src/oblique.cpp +35284 -0
- obliquetree/src/oblique.cpython-313-x86_64-linux-gnu.so +0 -0
- obliquetree/src/tree.cpp +30338 -0
- obliquetree/src/tree.cpython-313-x86_64-linux-gnu.so +0 -0
- obliquetree/src/utils.cpp +32642 -0
- obliquetree/src/utils.cpython-313-x86_64-linux-gnu.so +0 -0
- obliquetree/utils.py +882 -0
- obliquetree-1.0.3.dist-info/METADATA +114 -0
- obliquetree-1.0.3.dist-info/RECORD +21 -0
- obliquetree-1.0.3.dist-info/WHEEL +6 -0
- obliquetree-1.0.3.dist-info/licenses/LICENSE +21 -0
- obliquetree-1.0.3.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: obliquetree
|
|
3
|
+
Version: 1.0.3
|
|
4
|
+
Summary: Traditional and Oblique Decision Tree
|
|
5
|
+
Author-email: Samet Copur <sametcopur@yahoo.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
Project-URL: Documentation, https://obliquetree.readthedocs.io/en/latest/
|
|
8
|
+
Project-URL: Repository, https://github.com/sametcopur/obliquetree
|
|
9
|
+
Project-URL: Tracker, https://github.com/sametcopur/obliquetree/issues
|
|
10
|
+
Keywords: python,data-science,machine-learning,machine-learning-library,explainable-ai,decision-tree,oblique-tree
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: numpy>=2.2.1
|
|
18
|
+
Requires-Dist: scipy>=1.15.0
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# obliquetree
|
|
22
|
+
|
|
23
|
+
`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.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+

|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
----
|
|
30
|
+
|
|
31
|
+
## Getting Started
|
|
32
|
+
|
|
33
|
+
`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.
|
|
34
|
+
|
|
35
|
+
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.
|
|
36
|
+
|
|
37
|
+
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.
|
|
38
|
+
|
|
39
|
+
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**.
|
|
40
|
+
|
|
41
|
+
-----
|
|
42
|
+
## Installation
|
|
43
|
+
To install `obliquetree`, use the following pip command:
|
|
44
|
+
```bash
|
|
45
|
+
pip install obliquetree
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Using the `obliquetree` library is simple and intuitive. Here's a more generic example that works for both classification and regression:
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from obliquetree import Classifier, Regressor
|
|
53
|
+
|
|
54
|
+
# Initialize the model (Classifier or Regressor)
|
|
55
|
+
model = Classifier( # Replace "Classifier" with "Regressor" if performing regression
|
|
56
|
+
use_oblique=True, # Enable oblique splits
|
|
57
|
+
max_depth=2, # Set the maximum depth of the tree
|
|
58
|
+
n_pair=2, # Number of feature pairs for optimization
|
|
59
|
+
random_state=42, # Set a random state for reproducibility
|
|
60
|
+
categories=[0, 10, 32], # Specify which features are categorical
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
# Train the model on the training dataset
|
|
64
|
+
model.fit(X_train, y_train)
|
|
65
|
+
|
|
66
|
+
# Predict on the test dataset
|
|
67
|
+
y_pred = model.predict(X_test)
|
|
68
|
+
```
|
|
69
|
+
-----
|
|
70
|
+
|
|
71
|
+
## Documentation
|
|
72
|
+
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](https://obliquetree.readthedocs.io/en/latest/).
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
## Key Features
|
|
76
|
+
|
|
77
|
+
- **Oblique Splits**
|
|
78
|
+
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.
|
|
79
|
+
|
|
80
|
+
- **Axis-Aligned Splits**
|
|
81
|
+
Offers conventional (axis-aligned) splits, enabling users to leverage standard decision tree behavior for simplicity and interpretability.
|
|
82
|
+
|
|
83
|
+
- **Feature Constraints**
|
|
84
|
+
Limit the number of features used in oblique splits with the `n_pair` parameter, promoting simpler, more interpretable tree structures while retaining predictive power.
|
|
85
|
+
|
|
86
|
+
- **Seamless Categorical Feature Handling**
|
|
87
|
+
Natively supports categorical columns with minimal preprocessing. Only label encoding is required, removing the need for extensive data transformation.
|
|
88
|
+
|
|
89
|
+
- **Robust Handling of Missing Values**
|
|
90
|
+
Automatically assigns `NaN` values to the optimal leaf for axis-aligned splits.
|
|
91
|
+
|
|
92
|
+
- **Customizable Tree Structures**
|
|
93
|
+
The flexible API empowers users to design their own tree architectures easily.
|
|
94
|
+
|
|
95
|
+
- **Exact Equivalence with `scikit-learn`**
|
|
96
|
+
Guarantees results identical to `scikit-learn`'s decision trees when oblique and categorical splitting are disabled.
|
|
97
|
+
|
|
98
|
+
- **Optimized Performance**
|
|
99
|
+
Outperforms `scikit-learn` in terms of speed and efficiency when oblique and categorical splitting are disabled:
|
|
100
|
+
- Up to **50% faster** for datasets with float columns.
|
|
101
|
+
- Up to **200% faster** for datasets with integer columns.
|
|
102
|
+
|
|
103
|
+

|
|
104
|
+
|
|
105
|
+

|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
----
|
|
109
|
+
### Contributing
|
|
110
|
+
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.
|
|
111
|
+
|
|
112
|
+
-----
|
|
113
|
+
### License
|
|
114
|
+
`obliquetree` is released under the MIT License. See the LICENSE file for more details.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
obliquetree/__init__.py,sha256=VQapTBiRrm5l9oV8X2fu3xlvvGTh1cjQ6Hh3ynpArKU,103
|
|
2
|
+
obliquetree/_pywrap.py,sha256=d6XRinPMBxNUf2UlJQkV4TOe3_zbEcM4q8j8QPcXudg,26332
|
|
3
|
+
obliquetree/utils.py,sha256=mEs3ZspxOKUm1SoS-ms0XjQQ1Ci6Ej4oQA53WEYY7VY,30267
|
|
4
|
+
obliquetree/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
obliquetree/src/base.cpp,sha256=0mEPR8pc8mrPe_HTSZMzv7aUeXNokTOKQPfxtO7tZ0U,1416211
|
|
6
|
+
obliquetree/src/base.cpython-313-x86_64-linux-gnu.so,sha256=JCicX25UOdLYv1n5ZulzG1IJ7Bamn3kJwfmknD7aeU4,2266200
|
|
7
|
+
obliquetree/src/ccp.cpp,sha256=IvjLzRDZCvwoZMdK4EuhZ81fDEsR4NLTsY5RsDilRJs,948541
|
|
8
|
+
obliquetree/src/ccp.cpython-313-x86_64-linux-gnu.so,sha256=Wq6a1NZK_Tp1GZ4KXc-yU9Fuc_AJZI_S3Y8SfNPADxU,1483800
|
|
9
|
+
obliquetree/src/metric.cpp,sha256=wknqpIl6shhqBiQs3rL9RZ5tF4csS9qeOMPvb0CECrU,1182973
|
|
10
|
+
obliquetree/src/metric.cpython-313-x86_64-linux-gnu.so,sha256=YUvB7qk7C5t4Oes3x8tTYMT1HmvYm149K7Rwmay6hHE,1787848
|
|
11
|
+
obliquetree/src/oblique.cpp,sha256=oW96ab5iDtc-rNPpoWrO6ITlKStF9bFGplrNcCnKNp4,1363790
|
|
12
|
+
obliquetree/src/oblique.cpython-313-x86_64-linux-gnu.so,sha256=0KEzXeotaEVHmuM5BUNdhUhkgTNHZmsNsWOCTyG87os,2587104
|
|
13
|
+
obliquetree/src/tree.cpp,sha256=m5f3qdD_EBM4gDfm7PkzWZC_ypjEkuA-0OkuFl0_VQ4,1130937
|
|
14
|
+
obliquetree/src/tree.cpython-313-x86_64-linux-gnu.so,sha256=osbDQbM8ggznRTEFkxJ85Fz-2Vf1j8MVnyCBGyzZBNk,1669176
|
|
15
|
+
obliquetree/src/utils.cpp,sha256=e2PqxXuhqSyRHxw4irCaaRMZhrZ2blGJQTl-LVfo5gs,1235423
|
|
16
|
+
obliquetree/src/utils.cpython-313-x86_64-linux-gnu.so,sha256=KPTT7bpS6GXlyLnMTJueBmbYkESgSBgI3fTH8elOoJg,2276888
|
|
17
|
+
obliquetree-1.0.3.dist-info/METADATA,sha256=zo1UGljAQo1gfqG3q4-X1L4A4xIUf6UUAaiRQaDlfL4,5662
|
|
18
|
+
obliquetree-1.0.3.dist-info/WHEEL,sha256=6_JqD2WUvSzhpAM5fA1Og7JrJ2ryUwUo85Dhg1Hamn0,152
|
|
19
|
+
obliquetree-1.0.3.dist-info/top_level.txt,sha256=m-5N4-iAS5MsFOdk8y1r2ya_i5rVQBgPayHBA-K26qg,12
|
|
20
|
+
obliquetree-1.0.3.dist-info/RECORD,,
|
|
21
|
+
obliquetree-1.0.3.dist-info/licenses/LICENSE,sha256=lLpW3hLh8QbaRAWXRaZ76c80HoVfUr6739D0S7ecslU,1069
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Samet Çopur
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
obliquetree
|