DrawScikitTree
A simple interface to modify scikit-learn's generated DOT string representation of a trained decision tree. Some basic function include changing the shape and color of each node, and tracing the decision paths taken for a test sample.
Installation
pip install draw-scikit-tree
Basic usage
Using the iris dataset as the classical example.
from sklearn.datasets import load_iris
from sklearn import tree
iris = load_iris()
X, y = iris.data, iris.target
clf = tree.DecisionTreeClassifier()
clf = clf.fit(X, y)
Next, use the trained classifier to initialize the TreeGraph object.
from DrawScikitTree import TreeGraph
treeGraph = TreeGraph(clf, impurity=False, label="none", fontname="Arial")
To trace the decisions paths taken for some test samples, use the .trace_paths(X_sample) function.
import numpy as np
import graphviz
# Get some random samples
random_indices = np.random.randint(X.shape[0], size=5)
X_sample = X[random_indices, :]
# Setting verbose=True will print out the decision paths for each sample
treeGraph.trace_paths(X_sample, color="red", verbose=True)
# Displaying the newly modified tree
new_dot_data = treeGraph.export()
graph = graphviz.Source(new_dot_data)
display(graph)
For more examples check out the examples.
Metadata
Release files for draw-scikit-tree 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| draw_scikit_tree-0.1.5.tar.gz | 255.2 kB | Without provenance | Details for draw_scikit_tree-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| draw_scikit_tree-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for draw_scikit_tree-0.1.5-py3-none-any.whl |
Total release size: 264.1 kB
Release files / draw_scikit_tree-0.1.5.tar.gz
| Download URL | draw_scikit_tree-0.1.5.tar.gz |
|---|---|
| Size | 255.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f43fb772964a1267fc1177f9b1e48c5f7f99ec8e6efd555cfb677f82b162ae6
|
|
BLAKE2b-256 checksum How to use checksums |
6db4cc03ed24b45e3a992a57696c14e42dff7c2453e052fdc1add477d013e40d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.7.13
|
Release files / draw_scikit_tree-0.1.5-py3-none-any.whl
| Download URL | draw_scikit_tree-0.1.5-py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b106068525264241c87ec09bdcdd1bade0470ddb2bf19e8c59f238dc7c7c193f
|
|
BLAKE2b-256 checksum How to use checksums |
7c6e21f0395696ab91c0e52446b9c2efc1d2fe9fdf3823e9fbdeed0342f29595
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.7.13
|
Security for draw-scikit-tree 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.