Plots: kolena.workflow.plot
#
This module surfaces plot definitions to visualize test-case-level data. Evaluator implementations can optionally compute plots using these definitions for visualization on the Results page.
The following plot types are available:
NumberSeries = Sequence[Union[float, int]]
module-attribute
#
A sequence of numeric values.
NullableNumberSeries = Sequence[Union[float, int, None]]
module-attribute
#
A sequence of numeric values or None
.
AxisConfig
#
Bases: DataObject
Configuration for the format of a given axis on a plot.
type: Literal['linear', 'log']
instance-attribute
#
Type of axis to display. Supported options are linear
and log
.
Plot
#
Bases: TypedDataObject[_PlotType]
A data visualization shown when exploring model results in the web platform.
Curve
#
Bases: DataObject
A single series on a CurvePlot
.
x: NumberSeries
instance-attribute
#
The x
coordinates of this curve. Length must match the provided y
coordinates.
y: NumberSeries
instance-attribute
#
The y
coordinates of this curve. Length must match the provided x
coordinates.
label: Optional[str] = None
class-attribute
instance-attribute
#
Optionally specify an additional label (in addition to the associated test case) to apply to this curve, for use when e.g. there are multiple curves generated per test case.
extra: Optional[Dict[str, NumberSeries]] = None
class-attribute
instance-attribute
#
Optionally specify additional series shown when hovering over the plot. For example, when plotting a
precision-recall curve, it is desirable to include an extra series threshold
to specify the confidence threshold
value at which a given precision-recall point occurs.
CurvePlot
#
Bases: Plot
A plot visualizing one or more curves per test case.
Examples include Receiver Operating Characteristic (ROC) curves, Precision versus Recall (PR) curves, Detection-Error Tradeoff (DET) curves, etc.
title: str
instance-attribute
#
The title for the plot.
x_label: str
instance-attribute
#
The label describing the plot's x
axis.
y_label: str
instance-attribute
#
The label describing the plot's y
axis.
curves: List[Curve]
instance-attribute
#
A test case may generate zero or more curves on a given plot. However, under most circumstances, a single curve per test case is desirable.
x_config: Optional[AxisConfig] = None
class-attribute
instance-attribute
#
Custom options to allow for control over the display of the plot x
axis. See
AxisConfig
for details.
y_config: Optional[AxisConfig] = None
class-attribute
instance-attribute
#
Custom options to allow for control over the display of the plot y
axis. See
AxisConfig
for details.
Histogram
#
Bases: Plot
A plot visualizing distribution of one or more continuous values, e.g. distribution of an error metric across all samples within a test case.
For visualization of discrete values, see BarPlot
.
title: str
instance-attribute
#
The title for the plot.
x_label: str
instance-attribute
#
The label describing the plot's x
axis.
y_label: str
instance-attribute
#
The label describing the plot's y
axis.
buckets: NumberSeries
instance-attribute
#
A Histogram requires intervals to bucket the data. For n
buckets, n+1
consecutive bounds must be specified in
increasing order.
frequency: Union[NumberSeries, Sequence[NumberSeries]]
instance-attribute
#
For n
buckets, there are n
frequencies corresponding to the height of each bucket. The frequency at index i
corresponds to the bucket with bounds (i
, i+1
) in buckets
.
To specify multiple distributions for a given test case, multiple frequency series can be provided, corresponding
e.g. to the distribution for a given class within a test case, with name specified in labels
.
Specify a list of labels corresponding to the different frequency
series when multiple series are provided.
Can be omitted when a single frequency
series is provided.
labels: Optional[List[str]] = None
class-attribute
instance-attribute
#
Specify the label corresponding to a given distribution when multiple are specified in frequency
.
x_config: Optional[AxisConfig] = None
class-attribute
instance-attribute
#
Custom options to allow for control over the display of the plot x
axis. See
AxisConfig
for details.
y_config: Optional[AxisConfig] = None
class-attribute
instance-attribute
#
Custom options to allow for control over the display of the plot y
axis. See
AxisConfig
for details.
BarPlot
#
Bases: Plot
A plot visualizing a set of bars per test case.
title: str
instance-attribute
#
The plot title.
x_label: str
instance-attribute
#
Axis label for the axis along which the bars are laid out (labels
).
y_label: str
instance-attribute
#
Axis label for the axis corresponding to bar height (values
).
labels: Sequence[Union[str, int, float]]
instance-attribute
#
Labels for each bar with corresponding height specified in values
.
values: NullableNumberSeries
instance-attribute
#
Values for each bar with corresponding label specified in labels
.
config: Optional[AxisConfig] = None
class-attribute
instance-attribute
#
Custom format options to allow for control over the display of the numerical plot axis (values
).
ConfusionMatrix
#
Bases: Plot
A confusion matrix. Example:
ConfusionMatrix(
title="Cat and Dog Confusion",
labels=["Cat", "Dog"],
matrix=[[90, 10], [5, 95]],
)
Yields a confusion matrix of the form:
title: str
instance-attribute
#
The plot title.
labels: List[str]
instance-attribute
#
The labels corresponding to each entry in the square matrix
.
matrix: Sequence[NullableNumberSeries]
instance-attribute
#
A square matrix, typically representing the number of matches between class i
and class j
.
x_label: str = 'Predicted'
class-attribute
instance-attribute
#
The label for the x
axis of the confusion matrix.
y_label: str = 'Actual'
class-attribute
instance-attribute
#
The label for the y
axis of the confusion matrix.