qewton.visualization.plots.table package¶
Module contents¶
Submodules¶
qewton.visualization.plots.table.base module¶
Base class TablePlot for plots of tables: named columns, one
row per record, e.g. the runs of a hyperparameter tuning.
- class qewton.visualization.plots.table.base.TableColumn(values: ndarray, categories: list[str] | None = None)[source]¶
Bases:
objectA table column as plotted: numbers, with categories coded.
- Parameters:
values – One number per row; the code of its category for a categorical column.
categories – The category of each code; None for a numeric column.
- values: ndarray¶
- categories: list[str] | None = None¶
- qewton.visualization.plots.table.base.table_columns(table) dict[str, TableColumn][source]¶
The columns of a table, with categories coded.
Text and object columns become categorical (codes in sorted order of the categories), as do boolean ones (
False0,True1), since renderers draw codes rather than booleans.- Parameters:
table – Anything whose
items()gives (name, values) pairs, e.g. a dict of arrays or a pandas DataFrame.- Returns:
{name: TableColumn}.- Return type:
dict
- Raises:
ValueError – If the columns differ in length.
- class qewton.visualization.plots.table.base.TablePlot(table, *, color: str | Selector | None = None, color_scale: ColorScale | list[ColorScale] | None = None, log_columns: tuple[str, ...] | list[str] = (), controls: tuple[ControlAxis, ...] | list[ControlAxis] = (), title: str | None = None, label: str | None = None)[source]¶
Bases:
PlotDraws the rows of a table; channels are bound to column names, or to Selectors of column names.
Controls reference a column: their states are its distinct values, and only the rows with the value of the current state are drawn (a FacetAxis draws one cell per value). Log columns are drawn by the log10 of their values, with ticks labeled by the values; categorical columns by their codes, with ticks labeled by the categories.
- Parameters:
table – Anything whose
items()gives (name, values) pairs, e.g. a dict of arrays or a pandas DataFrame.color – TableColumn name or Selector of column names colored by; None for a uniform color.
color_scale – As for
DataPlot; a new scale of a log column is logarithmic, one of a categorical column categorical (one color per category).log_columns – Numeric columns drawn on a log scale.
controls – Control axes, each referencing a column.
title – As for
Plot.label – As for
Plot.
- Raises:
ValueError – If a reference names no column, a log column is not numeric and positive, or a control does not reference a column.
- columns¶
{name: TableColumn}.- Type:
dict
- n_rows¶
Number of rows.
- Type:
int
- log_columns¶
The log columns.
- Type:
set of str
- color_scale¶
Scale of the color channel in the current states.
- Type:
ColorScale or None
Notes
Subclasses implement dim, positions and
build().- static current(reference) str | None[source]¶
The column a reference names in the current states.
- Parameters:
reference – A column name, a Selector of them, or None.
- Returns:
The column name.
- Return type:
str or None
- drawn_values(name: str, rows: ndarray) ndarray[source]¶
The values of a column as drawn on a position axis: log10 for a log column, codes for a categorical one.
- Parameters:
name – The column.
rows – Boolean mask of the drawn rows.
- Returns:
One value per drawn row.
- Return type:
numpy.ndarray
- column_ticks(name: str) tuple[list[float], list[str]] | None[source]¶
The ticks of a column on a position axis, in drawn values.
- Parameters:
name – The column.
- Returns:
- Positions and labels: the categories, or values
of a log column; None for automatic ticks.
- Return type:
tuple or None
- property positions: dict¶
{channel: column name or Selector}of the position channels (class-specific).
- property n_copies: int¶
- property color_scale: ColorScale | None¶
- property color_scales: list[ColorScale]¶
- property active_color_scales: list[ColorScale]¶
- property color_title: str | None¶
- color_ticks(scale: ColorScale) tuple[list[float], list[str]] | None[source]¶
See
color_ticks(): the categories of the categorical color column of scale, at their codes; None for a numeric one, or a scale of several columns.
- channels_of(selector: Selector) tuple[str, ...][source]¶
See
channels_of().
- axis_title(channel: str) str | None[source]¶
See
axis_title().
- axis_ticks(channel: str) tuple[list[float], list[str]] | None[source]¶
See
axis_ticks().
- train_scales(axes: dict[str, Scale]) None[source]¶
See
train_scales().Position axes bound to a Selector are not trained, so their range follows the chosen column.
- evaluate() list[Result][source]¶
See
evaluate().
- color_values(rows: ndarray) ndarray | None[source]¶
The values of the color column of the drawn rows, as given.
- Parameters:
rows – Boolean mask of the drawn rows.
- Returns:
None without a color binding.
- Return type:
numpy.ndarray or None
- build(rows: ndarray) Result[source]¶
The Result of the drawn rows, without the common fields (label, colors), which
evaluate()sets.- Parameters:
rows – Boolean mask of the drawn rows.
- Returns:
The Result.
- Return type:
qewton.visualization.plots.table.heatmap module¶
TableHeatMap: the mean of a column over a raster of two others.
- class qewton.visualization.plots.table.heatmap.TableHeatMap(table, *, x: str | Selector, y: str | Selector, color: str | Selector, bins_x: int = 10, bins_y: int = 10, color_scale: ColorScale | list[ColorScale] | None = None, log_columns: tuple[str, ...] | list[str] = (), controls: tuple[ControlAxis, ...] | list[ControlAxis] = (), title: str | None = None, label: str | None = None)[source]¶
Bases:
TablePlotThe mean of the color column over the rows in each rectangle of a raster spanned by two columns; rectangles without rows stay empty. A log column is rastered in log space.
- Parameters:
table – As for
TablePlot.color_scale – As for
TablePlot.log_columns – As for
TablePlot.controls – As for
TablePlot.title – As for
TablePlot.label – As for
TablePlot.x – Numeric column names, or Selectors of them.
y – Numeric column names, or Selectors of them.
color – The averaged column, or a Selector of columns.
bins_x – Number of rectangles along x and y.
bins_y – Number of rectangles along x and y.
- Raises:
ValueError – As for TablePlot, and if a position column is categorical.
- bins_x, bins_y
Number of rectangles along x and y.
- Type:
int
- dim = 2¶
- point_encoding: PointEncoding | None = 1¶
- margin: float = 0.0¶
- property positions: dict¶
{channel: column name or Selector}of the position channels (class-specific).
qewton.visualization.plots.table.parallel_coordinates module¶
ParallelCoordinatesPlot: one axis per column, one line per row.
- class qewton.visualization.plots.table.parallel_coordinates.ParallelCoordinatesPlot(table, *, columns: list[str], color: str | Selector | None = None, color_scale: ColorScale | list[ColorScale] | None = None, column_titles: dict[str, str] | None = None, log_columns: tuple[str, ...] | list[str] = (), controls: tuple[ControlAxis, ...] | list[ControlAxis] = (), title: str | None = None, label: str | None = None)[source]¶
Bases:
TablePlotOne vertical axis per column, one line per row, e.g. the parameters and metrics of the runs of a hyperparameter tuning. The plot lays out its own axes (no position axes).
- Parameters:
table – As for
TablePlot.color – As for
TablePlot.color_scale – As for
TablePlot.log_columns – As for
TablePlot.controls – As for
TablePlot.title – As for
TablePlot.label – As for
TablePlot.columns – The drawn columns, in order.
column_titles – Display name per column; the column name if missing.
- column_names¶
The drawn columns.
- Type:
list of str
- column_titles¶
Display name per column.
- Type:
dict
- dim = 0¶
- property positions: dict¶
{channel: column name or Selector}of the position channels (class-specific).
qewton.visualization.plots.table.scatter module¶
TableScatter: a marker per row of a table.
- class qewton.visualization.plots.table.scatter.TableScatter(table, *, x: str | Selector, y: str | Selector, color: str | Selector | None = None, color_scale: ColorScale | list[ColorScale] | None = None, log_columns: tuple[str, ...] | list[str] = (), jitter: float = 0.0, size: float | None = None, controls: tuple[ControlAxis, ...] | list[ControlAxis] = (), title: str | None = None, label: str | None = None)[source]¶
Bases:
TablePlotA marker per row: x and y from two columns, colored by a third.
- Parameters:
table – As for
TablePlot.color – As for
TablePlot.color_scale – As for
TablePlot.log_columns – As for
TablePlot.controls – As for
TablePlot.title – As for
TablePlot.label – As for
TablePlot.x – Column names, or Selectors of column names.
y – Column names, or Selectors of column names.
jitter – Random offset of every marker, as a fraction of the drawn span of each column; separates rows with equal values. The offsets are fixed per row.
size – Marker size, or None for the theme’s.
- jitter¶
The jitter.
- Type:
float
- size¶
Marker size.
- Type:
float or None
- dim = 2¶
- property positions: dict¶
{channel: column name or Selector}of the position channels (class-specific).