Decision Boundary Visualization for PyTorch Models
Project description
dbViz — Decision Boundary Visualizer
Minimal install and quickstart to plot decision boundaries for PyTorch models.
Installation
uv sync
Quickstart
A tiny example that selects three samples, builds a plane loader, and plots decision boundaries:
import torch
import torchvision
import torchvision.transforms as transforms
from dbviz.utils import get_random_samples, make_plane_loader
from dbviz.plot import plot_decision_boundaries
import matplotlib.pyplot as plt
# 1. Load a dataset
transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010))])
testset = torchvision.datasets.CIFAR10(root='./data', train=False, download=True, transform=transform)
classes = ('plane', 'car', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck')
# 2. Load a model (using an untrained model for this example)
model = torchvision.models.resnet18(weights=None, num_classes=10)
model.eval()
# 3. Pick three samples from your dataset
cifar10_samples, cifar10_labels = get_random_samples(testset)
# 4. Build a plane loader
plane_loader = make_plane_loader(cifar10_samples, batch_size=256, plane_size=500)
# 5. Plot and save
fig = plot_decision_boundaries(model, cifar10_labels, plane_loader, num_classes=len(classes), plane_size=500)
fig.savefig('decision_boundaries_cifar10.png')
plt.show()
Acknowledgement
This package is inspired by:
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 Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dbviz-0.1.0.tar.gz.
File metadata
- Download URL: dbviz-0.1.0.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32af60eeac77a2c7d2da7b0ed84ecb90caf6c80fb497dcebc8b69fe8bc339b38
|
|
| MD5 |
3b37d4993dfcc9402f786806096c5f84
|
|
| BLAKE2b-256 |
12bfde10e531719a9dae3bb6b10b9c4278dbc9c28643755ef2aedf379106bfba
|
Provenance
The following attestation bundles were made for dbviz-0.1.0.tar.gz:
Publisher:
publish.yml on datthinh1801/dbViz
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dbviz-0.1.0.tar.gz -
Subject digest:
32af60eeac77a2c7d2da7b0ed84ecb90caf6c80fb497dcebc8b69fe8bc339b38 - Sigstore transparency entry: 529749226
- Sigstore integration time:
-
Permalink:
datthinh1801/dbViz@9c10c7da55df669ec289f9320ea6a5b6275e70af -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/datthinh1801
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9c10c7da55df669ec289f9320ea6a5b6275e70af -
Trigger Event:
release
-
Statement type:
File details
Details for the file dbviz-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dbviz-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12f6b965969acc435b74aca3293454258384978ea713210989e1d38424097414
|
|
| MD5 |
4a724fe5f781914fa142b224e368c859
|
|
| BLAKE2b-256 |
7224a9536a315dc4c5c2354367be1a2c56eb408ec2f51f006a95f7a421811563
|
Provenance
The following attestation bundles were made for dbviz-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on datthinh1801/dbViz
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dbviz-0.1.0-py3-none-any.whl -
Subject digest:
12f6b965969acc435b74aca3293454258384978ea713210989e1d38424097414 - Sigstore transparency entry: 529749246
- Sigstore integration time:
-
Permalink:
datthinh1801/dbViz@9c10c7da55df669ec289f9320ea6a5b6275e70af -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/datthinh1801
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9c10c7da55df669ec289f9320ea6a5b6275e70af -
Trigger Event:
release
-
Statement type: