Skip to main content

Radial visualization helpers for scikit-learn decision trees

Project description

radtree

CI License: MIT

radtree visualizes scikit-learn decision tree predictions as a radial graph. It is designed for quick exploratory inspection of class boundaries and prediction consistency on a sampled evaluation set.

Iris radial plot

Status

This project is maintained for exploratory decision-tree visualization workflows. Core public APIs (plot_radial, quick_fitted_tree, and package imports) are kept stable for notebook and script usage.

Installation

Local editable install (recommended for development)

python -m venv .venv
source .venv/bin/activate
python -m pip install -U pip
python -m pip install -e .

PyPI install (when published)

pip install radtree

If a PyPI release is not available yet, use editable install or GitHub source install.

Quickstart (<30 seconds)

from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier

import radtree

random_state = 42
X, y = datasets.load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.4, random_state=random_state
)

clf = DecisionTreeClassifier(random_state=random_state)
clf.fit(X_train, y_train)

fig, ax = radtree.plot_radial(
    clf,
    X=X_test,
    Y=y_test,
    smooth_d=8,
    l_alpha=0.2,
    l_width=1,
    random_state=random_state,
)

API

plot_radial

plot_radial(
    clf,
    X=None,
    Y=None,
    data=None,
    feature_cols=None,
    label_col=None,
    num_samples=100,
    levels=None,
    edges_labels=None,
    draw_labels=None,
    style="radplot",
    bbox="dark",
    cmap="pairs",
    tree_node_size=50,
    leaf_node_size=50,
    node_size=50,
    l_width=1,
    l_alpha=1,
    fig_res=72,
    save_img=False,
    img_res=300,
    png_transparent=True,
    spring=False,
    smooth_edges=False,
    smooth_d=None,
    smooth_res=50,
    random_state=None,
)

Core parameters:

  • clf: fitted DecisionTreeClassifier.
  • X/Y or data: input records and labels.
  • num_samples: number of rows to render. Use None to use all rows.
  • random_state: deterministic sampling seed.
  • smooth_d: enables spline smoothing when set.
  • save_img: saves output PNG to ./plots/.

Return value:

  • (fig, ax) matplotlib figure and axes.

Additional helpers:

  • quick_fitted_tree
  • plot_pca
  • plot_tsne
  • plot_umap (requires optional dependency umap-learn)

Performance and limits

plot_radial uses num_samples=100 by default as a safe rendering baseline. Runtime grows with sample size, and grows faster when smoothing is enabled.

Practical guidance:

  • Start with the default num_samples=100.
  • Increase to 200+ only when needed.
  • Keep smooth_d=None for faster previews.
  • Use random_state for repeatable comparisons.
  • For full-dataset runs (num_samples=None), prefer smaller evaluation subsets if rendering gets slow.

Examples

Notebooks and example datasets are available in notebooks/.

Digits radial plot Titanic radial plot

Third-party notices

Third-party dependency notices are listed in THIRD_PARTY_NOTICES.md.

Contributing

Please read CONTRIBUTING.md for local setup, quality checks, and pull request expectations.

License

MIT License (LICENSE).

Project details


Download files

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

Source Distribution

radtree-0.1.0.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

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

radtree-0.1.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file radtree-0.1.0.tar.gz.

File metadata

  • Download URL: radtree-0.1.0.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for radtree-0.1.0.tar.gz
Algorithm Hash digest
SHA256 504e231a570dbf928412c9097569dd27ada50d88bfecd0ada35a40423a8c9fc1
MD5 261e388f4ce9b4112711015c17a85d19
BLAKE2b-256 efa3d532203d4a49a9d66c1ecb8623e8debf86bccc043a1999518b8a29b094ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for radtree-0.1.0.tar.gz:

Publisher: release.yml on poctaviano/radtree

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file radtree-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: radtree-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for radtree-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5f482857d85873388419f0eacd18451e6ddb5a9dfb2464b5d1bbd8bb39458c55
MD5 473d5574ac6085b4d16402952ec9a8e3
BLAKE2b-256 87962d749b76aafec31ef6eaa422fb84b68a506d812e58d95556433d10d0f542

See more details on using hashes here.

Provenance

The following attestation bundles were made for radtree-0.1.0-py3-none-any.whl:

Publisher: release.yml on poctaviano/radtree

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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