InstanceSpace Python v0.4.1

instancespace.plotting

Thin matplotlib wrappers around a trained Model.

Mirrors MATLAB's InstanceSpace.plot('sources' | 'portfolio' | 'good' | 'footprint', algoIdx). Two-dimensional calls draw onto the current matplotlib axes by default, so repeated calls compose in a notebook cell. Three-dimensional calls create native 3D axes when none are supplied. Pass an explicit dimension-compatible ax to draw somewhere else instead.

These take a Model (or, for testing, anything duck-typing the same shape) rather than an InstanceSpace.

def plot_sources( model: Any, ax: matplotlib.axes._axes.Axes | None = None) -> matplotlib.axes._axes.Axes:

Scatter training instances in the instance space, coloured by source.

Requires model.data.s (the metadata's optional source column); raises if it wasn't provided at build time, matching MATLAB's equivalent requirement.

def plot_portfolio( model: Any, ax: matplotlib.axes._axes.Axes | None = None) -> matplotlib.axes._axes.Axes:

Scatter instances coloured by their best-performing algorithm (data.p).

def plot_good( model: Any, algo: str | int, ax: matplotlib.axes._axes.Axes | None = None) -> matplotlib.axes._axes.Axes:

Scatter instances coloured by PYTHIA's good/bad prediction for one algorithm.

def plot_footprint( model: Any, algo: str | int, kind: str = 'good', ax: matplotlib.axes._axes.Axes | None = None) -> matplotlib.axes._axes.Axes:

Draw one algorithm's native 2D polygon or 3D tetrahedral footprint.

kind is "good" (region where good performance is statistically inferred) or "best" (region where this algorithm is expected to dominate), matching model.trace.good/model.trace.best.