Skip to main content

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).


Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

DecisionTreeConstraints-0.1.tar.gz (2.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

DecisionTreeConstraints-0.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

DecisionTreeConstraints-0.1-py2.py3-none-any.whl (4.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file DecisionTreeConstraints-0.1.tar.gz.

File metadata

  • Download URL: DecisionTreeConstraints-0.1.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7

File hashes

Hashes for DecisionTreeConstraints-0.1.tar.gz
Algorithm Hash digest
SHA256 64edff1c62f6aef2cb860c2ccaea4127bd43ee5f1f091b437c589e6153d40ccf
MD5 082d5dca834e4007b9d46c52f762603c
BLAKE2b-256 fe239804d5a629dfd84cb668d15db1b8ab2a42de39c9f2f8eef894c05cfd5328

See more details on using hashes here.

File details

Details for the file DecisionTreeConstraints-0.1-py3-none-any.whl.

File metadata

  • Download URL: DecisionTreeConstraints-0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7

File hashes

Hashes for DecisionTreeConstraints-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 12311edf17a177b7017cf04768fc53f394f50daca5a247f360519fe00d772445
MD5 38d9b326757642caf21d8d2e91d57cbc
BLAKE2b-256 ece47ea7722f69509ba925f8430f1cf113dceaf2e2ae64ea17794616369a8a04

See more details on using hashes here.

File details

Details for the file DecisionTreeConstraints-0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: DecisionTreeConstraints-0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7

File hashes

Hashes for DecisionTreeConstraints-0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b1bfc51dce9fbee47b7e9434253ae178a286f8e2d281779fbf23e76352a2a429
MD5 3a6489ebb25a516f38df225eaaed771b
BLAKE2b-256 d054d7715d79bb3777a06aaedb3c0c786932f8771ca735d23b0a209b05573dea

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