Visualization

class endgame.visualization.BaseVisualizer(*, title='', palette='tableau', width=900, height=500, theme='dark')[source]

Bases: ABC

Abstract base class for all endgame visualizers.

Parameters:
  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette name (see _palettes.py).

  • width (int, default=900) – Chart width in pixels.

  • height (int, default=500) – Chart height in pixels.

  • theme (str, default='dark') – Color theme (‘dark’ or ‘light’).

to_json()[source]

Export chart data as a JSON string.

Return type:

Text

Returns:

str – JSON representation of the chart data.

save(filepath, open_browser=False)[source]

Save the visualization as a self-contained HTML file.

Parameters:
  • filepath (str or Path) – Output file path (should end in .html).

  • open_browser (bool, default=False) – If True, open the file in the default web browser.

Return type:

Path

Returns:

Path – The absolute path to the saved file.

to_png(filepath, width=None, height=None)[source]

Export the visualization as a PNG image via headless Chrome.

Parameters:
  • filepath (str or Path) – Output file path (should end in .png).

  • width (int, optional) – Screenshot viewport width in pixels. Defaults to self.width.

  • height (int, optional) – Screenshot viewport height in pixels. Defaults to self.height.

Return type:

Path

Returns:

Path – The absolute path to the saved PNG file.

Raises:

RuntimeError – If no Chrome/Chromium binary is found on the system.

endgame.visualization.get_palette(name, n=None)[source]

Get a palette by name.

Searches categorical, sequential, and diverging palettes.

Parameters:
  • name (str) – Palette name (e.g., ‘tableau’, ‘blues’, ‘rdbu’).

  • n (int, optional) – Number of colors to return. If None, returns the full palette. If n > palette length, colors cycle.

Return type:

list[Text]

Returns:

list of str – List of hex color strings.

class endgame.visualization.TreeVisualizer(model, feature_names=None, class_names=None, tree_index=0, title=None, color_by='prediction', max_depth=None, palette='tableau')[source]

Bases: object

Interactive decision tree visualizer.

Generates self-contained HTML files with D3.js-powered interactive tree visualizations featuring: - Expandable/collapsible branches (click nodes) - Zoom in/out and pan (mouse wheel + drag) - Rich tooltips with node statistics - Color-coded nodes by prediction or impurity - Responsive layout

Parameters:
  • model (estimator) – A fitted tree model. Supports: - sklearn DecisionTreeClassifier/Regressor - sklearn ensembles (extracts individual trees) - C50Classifier / C50Ensemble - ObliqueDecisionTreeClassifier/Regressor - ObliqueRandomForestClassifier/Regressor - EvolutionaryTreeClassifier/Regressor

  • feature_names (list of str, optional) – Names for each feature. If None, uses “feature_0”, “feature_1”, etc.

  • class_names (list of str, optional) – Names for each class (classification only).

  • tree_index (int, default=0) – For ensemble models, which tree to visualize.

  • title (str, optional) – Title displayed above the visualization.

  • color_by (str, default='prediction') – How to color nodes: ‘prediction’ (class color), ‘impurity’ (heatmap), or ‘samples’ (by sample count).

  • max_depth (int, optional) – Maximum depth to display. Deeper nodes are collapsed by default.

  • palette (str, default='tableau') – Color palette: ‘tableau’, ‘viridis’, ‘pastel’, or ‘dark’.

Example

>>> from sklearn.datasets import load_iris
>>> from sklearn.tree import DecisionTreeClassifier
>>> from endgame.visualization import TreeVisualizer
>>>
>>> X, y = load_iris(return_X_y=True)
>>> clf = DecisionTreeClassifier(max_depth=4, random_state=42).fit(X, y)
>>> viz = TreeVisualizer(
...     clf,
...     feature_names=load_iris().feature_names,
...     class_names=load_iris().target_names.tolist(),
...     title="Iris Decision Tree"
... )
>>> viz.save("iris_tree.html")
to_json()[source]

Export tree data as JSON string.

Return type:

Text

save(filepath, open_browser=False)[source]

Save interactive visualization as a self-contained HTML file.

Parameters:
  • filepath (str or Path) – Output file path (should end in .html).

  • open_browser (bool, default=False) – If True, open the file in the default web browser.

Return type:

Path

Returns:

Path – The absolute path to the saved file.

class endgame.visualization.BarChartVisualizer(labels, values, *, series_names=None, orientation='vertical', sort=False, x_label='', y_label='', show_values=True, title='', palette='tableau', width=900, height=500, theme='dark')[source]

Bases: BaseVisualizer

Interactive bar chart visualizer.

Parameters:
  • labels (list of str) – Category labels.

  • values (list of float or list of list of float) – Bar values. For stacked bars, pass a list of lists where each inner list is one stack group.

  • series_names (list of str, optional) – Names for each series (stacked mode).

  • orientation (str, default='vertical') – ‘vertical’ or ‘horizontal’.

  • sort (bool, default=False) – If True, sort bars by value (descending).

  • x_label (str, optional) – X-axis label.

  • y_label (str, optional) – Y-axis label.

  • show_values (bool, default=True) – Show value labels on bars.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette name.

  • width (int, default=900) – Chart width.

  • height (int, default=500) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_importances(model, *, feature_names=None, top_n=20, **kwargs)[source]

Create a bar chart from a fitted model’s feature importances.

Parameters:
  • model (estimator) – Fitted sklearn-compatible model with feature_importances_.

  • feature_names (list of str, optional) – Feature names. If None, uses feature_names_in_ or generic names.

  • top_n (int, default=20) – Show top N features.

  • **kwargs – Additional keyword arguments passed to the constructor.

Return type:

BarChartVisualizer

classmethod from_dict(data, **kwargs)[source]

Create a bar chart from a dictionary.

Parameters:
  • data (dict) – Mapping of label → value.

  • **kwargs – Additional keyword arguments passed to the constructor.

Return type:

BarChartVisualizer

class endgame.visualization.HeatmapVisualizer(data, *, x_labels=None, y_labels=None, annotate=True, fmt='.2f', vmin=None, vmax=None, cmap='rdbu', title='', width=700, height=600, theme='dark')[source]

Bases: BaseVisualizer

Interactive heatmap visualizer.

Parameters:
  • data (array-like, shape (n_rows, n_cols)) – 2D data matrix.

  • x_labels (list of str, optional) – Column labels.

  • y_labels (list of str, optional) – Row labels.

  • annotate (bool, default=True) – Show cell values.

  • fmt (str, default='.2f') – Format string for annotations.

  • vmin (float, optional) – Color scale range. Auto-computed if None.

  • vmax (float, optional) – Color scale range. Auto-computed if None.

  • cmap (str, default='rdbu') – Color palette for the heatmap (diverging palettes work best).

  • title (str, optional) – Chart title.

  • width (int, default=700) – Chart width.

  • height (int, default=600) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_correlation(X, *, feature_names=None, method='pearson', **kwargs)[source]

Create a heatmap from a correlation matrix.

Parameters:
  • X (array-like or DataFrame) – Data to compute correlations from.

  • feature_names (list of str, optional) – Feature names.

  • method (str, default='pearson') – Correlation method (only used if X is a pandas DataFrame).

  • **kwargs – Additional keyword arguments passed to the constructor.

Return type:

HeatmapVisualizer

class endgame.visualization.ConfusionMatrixVisualizer(matrix, *, class_names=None, normalize=False, title='', cmap='blues', width=650, height=600, theme='dark')[source]

Bases: BaseVisualizer

Interactive confusion matrix visualizer.

Parameters:
  • matrix (array-like, shape (n_classes, n_classes)) – Confusion matrix (rows = true, columns = predicted).

  • class_names (list of str, optional) – Class label names.

  • normalize (bool, default=False) – If True, show row-normalized values (recall per class).

  • title (str, optional) – Chart title.

  • cmap (str, default='blues') – Color palette for the matrix cells.

  • width (int, default=650) – Chart width.

  • height (int, default=600) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_estimator(model, X, y, *, class_names=None, **kwargs)[source]

Create a confusion matrix from a fitted classifier.

Parameters:
  • model (estimator) – Fitted sklearn-compatible classifier.

  • X (array-like) – Features.

  • y (array-like) – True labels.

  • class_names (list of str, optional) – Class names.

  • **kwargs – Additional keyword arguments passed to the constructor.

Return type:

ConfusionMatrixVisualizer

classmethod from_predictions(y_true, y_pred, *, class_names=None, **kwargs)[source]

Create a confusion matrix from predictions.

Parameters:
  • y_true (array-like) – True labels.

  • y_pred (array-like) – Predicted labels.

  • class_names (list of str, optional) – Class names.

  • **kwargs – Additional keyword arguments.

Return type:

ConfusionMatrixVisualizer

class endgame.visualization.HistogramVisualizer(data, *, series_names=None, bins='auto', density=False, kde=False, cumulative=False, x_label='', y_label='', title='', palette='tableau', width=900, height=500, theme='dark')[source]

Bases: BaseVisualizer

Interactive histogram visualizer.

Parameters:
  • data (array-like or list of array-like) – Data values. Pass multiple arrays for overlaid histograms.

  • series_names (list of str, optional) – Names for each series.

  • bins (int or str, default='auto') – Number of bins or ‘auto’ (Freedman-Diaconis rule).

  • density (bool, default=False) – If True, show density instead of counts.

  • kde (bool, default=False) – If True, overlay KDE curve.

  • cumulative (bool, default=False) – If True, show cumulative histogram.

  • x_label (str, optional) – X-axis label.

  • y_label (str, optional) – Y-axis label.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette name.

  • width (int, default=900) – Chart width.

  • height (int, default=500) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_residuals(y_true, y_pred, **kwargs)[source]

Create a histogram of residuals.

Parameters:
  • y_true (array-like) – True values.

  • y_pred (array-like) – Predicted values.

  • **kwargs – Additional keyword arguments.

Return type:

HistogramVisualizer

classmethod from_predictions(y_proba, **kwargs)[source]

Create a histogram of prediction probabilities.

Parameters:
  • y_proba (array-like) – Predicted probabilities.

  • **kwargs – Additional keyword arguments.

Return type:

HistogramVisualizer

class endgame.visualization.LineChartVisualizer(x, series, *, error_bands=None, area=False, markers=True, x_label='', y_label='', title='', palette='tableau', width=900, height=500, theme='dark')[source]

Bases: BaseVisualizer

Interactive line chart visualizer.

Parameters:
  • x (list of float or list of str) – X-axis values (shared across series).

  • series (dict of str → list of float) – Mapping of series name to Y values.

  • error_bands (dict of str → (list of float, list of float), optional) – Mapping of series name to (lower, upper) error bands.

  • area (bool, default=False) – If True, fill area under each line.

  • markers (bool, default=True) – Show data point markers.

  • x_label (str, optional) – X-axis label.

  • y_label (str, optional) – Y-axis label.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette name.

  • width (int, default=900) – Chart width.

  • height (int, default=500) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_learning_curve(train_sizes, train_scores, test_scores, **kwargs)[source]

Create a learning curve plot.

Parameters:
  • train_sizes (array-like) – Training set sizes.

  • train_scores (array-like, shape (n_sizes,) or (n_sizes, n_folds)) – Training scores.

  • test_scores (array-like, shape (n_sizes,) or (n_sizes, n_folds)) – Test/validation scores.

  • **kwargs – Additional keyword arguments.

Return type:

LineChartVisualizer

classmethod from_cv_scores(scores, **kwargs)[source]

Create a line chart from cross-validation scores.

Parameters:
  • scores (dict of str → list of float) – Mapping of model name to fold scores.

  • **kwargs – Additional keyword arguments.

Return type:

LineChartVisualizer

class endgame.visualization.ScatterplotVisualizer(x, y, *, labels=None, sizes=None, colors=None, point_labels=None, x_label='', y_label='', show_diagonal=False, show_regression=False, title='', palette='tableau', width=700, height=600, theme='dark')[source]

Bases: BaseVisualizer

Interactive scatterplot visualizer.

Parameters:
  • x (array-like) – X coordinates.

  • y (array-like) – Y coordinates.

  • labels (array-like of str, optional) – Point labels for coloring (categorical).

  • sizes (array-like of float, optional) – Point sizes for bubble mode.

  • colors (array-like of float, optional) – Continuous values for color mapping.

  • point_labels (list of str, optional) – Individual point hover labels.

  • x_label (str, optional) – X-axis label.

  • y_label (str, optional) – Y-axis label.

  • show_diagonal (bool, default=False) – Show y=x diagonal line.

  • show_regression (bool, default=False) – Show linear regression line.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette name.

  • width (int, default=700) – Chart width.

  • height (int, default=600) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_predictions(y_true, y_pred, **kwargs)[source]

Create an actual-vs-predicted scatter plot.

Parameters:
  • y_true (array-like) – True values.

  • y_pred (array-like) – Predicted values.

  • **kwargs – Additional keyword arguments.

Return type:

ScatterplotVisualizer

classmethod from_embedding(embedding, labels=None, **kwargs)[source]

Create a scatter plot from 2D embeddings (t-SNE, UMAP, PCA).

Parameters:
  • embedding (array-like, shape (n_samples, 2)) – 2D embedding coordinates.

  • labels (array-like, optional) – Labels for coloring.

  • **kwargs – Additional keyword arguments.

Return type:

ScatterplotVisualizer

class endgame.visualization.BoxPlotVisualizer(data, *, orientation='vertical', show_points=False, x_label='', y_label='', title='', palette='tableau', width=800, height=500, theme='dark')[source]

Bases: BaseVisualizer

Interactive box plot visualizer.

Parameters:
  • data (dict of str → list of float) – Mapping of group name to values.

  • orientation (str, default='vertical') – ‘vertical’ or ‘horizontal’.

  • show_points (bool, default=False) – Show individual data points (jittered).

  • x_label (str, optional) – X-axis label.

  • y_label (str, optional) – Y-axis label.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=800) – Chart width.

  • height (int, default=500) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_cv_results(results, **kwargs)[source]

Create box plot from CV results.

Parameters:
  • results (dict of str → list of float) – Model name → fold scores.

  • **kwargs – Additional keyword arguments.

Return type:

BoxPlotVisualizer

class endgame.visualization.ViolinPlotVisualizer(data, *, show_box=True, x_label='', y_label='', title='', palette='tableau', width=800, height=500, theme='dark')[source]

Bases: BaseVisualizer

Interactive violin plot visualizer.

Parameters:
  • data (dict of str → list of float) – Mapping of group name to values.

  • show_box (bool, default=True) – Show mini box plot inside violin.

  • x_label (str, optional) – X-axis label.

  • y_label (str, optional) – Y-axis label.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=800) – Chart width.

  • height (int, default=500) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

class endgame.visualization.ErrorBarsVisualizer(labels, means, errors, *, orientation='horizontal', sort=True, x_label='', y_label='', title='', palette='tableau', width=800, height=500, theme='dark')[source]

Bases: BaseVisualizer

Interactive error bar chart for model comparison.

Parameters:
  • labels (list of str) – Model/category names.

  • means (list of float) – Mean values.

  • errors (list of float or list of tuple of float) – Symmetric errors (single value) or asymmetric (lo, hi) per point.

  • orientation (str, default='horizontal') – ‘horizontal’ or ‘vertical’.

  • sort (bool, default=True) – Sort by mean value.

  • x_label (str, optional) – Value axis label.

  • y_label (str, optional) – Category axis label.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=800) – Chart width.

  • height (int, default=500) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_cv_results(results, **kwargs)[source]

Create from CV results (mean +/- std).

Parameters:
  • results (dict of str → list of float) – Model name → fold scores.

  • **kwargs – Additional keyword arguments.

Return type:

ErrorBarsVisualizer

class endgame.visualization.ParallelCoordinatesVisualizer(data, *, dimensions=None, color_by=None, cmap='viridis_seq', title='', width=900, height=500, theme='dark')[source]

Bases: BaseVisualizer

Interactive parallel coordinates visualizer.

Parameters:
  • data (list of dict) – List of records, each a dict of dimension_name → value.

  • dimensions (list of str, optional) – Which dimensions to show (and in what order). If None, use all.

  • color_by (str, optional) – Dimension name to use for line coloring.

  • cmap (str, default='viridis_seq') – Color palette for continuous coloring.

  • title (str, optional) – Chart title.

  • width (int, default=900) – Chart width.

  • height (int, default=500) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_optuna_study(study, *, n_trials=None, **kwargs)[source]

Create from an Optuna study.

Parameters:
  • study (optuna.Study) – Completed Optuna study.

  • n_trials (int, optional) – Max number of trials to show.

  • **kwargs – Additional keyword arguments.

Return type:

ParallelCoordinatesVisualizer

class endgame.visualization.RadarChartVisualizer(dimensions, series, *, ranges=None, fill=True, title='', palette='tableau', width=600, height=600, theme='dark')[source]

Bases: BaseVisualizer

Interactive radar chart visualizer.

Parameters:
  • dimensions (list of str) – Axis labels.

  • series (dict of str → list of float) – Mapping of series name to values (one per dimension).

  • ranges (list of tuple of float, optional) – (min, max) for each dimension. If None, auto-computed.

  • fill (bool, default=True) – Fill polygon area.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=600) – Chart width.

  • height (int, default=600) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

class endgame.visualization.TreemapVisualizer(labels, values, *, parents=None, title='', palette='tableau', width=800, height=500, theme='dark')[source]

Bases: BaseVisualizer

Interactive treemap visualizer.

Parameters:
  • labels (list of str) – Category labels.

  • values (list of float) – Values (sizes) for each category.

  • parents (list of str, optional) – Parent labels for hierarchical treemaps.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=800) – Chart width.

  • height (int, default=500) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_importances(model, *, feature_names=None, top_n=30, **kwargs)[source]

Create from model feature importances.

Parameters:
  • model (estimator) – Fitted model with feature_importances_.

  • feature_names (list of str, optional) – Feature names.

  • top_n (int, default=30) – Show top N features.

  • **kwargs – Additional keyword arguments.

Return type:

TreemapVisualizer

class endgame.visualization.SunburstVisualizer(labels, parents, values, *, title='', palette='tableau', width=600, height=600, theme='dark')[source]

Bases: BaseVisualizer

Interactive sunburst chart visualizer.

Parameters:
  • labels (list of str) – Node labels.

  • parents (list of str) – Parent label for each node (’’ for root).

  • values (list of float) – Values/sizes for each node.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=600) – Chart width.

  • height (int, default=600) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

class endgame.visualization.SankeyVisualizer(nodes, links, *, title='', palette='tableau', width=900, height=500, theme='dark')[source]

Bases: BaseVisualizer

Interactive Sankey diagram visualizer.

Parameters:
  • nodes (list of str) – Node labels.

  • links (list of (str, str, float)) – Links as (source, target, value) tuples.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=900) – Chart width.

  • height (int, default=500) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

class endgame.visualization.DotMatrixVisualizer(labels, values, *, n_dots=100, dot_shape='circle', title='', palette='tableau', width=600, height=400, theme='dark')[source]

Bases: BaseVisualizer

Interactive dot matrix (waffle) chart visualizer.

Parameters:
  • labels (list of str) – Category labels.

  • values (list of float) – Values for each category (will be normalized to n_dots total).

  • n_dots (int, default=100) – Total number of dots.

  • dot_shape (str, default='circle') – ‘circle’ or ‘square’.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=600) – Chart width.

  • height (int, default=400) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

class endgame.visualization.VennDiagramVisualizer(sets, intersections, *, title='', palette='tableau', width=600, height=500, theme='dark')[source]

Bases: BaseVisualizer

Interactive Venn diagram visualizer (2 or 3 sets).

Parameters:
  • sets (dict of str → int) – Set name → total count.

  • intersections (dict of str → int) – Intersection keys (e.g., ‘A&B’, ‘A&B&C’) → count.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=600) – Chart width.

  • height (int, default=500) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

class endgame.visualization.WordCloudVisualizer(words, *, max_words=100, min_font=12, max_font=60, title='', palette='tableau', width=800, height=500, theme='dark')[source]

Bases: BaseVisualizer

Interactive word cloud visualizer.

Parameters:
  • words (dict of str → float) – Word/phrase → weight/frequency.

  • max_words (int, default=100) – Maximum number of words to display.

  • min_font (int, default=12) – Minimum font size in pixels.

  • max_font (int, default=60) – Maximum font size in pixels.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=800) – Chart width.

  • height (int, default=500) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_feature_names(feature_names, importances=None, **kwargs)[source]

Create from feature names and optional importances.

Parameters:
  • feature_names (list of str) – Feature names.

  • importances (list of float, optional) – Feature importances.

  • **kwargs – Additional keyword arguments.

Return type:

WordCloudVisualizer

class endgame.visualization.ArcDiagramVisualizer(nodes, edges, *, sort_by='input', thickness_range=(1.0, 8.0), title='', palette='tableau', width=900, height=500, theme='dark')[source]

Bases: BaseVisualizer

Interactive arc diagram visualizer.

Nodes are placed along a horizontal line; edges are drawn as semicircular arcs above (and optionally below) the line. Arc thickness and opacity encode edge weight.

Parameters:
  • nodes (list of str) – Node labels (placed left-to-right).

  • edges (list of (str, str, float)) – Edges as (source, target, weight) tuples.

  • sort_by (str, default='input') – Node order: ‘input’ (given order), ‘degree’ (most connected first), ‘name’ (alphabetical).

  • thickness_range (tuple of float, default=(1, 8)) – Min and max arc stroke width (maps to weight).

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=900) – Chart width.

  • height (int, default=500) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_correlation_matrix(corr, feature_names, *, threshold=0.3, **kwargs)[source]

Create from a correlation matrix, showing edges above a threshold.

Parameters:
  • corr (array-like, shape (n, n)) – Correlation matrix.

  • feature_names (list of str) – Feature names.

  • threshold (float, default=0.3) – Minimum absolute correlation to draw an edge.

  • **kwargs – Additional keyword arguments.

Return type:

ArcDiagramVisualizer

class endgame.visualization.ChordDiagramVisualizer(matrix, labels, *, title='', palette='tableau', width=650, height=650, theme='dark')[source]

Bases: BaseVisualizer

Interactive chord diagram visualizer.

Parameters:
  • matrix (array-like, shape (n, n)) – Symmetric or asymmetric flow matrix. matrix[i][j] is the flow from group i to group j.

  • labels (list of str) – Group labels.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=650) – Chart width.

  • height (int, default=650) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_confusion_matrix(matrix, class_names, **kwargs)[source]

Create a chord diagram from a confusion matrix.

Shows misclassification flows between classes.

Parameters:
  • matrix (array-like, shape (n, n)) – Confusion matrix.

  • class_names (list of str) – Class names.

  • **kwargs – Additional keyword arguments.

Return type:

ChordDiagramVisualizer

class endgame.visualization.DonutChartVisualizer(labels, values, *, inner_radius_ratio=0.55, center_text='', title='', palette='tableau', width=600, height=550, theme='dark')[source]

Bases: BaseVisualizer

Interactive donut chart visualizer.

Parameters:
  • labels (list of str) – Slice labels.

  • values (list of float) – Slice values (proportions are computed automatically).

  • inner_radius_ratio (float, default=0.55) – Ratio of inner to outer radius (0 = pie, ~0.6 = donut).

  • center_text (str, optional) – Text displayed in the center hole.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=600) – Chart width.

  • height (int, default=550) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_class_distribution(y, *, class_names=None, **kwargs)[source]

Create from a target array’s class distribution.

Parameters:
  • y (array-like) – Target labels.

  • class_names (list of str, optional) – Class names.

  • **kwargs – Additional keyword arguments.

Return type:

DonutChartVisualizer

class endgame.visualization.FlowChartVisualizer(nodes, edges, *, direction='LR', title='', palette='tableau', width=900, height=500, theme='dark')[source]

Bases: BaseVisualizer

Interactive flow chart visualizer.

Parameters:
  • nodes (list of dict) – Each dict must have ‘id’ and ‘label’. Optional keys: ‘type’ (‘input’, ‘process’, ‘decision’, ‘output’), ‘description’ (tooltip text).

  • edges (list of (str, str) or (str, str, str)) – Edges as (source_id, target_id) or (source_id, target_id, label).

  • direction (str, default='LR') – Flow direction: ‘LR’ (left-to-right), ‘TB’ (top-to-bottom).

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=900) – Chart width.

  • height (int, default=500) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_pipeline(steps, **kwargs)[source]

Create from a list of (name, description) pipeline steps.

Parameters:
  • steps (list of (str, str)) – Pipeline step names and descriptions.

  • **kwargs – Additional keyword arguments.

Return type:

FlowChartVisualizer

class endgame.visualization.NetworkDiagramVisualizer(nodes, edges, *, directed=True, node_sizes=None, layout='force', title='', palette='tableau', width=800, height=600, theme='dark')[source]

Bases: BaseVisualizer

Interactive network diagram visualizer.

Parameters:
  • nodes (list of str or list of dict) – Node labels (strings) or dicts with ‘id’, ‘label’, and optional ‘group’, ‘size’, ‘description’ keys.

  • edges (list of (str, str) or (str, str, float)) – Edges as (source, target) or (source, target, weight) tuples.

  • directed (bool, default=True) – If True, draw arrows on edges (for DAGs like Bayesian Networks).

  • node_sizes (dict of str → float, optional) – Custom node sizes. If None, sized by degree.

  • layout (str, default='force') – Layout algorithm: ‘force’ (force-directed), ‘hierarchical’ (top-down DAG), ‘circular’.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=800) – Chart width.

  • height (int, default=600) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_bayesian_network(model, *, feature_names=None, **kwargs)[source]

Create from an endgame Bayesian classifier (TAN, KDB, ESKDB).

Extracts the DAG structure from the model’s learned network.

Parameters:
  • model (estimator) – Fitted Bayesian network classifier with structure information. Supports endgame TAN, KDB, ESKDB classifiers and any model with edges_ or dag_ attribute.

  • feature_names (list of str, optional) – Feature names.

  • **kwargs – Additional keyword arguments.

Return type:

NetworkDiagramVisualizer

classmethod from_adjacency_matrix(matrix, labels, *, threshold=0.0, **kwargs)[source]

Create from an adjacency/weight matrix.

Parameters:
  • matrix (array-like, shape (n, n)) – Adjacency or weight matrix.

  • labels (list of str) – Node labels.

  • threshold (float, default=0.0) – Minimum absolute value to create an edge.

  • **kwargs – Additional keyword arguments.

Return type:

NetworkDiagramVisualizer

classmethod from_edge_list(edges, **kwargs)[source]

Create from a simple edge list, auto-discovering nodes.

Parameters:
  • edges (list of (str, str)) – Edge tuples.

  • **kwargs – Additional keyword arguments.

Return type:

NetworkDiagramVisualizer

class endgame.visualization.NightingaleRoseVisualizer(labels, values, *, series_names=None, title='', palette='tableau', width=600, height=600, theme='dark')[source]

Bases: BaseVisualizer

Interactive Nightingale Rose chart visualizer.

Parameters:
  • labels (list of str) – Category labels.

  • values (list of float or dict of str → list of float) – Values for each category. Pass a dict for multiple series (overlaid petals).

  • series_names (list of str, optional) – Series names (when values is a dict).

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=600) – Chart width.

  • height (int, default=600) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_metrics(metrics, **kwargs)[source]

Create from a metrics dictionary.

Parameters:
  • metrics (dict of str → float) – Metric name → value.

  • **kwargs – Additional keyword arguments.

Return type:

NightingaleRoseVisualizer

class endgame.visualization.RadialBarVisualizer(labels, values, *, inner_radius_ratio=0.3, sort=False, title='', palette='tableau', width=650, height=650, theme='dark')[source]

Bases: BaseVisualizer

Interactive radial bar chart visualizer.

Parameters:
  • labels (list of str) – Category labels.

  • values (list of float) – Bar values.

  • inner_radius_ratio (float, default=0.3) – Ratio of inner radius to outer radius.

  • sort (bool, default=False) – If True, sort bars by value descending.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=650) – Chart width.

  • height (int, default=650) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

class endgame.visualization.SpiralPlotVisualizer(values, *, labels=None, n_turns=None, color_by_value=True, cmap='blues', title='', width=650, height=650, theme='dark')[source]

Bases: BaseVisualizer

Interactive spiral plot visualizer.

Parameters:
  • values (array-like) – Sequential data values to plot along the spiral.

  • labels (list of str, optional) – Labels for each data point (shown on hover).

  • n_turns (float, optional) – Number of spiral turns. If None, auto-computed.

  • color_by_value (bool, default=True) – If True, color points by value. Otherwise use position.

  • cmap (str, default='viridis_seq') – Color palette for value mapping.

  • title (str, optional) – Chart title.

  • width (int, default=650) – Chart width.

  • height (int, default=650) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_time_series(values, timestamps=None, **kwargs)[source]

Create from a time series.

Parameters:
  • values (array-like) – Time series values.

  • timestamps (list of str, optional) – Timestamp labels for each point.

  • **kwargs – Additional keyword arguments.

Return type:

SpiralPlotVisualizer

class endgame.visualization.StreamGraphVisualizer(x, series, *, baseline='wiggle', title='', palette='tableau', width=900, height=500, theme='dark')[source]

Bases: BaseVisualizer

Interactive stream graph visualizer.

Parameters:
  • x (list of float or list of str) – X-axis values.

  • series (dict of str → list of float) – Mapping of series name to values at each x point.

  • baseline (str, default='wiggle') – Baseline algorithm: ‘zero’ (stacked from zero), ‘center’ (centered around zero), ‘wiggle’ (minimizes wiggle).

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=900) – Chart width.

  • height (int, default=500) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

class endgame.visualization.ROCCurveVisualizer(curves, *, title='', palette='tableau', width=650, height=600, theme='dark')[source]

Bases: BaseVisualizer

Interactive ROC curve visualizer.

Parameters:
  • curves (list of dict) – Each dict has keys ‘fpr’ (list of float), ‘tpr’ (list of float), ‘auc’ (float), ‘label’ (str).

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=650) – Chart width.

  • height (int, default=600) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_estimator(model, X, y, *, class_names=None, **kwargs)[source]

Create ROC curves from a fitted classifier.

For binary classifiers, plots a single curve. For multiclass, plots one-vs-rest curves for each class.

Parameters:
  • model (estimator) – Fitted sklearn-compatible classifier with predict_proba.

  • X (array-like) – Test features.

  • y (array-like) – True labels.

  • class_names (list of str, optional) – Class names.

  • **kwargs – Additional keyword arguments.

Return type:

ROCCurveVisualizer

classmethod from_predictions(y_true, y_score, *, label='Model', **kwargs)[source]

Create ROC curve from predictions (binary).

Parameters:
  • y_true (array-like) – True binary labels.

  • y_score (array-like) – Predicted probabilities or decision scores for the positive class.

  • label (str, default='Model') – Curve label.

  • **kwargs – Additional keyword arguments.

Return type:

ROCCurveVisualizer

class endgame.visualization.PRCurveVisualizer(curves, *, prevalence=None, title='', palette='tableau', width=650, height=600, theme='dark')[source]

Bases: BaseVisualizer

Interactive Precision-Recall curve visualizer.

Parameters:
  • curves (list of dict) – Each dict has keys ‘precision’ (list of float), ‘recall’ (list of float), ‘ap’ (float), ‘label’ (str).

  • prevalence (float, optional) – Positive class prevalence (shown as baseline).

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=650) – Chart width.

  • height (int, default=600) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_estimator(model, X, y, *, class_names=None, **kwargs)[source]

Create PR curves from a fitted classifier.

Parameters:
  • model (estimator) – Fitted sklearn-compatible classifier with predict_proba.

  • X (array-like) – Test features.

  • y (array-like) – True labels.

  • class_names (list of str, optional) – Class names.

  • **kwargs – Additional keyword arguments.

Return type:

PRCurveVisualizer

classmethod from_predictions(y_true, y_score, *, label='Model', **kwargs)[source]

Create PR curve from binary predictions.

Parameters:
  • y_true (array-like) – True binary labels.

  • y_score (array-like) – Predicted probabilities for the positive class.

  • label (str, default='Model') – Curve label.

  • **kwargs – Additional keyword arguments.

Return type:

PRCurveVisualizer

class endgame.visualization.CalibrationPlotVisualizer(curves, *, n_bins=10, title='', palette='tableau', width=650, height=700, theme='dark')[source]

Bases: BaseVisualizer

Interactive calibration (reliability) diagram visualizer.

Parameters:
  • curves (list of dict) – Each dict has keys ‘prob_true’ (list of float), ‘prob_pred’ (list of float), ‘counts’ (list of int), ‘label’ (str), ‘ece’ (float), ‘mce’ (float).

  • n_bins (int, default=10) – Number of bins (for reference; actual binning in constructors).

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=650) – Chart width.

  • height (int, default=700) – Chart height (taller to fit histogram below).

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_estimator(model, X, y, *, n_bins=10, strategy='uniform', label=None, **kwargs)[source]

Create from a fitted classifier.

Parameters:
  • model (estimator) – Fitted classifier with predict_proba.

  • X (array-like) – Test features.

  • y (array-like) – True binary labels.

  • n_bins (int, default=10) – Number of calibration bins.

  • strategy (str, default='uniform') – Binning strategy: ‘uniform’ or ‘quantile’.

  • label (str, optional) – Model label.

  • **kwargs – Additional keyword arguments.

Return type:

CalibrationPlotVisualizer

classmethod from_predictions(y_true, y_prob, *, n_bins=10, strategy='uniform', label='Model', **kwargs)[source]

Create from predictions.

Parameters:
  • y_true (array-like) – True binary labels.

  • y_prob (array-like) – Predicted probabilities.

  • n_bins (int, default=10) – Number of calibration bins.

  • strategy (str, default='uniform') – Binning strategy.

  • label (str, default='Model') – Model label.

  • **kwargs – Additional keyword arguments.

Return type:

CalibrationPlotVisualizer

classmethod from_multiple(y_true, predictions, *, n_bins=10, strategy='uniform', **kwargs)[source]

Compare calibration of multiple models.

Parameters:
  • y_true (array-like) – True binary labels.

  • predictions (dict of str → array-like) – Model name → predicted probabilities.

  • n_bins (int, default=10) – Number of bins.

  • strategy (str, default='uniform') – Binning strategy.

  • **kwargs – Additional keyword arguments.

Return type:

CalibrationPlotVisualizer

class endgame.visualization.LiftChartVisualizer(curves, *, mode='both', title='', palette='tableau', width=850, height=550, theme='dark')[source]

Bases: BaseVisualizer

Interactive lift / cumulative gains chart visualizer.

Parameters:
  • curves (list of dict) – Each dict has keys ‘percentiles’ (list of float 0-1), ‘gains’ (list of float), ‘lift’ (list of float), ‘label’ (str).

  • mode (str, default='both') – ‘gains’ (cumulative gains only), ‘lift’ (lift only), or ‘both’ (gains on left, lift on right — dual axis).

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=850) – Chart width.

  • height (int, default=550) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_estimator(model, X, y, *, label=None, **kwargs)[source]

Create from a fitted classifier.

Parameters:
  • model (estimator) – Fitted classifier with predict_proba.

  • X (array-like) – Test features.

  • y (array-like) – True binary labels.

  • label (str, optional) – Model label.

  • **kwargs – Additional keyword arguments.

Return type:

LiftChartVisualizer

classmethod from_predictions(y_true, y_score, *, label='Model', n_points=100, **kwargs)[source]

Create from predictions.

Parameters:
  • y_true (array-like) – True binary labels.

  • y_score (array-like) – Predicted probabilities or decision scores.

  • label (str, default='Model') – Model label.

  • n_points (int, default=100) – Number of evaluation points.

  • **kwargs – Additional keyword arguments.

Return type:

LiftChartVisualizer

class endgame.visualization.PDPVisualizer(grid_values, pdp_values, *, ice_lines=None, feature_name='', is_categorical=False, title='', palette='tableau', width=750, height=500, theme='dark')[source]

Bases: BaseVisualizer

Interactive partial dependence / ICE plot visualizer.

Parameters:
  • grid_values (list of float) – Feature values on the grid.

  • pdp_values (list of float) – Partial dependence values (mean ICE).

  • ice_lines (list of list of float, optional) – Individual conditional expectation curves.

  • feature_name (str, default='') – Feature name for axis label.

  • is_categorical (bool, default=False) – Whether feature is categorical.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=750) – Chart width.

  • height (int, default=500) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_estimator(model, X, *, feature=0, ice=True, n_ice_lines=50, grid_resolution=50, percentiles=(0.05, 0.95), target_class=1, **kwargs)[source]

Create PDP/ICE from a fitted model.

Parameters:
  • model (estimator) – Fitted sklearn-compatible estimator.

  • X (array-like of shape (n_samples, n_features)) – Training data (used to build the grid and compute ICE).

  • feature (int or str) – Feature index or name.

  • ice (bool, default=True) – Whether to include ICE lines.

  • n_ice_lines (int, default=50) – Number of ICE lines to sample.

  • grid_resolution (int, default=50) – Number of grid points.

  • percentiles (tuple, default=(0.05, 0.95)) – Feature range percentiles.

  • target_class (int, default=1) – For classifiers, which class probability to show.

  • **kwargs – Additional keyword arguments.

Return type:

PDPVisualizer

classmethod from_precomputed(grid_values, pdp_values, *, ice_lines=None, feature_name='', **kwargs)[source]

Create from precomputed PDP/ICE values.

Parameters:
  • grid_values (list of float) – Feature grid values.

  • pdp_values (list of float) – Partial dependence values.

  • ice_lines (list of list of float, optional) – ICE lines.

  • feature_name (str, optional) – Feature name.

  • **kwargs – Additional keyword arguments.

Return type:

PDPVisualizer

class endgame.visualization.PDP2DVisualizer(grid_x, grid_y, values, *, feature_x='', feature_y='', title='', palette='tableau', width=700, height=600, theme='dark')[source]

Bases: BaseVisualizer

2D partial dependence plot (heatmap).

Parameters:
  • grid_x (list of float) – Grid values for feature x.

  • grid_y (list of float) – Grid values for feature y.

  • values (list of list of float) – 2D matrix of PD values (rows = y, cols = x).

  • feature_x (str, default='') – Feature x name.

  • feature_y (str, default='') – Feature y name.

  • title (str)

  • palette (str)

  • width (int)

  • height (int)

  • theme (str)

classmethod from_estimator(model, X, *, features=(0, 1), grid_resolution=25, percentiles=(0.05, 0.95), target_class=1, **kwargs)[source]

Create 2D PDP from a fitted model.

Parameters:
  • model (estimator) – Fitted sklearn-compatible estimator.

  • X (array-like) – Training data.

  • features (tuple of (int or str, int or str)) – Two feature indices or names.

  • grid_resolution (int, default=25) – Grid resolution per axis.

  • percentiles (tuple, default=(0.05, 0.95)) – Feature range percentiles.

  • target_class (int, default=1) – For classifiers, which class probability.

  • **kwargs – Additional keyword arguments.

Return type:

PDP2DVisualizer

class endgame.visualization.WaterfallVisualizer(categories, values, *, base_value=None, final_value=None, show_connectors=True, sort_by=None, max_display=None, title='', palette='tableau', width=750, height=550, theme='dark')[source]

Bases: BaseVisualizer

Interactive waterfall chart visualizer.

Parameters:
  • categories (list of str) – Category/feature labels.

  • values (list of float) – Contribution values (positive = increase, negative = decrease).

  • base_value (float, optional) – Starting/baseline value (shown at bottom).

  • final_value (float, optional) – Final value (shown at top). If None, computed as base + sum(values).

  • show_connectors (bool, default=True) – Show connector lines between bars.

  • sort_by (str, optional) – ‘abs’ to sort by absolute contribution, None for given order.

  • max_display (int, optional) – Maximum features to display. Remaining are grouped into “Other”.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=750) – Chart width.

  • height (int, default=550) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_shap(shap_values, feature_names, base_value, *, max_display=15, **kwargs)[source]

Create from SHAP values for a single prediction.

Parameters:
  • shap_values (array-like of shape (n_features,)) – SHAP values for one sample.

  • feature_names (list of str) – Feature names.

  • base_value (float) – Expected value (model output mean).

  • max_display (int, default=15) – Max features to display.

  • **kwargs – Additional keyword arguments.

Return type:

WaterfallVisualizer

classmethod from_contributions(categories, values, *, base_value=0.0, **kwargs)[source]

Create from sequential contributions.

Parameters:
  • categories (list of str) – Step/category labels.

  • values (list of float) – Contribution values.

  • base_value (float, default=0.0) – Starting value.

  • **kwargs – Additional keyword arguments.

Return type:

WaterfallVisualizer

class endgame.visualization.RidgelinePlotVisualizer(data, *, overlap=0.5, kde_points=100, bandwidth=None, show_quantiles=True, title='', palette='tableau', width=800, height=500, theme='dark')[source]

Bases: BaseVisualizer

Interactive ridgeline (joy) plot visualizer.

Parameters:
  • data (dict of str → list of float) – Group name → raw values.

  • overlap (float, default=0.5) – Overlap ratio between adjacent ridges (0 = no overlap, 1 = full).

  • kde_points (int, default=100) – Number of points for KDE evaluation.

  • bandwidth (float, optional) – KDE bandwidth. If None, uses Silverman’s rule.

  • show_quantiles (bool, default=True) – Show median and Q1/Q3 markers.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=800) – Chart width.

  • height (int, default=500) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_cv_results(results, **kwargs)[source]

Create from cross-validation results.

Parameters:
  • results (dict of str → list of float) – Model name → fold scores.

  • **kwargs – Additional keyword arguments.

Return type:

RidgelinePlotVisualizer

classmethod from_feature_distributions(X, feature_names=None, *, max_features=15, **kwargs)[source]

Create from feature column distributions.

Parameters:
  • X (array-like of shape (n_samples, n_features)) – Feature matrix.

  • feature_names (list of str, optional) – Feature names.

  • max_features (int, default=15) – Max number of features to show.

  • **kwargs – Additional keyword arguments.

Return type:

RidgelinePlotVisualizer

class endgame.visualization.BumpChartVisualizer(x, rankings, *, title='', palette='tableau', width=800, height=500, theme='dark')[source]

Bases: BaseVisualizer

Interactive bump chart visualizer.

Parameters:
  • x (list) – X-axis labels (e.g. time points, fold names, rounds).

  • rankings (dict of str → list of int) – Series name → ranking at each x point (1 = best).

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=800) – Chart width.

  • height (int, default=500) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_scores(x, scores, *, higher_is_better=True, **kwargs)[source]

Create from raw scores, converting to rankings.

Parameters:
  • x (list) – X-axis labels.

  • scores (dict of str → list of float) – Series name → scores at each point.

  • higher_is_better (bool, default=True) – If True, highest score → rank 1.

  • **kwargs – Additional keyword arguments.

Return type:

BumpChartVisualizer

classmethod from_cv_scores(scores, *, higher_is_better=True, **kwargs)[source]

Create from cross-validation fold scores.

Parameters:
  • scores (dict of str → list of float) – Model name → fold scores.

  • higher_is_better (bool, default=True) – If True, highest score → rank 1.

  • **kwargs – Additional keyword arguments.

Return type:

BumpChartVisualizer

class endgame.visualization.LollipopChartVisualizer(labels, values, *, orientation='horizontal', sort=False, highlight_top=None, baseline=0, title='', palette='tableau', width=750, height=500, theme='dark')[source]

Bases: BaseVisualizer

Interactive lollipop chart visualizer.

Parameters:
  • labels (list of str) – Category labels.

  • values (list of float) – Values for each category.

  • orientation (str, default='horizontal') – ‘horizontal’ (labels on Y) or ‘vertical’ (labels on X).

  • sort (bool, default=False) – Sort by value (descending).

  • highlight_top (int, optional) – Number of top items to highlight with larger dots.

  • baseline (float, default=0) – Baseline value where stems start.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=750) – Chart width.

  • height (int, default=500) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_importances(model, *, feature_names=None, top_n=None, **kwargs)[source]

Create from model feature importances.

Parameters:
  • model (estimator) – Fitted model with feature_importances_.

  • feature_names (list of str, optional) – Feature names.

  • top_n (int, optional) – Show only top N features.

  • **kwargs – Additional keyword arguments.

Return type:

LollipopChartVisualizer

classmethod from_dict(data, **kwargs)[source]

Create from a dictionary.

Parameters:
  • data (dict of str → float) – Label → value pairs.

  • **kwargs – Additional keyword arguments.

Return type:

LollipopChartVisualizer

class endgame.visualization.DumbbellChartVisualizer(labels, values_start, values_end, *, start_label='Start', end_label='End', sort_by=None, title='', palette='tableau', width=750, height=500, theme='dark')[source]

Bases: BaseVisualizer

Interactive dumbbell chart visualizer.

Parameters:
  • labels (list of str) – Category labels.

  • values_start (list of float) – Starting (left) values.

  • values_end (list of float) – Ending (right) values.

  • start_label (str, default='Start') – Legend label for starting dots.

  • end_label (str, default='End') – Legend label for ending dots.

  • sort_by (str, optional) – ‘diff’ to sort by difference, ‘end’ to sort by end value, ‘start’ to sort by start value, None for given order.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=750) – Chart width.

  • height (int, default=500) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_metrics(labels, before, after, *, start_label='Before', end_label='After', **kwargs)[source]

Create from before/after metric dicts.

Parameters:
  • labels (list of str) – Metric names to compare.

  • before (dict of str → float) – Metric name → value before.

  • after (dict of str → float) – Metric name → value after.

  • **kwargs – Additional keyword arguments.

  • start_label (str)

  • end_label (str)

Return type:

DumbbellChartVisualizer

classmethod from_train_test(labels, train_scores, test_scores, **kwargs)[source]

Create from train/test score pairs.

Parameters:
  • labels (list of str) – Model or metric names.

  • train_scores (list of float) – Training scores.

  • test_scores (list of float) – Test scores.

  • **kwargs – Additional keyword arguments.

Return type:

DumbbellChartVisualizer

class endgame.visualization.FunnelChartVisualizer(stages, values, *, show_percentages=True, title='', palette='tableau', width=700, height=500, theme='dark')[source]

Bases: BaseVisualizer

Interactive funnel chart visualizer.

Parameters:
  • stages (list of str) – Stage names (top to bottom).

  • values (list of float) – Values at each stage (should generally decrease).

  • show_percentages (bool, default=True) – Show percentage of initial value and step-to-step retention.

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=700) – Chart width.

  • height (int, default=500) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_pipeline(stages, sample_counts, **kwargs)[source]

Create from a data pipeline with sample counts.

Parameters:
  • stages (list of str) – Pipeline stage names.

  • sample_counts (list of int) – Number of samples at each stage.

  • **kwargs – Additional keyword arguments.

Return type:

FunnelChartVisualizer

classmethod from_feature_selection(stages, feature_counts, **kwargs)[source]

Create from feature selection stages.

Parameters:
  • stages (list of str) – Selection stage names (e.g., “All Features”, “Variance Filter”, etc.).

  • feature_counts (list of int) – Number of features remaining at each stage.

  • **kwargs – Additional keyword arguments.

Return type:

FunnelChartVisualizer

class endgame.visualization.GaugeChartVisualizer(value, *, min_value=0, max_value=1, label='', zones=None, format_str=None, title='', palette='tableau', width=450, height=350, theme='dark')[source]

Bases: BaseVisualizer

Interactive gauge chart visualizer.

Parameters:
  • value (float) – Current metric value.

  • min_value (float, default=0) – Minimum scale value.

  • max_value (float, default=1) – Maximum scale value.

  • label (str, default='') – Metric label shown below the value.

  • zones (list of (float, float, str), optional) – Colored zones as (start, end, color). If None, uses default red/yellow/green zones dividing the range into thirds.

  • format_str (str, optional) – Python format string for the displayed value (e.g., ‘.1%’, ‘.3f’).

  • title (str, optional) – Chart title.

  • palette (str, default='tableau') – Color palette.

  • width (int, default=450) – Chart width.

  • height (int, default=350) – Chart height.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

classmethod from_score(score, metric_name='Score', *, min_value=0, max_value=1, **kwargs)[source]

Create from a single metric score.

Parameters:
  • score (float) – Metric value.

  • metric_name (str, default='Score') – Name of the metric.

  • min_value (float, default=0) – Min scale.

  • max_value (float, default=1) – Max scale.

  • **kwargs – Additional keyword arguments.

Return type:

GaugeChartVisualizer

classmethod from_accuracy(accuracy, **kwargs)[source]

Create for an accuracy metric (0-1 scale).

Parameters:
  • accuracy (float) – Accuracy value (0 to 1).

  • **kwargs – Additional keyword arguments.

Return type:

GaugeChartVisualizer

class endgame.visualization.ClassificationReport(model, X, y, *, feature_names=None, class_names=None, model_name=None, dataset_name=None, palette='tableau', theme='dark')[source]

Bases: object

Comprehensive classification model evaluation report.

Generates a multi-section HTML report with metrics, charts, and model interpretability for any sklearn-compatible classifier.

Parameters:
  • model (estimator) – Fitted sklearn-compatible classifier.

  • X (array-like) – Test features.

  • y (array-like) – True labels.

  • feature_names (list of str, optional) – Feature names.

  • class_names (list of str, optional) – Class label names. Auto-detected from model.classes_ if absent.

  • model_name (str, optional) – Display name for the model.

  • dataset_name (str, optional) – Display name for the dataset.

  • palette (str, default='tableau') – Color palette.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

Examples

>>> from sklearn.ensemble import RandomForestClassifier
>>> clf = RandomForestClassifier().fit(X_train, y_train)
>>> report = ClassificationReport(clf, X_test, y_test)
>>> report.save("report.html")
property metrics: dict[str, Any]

Access computed metrics dictionary.

save(filepath, open_browser=False)[source]

Save report as self-contained HTML.

Parameters:
  • filepath (str or Path) – Output path.

  • open_browser (bool, default=False) – Open in default browser after saving.

Return type:

Path

Returns:

Path – Absolute path to the saved file.

class endgame.visualization.RegressionReport(model, X, y, *, feature_names=None, model_name=None, dataset_name=None, palette='tableau', theme='dark')[source]

Bases: object

Comprehensive regression model evaluation report.

Generates a multi-section HTML report with metrics, charts, and model interpretability for any sklearn-compatible regressor.

Parameters:
  • model (estimator) – Fitted sklearn-compatible regressor.

  • X (array-like) – Test features.

  • y (array-like) – True target values.

  • feature_names (list of str, optional) – Feature names.

  • model_name (str, optional) – Display name for the model.

  • dataset_name (str, optional) – Display name for the dataset.

  • palette (str, default='tableau') – Color palette.

  • theme (str, default='dark') – ‘dark’ or ‘light’.

Examples

>>> from sklearn.ensemble import RandomForestRegressor
>>> reg = RandomForestRegressor().fit(X_train, y_train)
>>> report = RegressionReport(reg, X_test, y_test)
>>> report.save("report.html")
property metrics: dict[str, Any]

Access computed metrics dictionary.

save(filepath, open_browser=False)[source]

Save report as self-contained HTML.

Return type:

Path

Parameters:

Tree Visualization

class endgame.visualization.TreeVisualizer(model, feature_names=None, class_names=None, tree_index=0, title=None, color_by='prediction', max_depth=None, palette='tableau')[source]

Bases: object

Interactive decision tree visualizer.

Generates self-contained HTML files with D3.js-powered interactive tree visualizations featuring: - Expandable/collapsible branches (click nodes) - Zoom in/out and pan (mouse wheel + drag) - Rich tooltips with node statistics - Color-coded nodes by prediction or impurity - Responsive layout

Parameters:
  • model (estimator) – A fitted tree model. Supports: - sklearn DecisionTreeClassifier/Regressor - sklearn ensembles (extracts individual trees) - C50Classifier / C50Ensemble - ObliqueDecisionTreeClassifier/Regressor - ObliqueRandomForestClassifier/Regressor - EvolutionaryTreeClassifier/Regressor

  • feature_names (list of str, optional) – Names for each feature. If None, uses “feature_0”, “feature_1”, etc.

  • class_names (list of str, optional) – Names for each class (classification only).

  • tree_index (int, default=0) – For ensemble models, which tree to visualize.

  • title (str, optional) – Title displayed above the visualization.

  • color_by (str, default='prediction') – How to color nodes: ‘prediction’ (class color), ‘impurity’ (heatmap), or ‘samples’ (by sample count).

  • max_depth (int, optional) – Maximum depth to display. Deeper nodes are collapsed by default.

  • palette (str, default='tableau') – Color palette: ‘tableau’, ‘viridis’, ‘pastel’, or ‘dark’.

Example

>>> from sklearn.datasets import load_iris
>>> from sklearn.tree import DecisionTreeClassifier
>>> from endgame.visualization import TreeVisualizer
>>>
>>> X, y = load_iris(return_X_y=True)
>>> clf = DecisionTreeClassifier(max_depth=4, random_state=42).fit(X, y)
>>> viz = TreeVisualizer(
...     clf,
...     feature_names=load_iris().feature_names,
...     class_names=load_iris().target_names.tolist(),
...     title="Iris Decision Tree"
... )
>>> viz.save("iris_tree.html")
to_json()[source]

Export tree data as JSON string.

Return type:

Text

save(filepath, open_browser=False)[source]

Save interactive visualization as a self-contained HTML file.

Parameters:
  • filepath (str or Path) – Output file path (should end in .html).

  • open_browser (bool, default=False) – If True, open the file in the default web browser.

Return type:

Path

Returns:

Path – The absolute path to the saved file.