Skip to main content

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


Download files

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

Source Distribution

dbviz-0.1.3.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

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

dbviz-0.1.3-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file dbviz-0.1.3.tar.gz.

File metadata

  • Download URL: dbviz-0.1.3.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

Hashes for dbviz-0.1.3.tar.gz
Algorithm Hash digest
SHA256 0896b00dce15b873299966f49df75b11dbfe6491c6f3076bacecc0e18cccfa6c
MD5 a3f8e19300cab6c153eb620ec45cc852
BLAKE2b-256 272d0a3029249cdc95befb029e032113afc977d77b3e8711e1fdb44ca16d7152

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbviz-0.1.3.tar.gz:

Publisher: publish.yml on datthinh1801/dbViz

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

File details

Details for the file dbviz-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: dbviz-0.1.3-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

Hashes for dbviz-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 babf37ec32da60d50644d25ed18c4a7409712bf9858a077db199a7aa43c28686
MD5 8d92501cbb77f1009b493096c5226c56
BLAKE2b-256 4ac7a6961e0f30daabf00288fed35e9146490aa4acd960ba11949ca70631b1de

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbviz-0.1.3-py3-none-any.whl:

Publisher: publish.yml on datthinh1801/dbViz

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