GitHub
deepbox/plot

ML Diagnostics, Animation & Interactive

Diagnostic plots for evaluation plus animation and interactive plotting APIs.
Diagnostics
Interactive
type AnimationFrame
export type AnimationFrame = { /** Frame index (0-based). */ readonly index: number; /** Timestamp in milliseconds from the start. */ readonly timeMs: number; /** The rendered SVG for this frame. */ readonly svg: Render…
A single animation frame.
type AnimationOptions
export type AnimationOptions = { /** Frames per second. Default: 30. */ readonly fps?: number; /** Total duration in milliseconds. Default: inferred from frames. */ readonly duration?: number; /** Whether the animation…
Options for creating an animation.
type AnimationResult
export type AnimationResult = { /** Total number of frames. */ readonly frameCount: number; /** Frames per second. */ readonly fps: number; /** Total duration in milliseconds. */ readonly durationMs: number; /** Whether…
Result of rendering an animation.
type InteractiveOptions
export type InteractiveOptions = { /** Enable pan interaction. Default: true. */ readonly pan?: boolean; /** Enable zoom interaction. Default: true. */ readonly zoom?: boolean; /** Enable tooltips on hover. Default: tru…
Options for interactive plot rendering.
type InteractiveResult
export type InteractiveResult = { /** The complete HTML document string. */ readonly html: string; /** The SVG content embedded in the HTML. */ readonly svg: string; /** Options used for rendering. */ readonly options:…
Result of rendering an interactive plot.
type TooltipDataPoint
export type TooltipDataPoint = { readonly x: number; readonly y: number; readonly label?: string; readonly series?: string; };
Data point for tooltip display.

Animation

Frame-based animation controller for Deepbox plots.

InteractivePlot

Interactive plot wrapper for Deepbox figures.

plotConfusionMatrix
export declare function plotConfusionMatrix(cm: Tensor, labels?: readonly string[], options?: PlotOptions): void;

Plot a confusion matrix as a heatmap.

plotRocCurve
export declare function plotRocCurve(fpr: Tensor, tpr: Tensor, auc?: number, options?: PlotOptions): void;

Plot a ROC curve with optional AUC annotation.

plotPrecisionRecallCurve
export declare function plotPrecisionRecallCurve(precision: Tensor, recall: Tensor, averagePrecision?: number, options?: PlotOptions): void;

Plot a precision-recall curve with optional AP annotation.

plotLearningCurve
export declare function plotLearningCurve(trainSizes: Tensor, trainScores: Tensor, valScores: Tensor, options?: PlotOptions): void;

Plot training and validation learning curves.

plotValidationCurve
export declare function plotValidationCurve(paramRange: Tensor, trainScores: Tensor, valScores: Tensor, options?: PlotOptions): void;

Plot training and validation curves.

plotDecisionBoundary
export declare function plotDecisionBoundary(X: Tensor, y: Tensor, model: { readonly predict: (x: Tensor) => Tensor; }, options?: PlotOptions): void;

Plot a classifier decision boundary on a 2D feature space.

plotResiduals
export declare function plotResiduals(yTrue: Tensor, yPred: Tensor, options?: PlotOptions): void;

Plot residuals (predicted vs.

plotFeatureImportance
export declare function plotFeatureImportance(importances: Tensor, featureNames?: readonly string[], options?: PlotOptions): void;

Plot feature importances as a horizontal bar chart.

plotElbowCurve
export declare function plotElbowCurve(kValues: Tensor, inertias: Tensor, options?: PlotOptions): void;

Plot an elbow curve for KMeans cluster selection.

plotSilhouette
export declare function plotSilhouette(kValues: Tensor, silhouetteScores: Tensor, options?: PlotOptions): void;

Plot silhouette scores for clustering evaluation.

plotCalibrationCurve
export declare function plotCalibrationCurve(fractionPositive: Tensor, meanPredicted: Tensor, options?: PlotOptions): void;

Plot a calibration curve (reliability diagram).

createAnimation
export declare function createAnimation(options?: AnimationOptions): Animation;

Create a new Animation instance.

createInteractivePlot
export declare function createInteractivePlot(fig: Figure, options?: InteractiveOptions): InteractivePlot;

Create an interactive plot from a Figure.

plot-ml.ts
import {  Animation,  createInteractivePlot,  figure,  plotCalibrationCurve,  plotFeatureImportance,} from "deepbox/plot";import { tensor } from "deepbox/ndarray";const fig = figure({ width: 640, height: 400 });plotCalibrationCurve(tensor([0.1, 0.5, 0.9]), tensor([0.2, 0.55, 0.95]));plotFeatureImportance(tensor([0.4, 0.35, 0.25]), ["latency", "score", "age"]);const animation = new Animation();const interactive = createInteractivePlot(fig);console.log(animation, interactive);