Skip to main content

Diorama

Interactive 2D/3D embedding visualization for JSON documents.

Diorama takes high-dimensional embeddings and a list of JSON documents, runs dimensionality reduction, and produces interactive Plotly scatter plots. Color points by any field in your documents, filter with MongoDB query syntax, and switch between perspectives via dropdown.

Install

pip install diorama[umap]        # core + UMAP (recommended)
pip install diorama[all]         # core + UMAP + T-SNE + Dash app

Quick start

import numpy as np
import diorama

# Load your data
documents = [{"city": "Sydney", "score": 4.2, "category": "A"}, ...]
embeddings = np.load("embeddings.npy")  # (N, D) array

# Reduce and visualize in one call
fig = diorama.show(embeddings, documents, color_by="category")

Reduce once, explore fast

UMAP is the expensive step. Run it once and reuse the result:

reduced = diorama.reduce(embeddings, n_components=2, show_progress=True)

# Fast iterations — only filtering + plotting
diorama.show(reduced, documents, color_by="city")
diorama.show(reduced, documents, color_by="score")
diorama.show(reduced, documents, filter={"score": {"$gt": 3.0}})

Positions are stable across calls — the same document always appears at the same coordinates.

Large datasets

For 100K+ points, fit UMAP on a subset and transform the rest:

reduced = diorama.reduce(
    embeddings, n_components=2,
    subsample=10_000, show_progress=True,
)

Coloring

Pass a single field, a list of fields (creates a dropdown), or None to auto-discover:

# single field
diorama.show(reduced, documents, color_by="category")

# dropdown
diorama.show(reduced, documents, color_by=["category", "city", "score"])

# auto-discover top 15
diorama.show(reduced, documents)

Numeric fields with many unique values are colored continuously. Low-cardinality numerics, strings, and booleans are categorical. Override with:

diorama.show(
    reduced, documents,
    color_by="score",
    color_type_overrides={"score": "categorical"},
)

Filtering

Filter documents using MongoDB query syntax:

diorama.show(reduced, documents,
             filter={"score": {"$gte": 4.0}, "city": "Sydney"})

diorama.show(reduced, documents,
             filter={"$or": [{"city": "Sydney"}, {"city": "Melbourne"}]})

diorama.show(reduced, documents,
             filter={"name": {"$regex": "^A"}})

Supported operators: $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $exists, $regex, $and, $or, $not, $nor.

3D

reduced_3d = diorama.reduce(embeddings, n_components=3)
diorama.show(reduced_3d, documents, color_by="category")

Dash app

Launch an interactive web UI with a field dropdown, filter text input, and 2D/3D toggle:

diorama.app(embeddings, documents, subsample=10_000)
# Opens at http://127.0.0.1:8050

Requires the dash extra: pip install diorama[dash].

Options

diorama.show(
    embeddings,
    documents,
    color_by="field.path",          # dot notation for nested fields
    filter={"age": {"$gt": 20}},    # MongoDB-style filter
    n_components=2,                  # 2 or 3
    method="umap",                   # "umap" or "tsne"
    subsample=10_000,                # fit on subset, transform all
    color_scheme="dark",             # "light" or "dark"
    height=800,                      # figure height in pixels
    show_progress=True,              # tqdm progress bar
    output_path="plot.html",         # save to file
)

Metadata

Release files for diorama 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for diorama 0.2.0
File Size Uploaded Provenance
diorama-0.2.0.tar.gz 59.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for diorama 0.2.0
File Interpreter ABI Platform
diorama-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 74.3 kB

Release files / diorama-0.2.0.tar.gz

Download URL diorama-0.2.0.tar.gz
Size 59.4 kB
Tags Source
SHA-256 checksum
How to use checksums
62d16b956a5627c36d5aeed5e8908091e56c2809f43d3f91a7864f0a014d3e3e
BLAKE2b-256 checksum
How to use checksums
951a2d1e70c50232b619915e3918b6e74f14e080d9b12160ecc0b31c2639b1a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.11

Release files / diorama-0.2.0-py3-none-any.whl

Download URL diorama-0.2.0-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
60800a625651270c0a04014a4b2d0e4db9f6db66153bb172a480bc27019cc3a3
BLAKE2b-256 checksum
How to use checksums
cfc396bd5a32b438d17943bfbf7966a7c21f3a59c760bb0377944a2dd8b144e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.11

Security for diorama 0.2.0

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page