Building Decision Trees with Constraints
Project description
# Decision Tree Constraints
This is a sample code of the `PruneToSizeK` method for sklearn [Decision Tree Classifier](https://scikit-learn.org/stable/modules/tree.html).
Usage:
```
from sklearn.datasets import load_iris
from sklearn import tree
from DecisionTreeConstraints import SizeConstraintPruning
iris = load_iris()
clf = tree.DecisionTreeClassifier()
clf = clf.fit(iris.data, iris.target)
MAX_SIZE=6
SizeConstraintPruning(MAX_SIZE).pruneToSizeK(clf)
accuracy = clf.score(iris.data, iris.target)
print('Training accuracy for max size %s: %.3f' % (MAX_SIZE, accuracy))
```
Garofalakis, M., Hyun, D., Rastogi, R. et al. Data Mining and Knowledge Discovery (2003) 7: 187. [doi:10.1023](https://doi.org/10.1023/A:1022445500761).
This is a sample code of the `PruneToSizeK` method for sklearn [Decision Tree Classifier](https://scikit-learn.org/stable/modules/tree.html).
Usage:
```
from sklearn.datasets import load_iris
from sklearn import tree
from DecisionTreeConstraints import SizeConstraintPruning
iris = load_iris()
clf = tree.DecisionTreeClassifier()
clf = clf.fit(iris.data, iris.target)
MAX_SIZE=6
SizeConstraintPruning(MAX_SIZE).pruneToSizeK(clf)
accuracy = clf.score(iris.data, iris.target)
print('Training accuracy for max size %s: %.3f' % (MAX_SIZE, accuracy))
```
Garofalakis, M., Hyun, D., Rastogi, R. et al. Data Mining and Knowledge Discovery (2003) 7: 187. [doi:10.1023](https://doi.org/10.1023/A:1022445500761).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Close
Hashes for DecisionTreeConstraints-0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64edff1c62f6aef2cb860c2ccaea4127bd43ee5f1f091b437c589e6153d40ccf |
|
MD5 | 082d5dca834e4007b9d46c52f762603c |
|
BLAKE2b-256 | fe239804d5a629dfd84cb668d15db1b8ab2a42de39c9f2f8eef894c05cfd5328 |
Close
Hashes for DecisionTreeConstraints-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12311edf17a177b7017cf04768fc53f394f50daca5a247f360519fe00d772445 |
|
MD5 | 38d9b326757642caf21d8d2e91d57cbc |
|
BLAKE2b-256 | ece47ea7722f69509ba925f8430f1cf113dceaf2e2ae64ea17794616369a8a04 |
Close
Hashes for DecisionTreeConstraints-0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1bfc51dce9fbee47b7e9434253ae178a286f8e2d281779fbf23e76352a2a429 |
|
MD5 | 3a6489ebb25a516f38df225eaaed771b |
|
BLAKE2b-256 | d054d7715d79bb3777a06aaedb3c0c786932f8771ca735d23b0a209b05573dea |