Implementation:Rapidsai Cuml UMAP Web Results
| Knowledge Sources | |
|---|---|
| Domains | Machine_Learning, Dimensionality_Reduction |
| Last Updated | 2026-02-08 12:00 GMT |
Overview
A Python module that generates an interactive HTML web report with Plotly visualizations for comparing UMAP embedding quality across datasets and implementations.
Description
web_results_generation.py produces a self-contained HTML report that visualizes UMAP embedding results. The report features interactive Plotly charts, a summary metrics table, and toggle controls for switching between reference and cuML implementations.
The module provides two main functions:
create_plotly_plots(datasets, embeddings, all_metrics, spectral_inits) -- Creates the visualization figures and returns three outputs:
main_html-- A list of HTML divs containing the 4-panel figure for each dataset: (1) original data plot (2D scatter or 3D scatter via PCA if >3 features), (2) UMAP embedding scatter, (3) quality metrics table, and (4) persistence diagram showing H0/H1 topological features.spectral_html-- A list of HTML divs for spectral initialization scatter plots.comparison_data-- A data structure tracking which datasets have both reference and cuML implementations.
For datasets with both implementations, the function generates two complete sets of plots and wraps them in containers with CSS toggle switches. The toggle UI uses a styled checkbox that switches between "Reference" (purple) and "cuML" (green) views, controlling both the main 4-panel figure and the spectral initialization plot.
generate_web_report(datasets, embeddings, all_metrics, spectral_inits) -- Generates the complete HTML document including:
- A gradient header with title and generation timestamp.
- A summary table with all metrics across all datasets and implementations, showing trustworthiness, continuity, geodesic correlations, DEMaP, fuzzy KL divergences, and cross-implementation comparison metrics.
- Individual dataset sections with hover-triggered spectral initialization popups.
- JavaScript for implementation toggle functionality (show/hide containers and resize Plotly plots after visibility changes).
- CSS for toggle switch styling, layout, and spectral bubble popups.
The Plotly.js library is loaded from CDN. For high-dimensional datasets (>3 features), PCA is applied to project to 3D for the original data visualization, with appropriate labeling.
Usage
This module is called by run_umap_debug.py when the --web-report flag is specified. The generated HTML file can be opened in any modern web browser for interactive exploration of UMAP embedding quality.
Code Reference
Source Location
- Repository: Rapidsai_Cuml
- File:
python/cuml/umap_dev_tools/web_results_generation.py
Signature
def create_plotly_plots(datasets, embeddings, all_metrics, spectral_inits):
"""
Returns: (main_html: list[str], spectral_html: list[str], comparison_data: dict)
"""
def generate_web_report(datasets, embeddings, all_metrics, spectral_inits):
"""
Returns: html: str (complete HTML document)
"""
Import
from web_results_generation import generate_web_report
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| datasets | dict | Yes | Mapping of dataset name to (X, colors) tuples, where X is the input data array and colors is a label/color array for visualization |
| embeddings | dict | Yes | Mapping of dataset name to embedding array or dict with "reference"/"cuml" keys |
| all_metrics | dict | Yes | Mapping of dataset name to metrics dict or dict with "reference"/"cuml" keys |
| spectral_inits | dict | Yes | Mapping of dataset name to spectral initialization array or dict with "reference"/"cuml" keys |
Outputs
| Name | Type | Description |
|---|---|---|
| html | str | Complete self-contained HTML document with embedded Plotly visualizations, CSS styling, and JavaScript toggle functionality |
Usage Examples
from web_results_generation import generate_web_report
# Example: Generate a web report with comparison data
datasets = {
"swiss_roll": (X_swiss, colors_swiss),
"blobs": (X_blobs, colors_blobs),
}
embeddings = {
"swiss_roll": {
"reference": ref_embedding_swiss,
"cuml": cuml_embedding_swiss,
},
"blobs": {
"reference": ref_embedding_blobs,
"cuml": cuml_embedding_blobs,
},
}
all_metrics = {
"swiss_roll": {
"reference": ref_metrics_swiss,
"cuml": cuml_metrics_swiss,
},
"blobs": {
"reference": ref_metrics_blobs,
"cuml": cuml_metrics_blobs,
},
}
spectral_inits = {
"swiss_roll": {
"reference": ref_spectral_swiss,
"cuml": cuml_spectral_swiss,
},
"blobs": {
"reference": ref_spectral_blobs,
"cuml": cuml_spectral_blobs,
},
}
html_content = generate_web_report(datasets, embeddings, all_metrics, spectral_inits)
with open("umap_quality_assessment_results.html", "w") as f:
f.write(html_content)