qilisdk.utils.visualization.dataset_renderers
Attributes
Classes
Render a dataset sample using matplotlib, with theme support. |
Module Contents
- type Channel = tuple[str, NDArray[np.float64]] | NDArray[np.float64][fuente]
- class MatplotlibDatasetRenderer(sample: qilisdk.ml.datasets.dataset.DatasetSample | numpy.typing.NDArray[numpy.floating[Any]], style: str = '1d', *, config: qilisdk.utils.visualization.style.DatasetStyle | None = None, labels: tuple[str, ...] | None = None, title: str | None = None, transform: Transform | None = None, ax: matplotlib.pyplot.Axes | None = None)[fuente]
Render a dataset sample using matplotlib, with theme support.
This is the common drawing class shared by every dataset’s
draw()method. The series to plot is taken either from aDatasetSample(whoseinputsare used) or from a raw array, so that a single component of a sample – or any series of the same shape – can be plotted directly.What is drawn on each axis is decided by a transform: a callable mapping the full
(n_points, n_components)series to the coordinates to plot. A transform returns the channels for the current mode – two arrays for a"2d"view, three for"3d", or any number of lines for"1d"– each optionally paired with an axis label. It is free to reshape, slice or delay-embed the data rather than merely selecting columns, so the view is fully general: e.g.lambda d: [("x", d[:, 0]), ("z", d[:, 2])]picks the Lorenzx–zplane, andlambda d: [("P(t)", d[17:, 0]), ("P(t-17)", d[:-17, 0])]builds a delay embedding. When no transform is given, a sensible default is used per mode:"1d"– every component plotted against the sample index."2d"– the first two components; a one-dimensional series is delay-embedded asx(t)vsx(t + delay)."3d"– the first three components; lower-dimensional series are delay-embedded.
Initialize a renderer for a dataset sample.
- Parámetros:
sample (
DatasetSample | NDArray[np.floating[Any]]) – The sample to plot, or a raw array holding the series itself, one row per time step.style (
str) – The plot mode, one of"1d","2d"or"3d". Defaults to"1d".config (
DatasetStyle | None) – Optional style configuration. Defaults toNone(use dataset defaults).labels (
tuple[str,] | None) – Optional labels for the components of the series. Defaults toNone(use dataset defaults).title (
str | None) – Optional title for the plot. Defaults toNone(use dataset defaults).transform (
Transform | None) – Optional callable mapping the full series to the coordinates to plot. Defaults toNone(use dataset defaults).ax (
plt.Axes | None) – Optional Matplotlib Axes to draw on. Defaults toNone(create a new figure and axes).
- Muestra:
ValueError – If
styleis not one of"1d","2d", or"3d".
- sample[fuente]
- mode = '1d'[fuente]
- style[fuente]
- labels = None[fuente]
- title = None[fuente]
- transform = None[fuente]
- series[fuente]
- ax[fuente]
- plot(ax: matplotlib.pyplot.Axes | None = None) None[fuente]
Render the sample onto the renderer’s axes.
- Parámetros:
ax (
plt.Axes | None) – Optional Matplotlib Axes to draw on. If not provided, the renderer’s own axes are used.
- save(filename: str) None[fuente]
Save the current figure to disk (format inferred from the extension).
- show() None[fuente]
Show the current figure.