SingleMetricBoxplot#
- class gaitmap_challenges.visualization.SingleMetricBoxplot(cv_results: Dict[str, DataFrame], metric: str, use_aggregation: Literal['fold', 'single'] = 'single', overlay_scatter: bool = True, force_order: Optional[Sequence[str]] = None, label_grouper: Optional[Callable[[Series], Categorical]] = None, invert_grouping: bool = False, matplotlib_boxplot_props: Optional[Dict[str, Any]] = None)[source]#
Create a boxplot for a single metric.
The plot can be either created with matplotlib or bokeh, by using the respective methods.
Most parameters are shared between both plotting backends. Specific parameters are prefixed with
bokeh_ormatplotlib_or are expected to be passed to the method directly.- Parameters:
- cv_results
A list of cv results of multiple algorithms as loaded by
load_run.- metric
The metric to plot. This should be the error metric without the “test_” and/or “single_” prefix.
- use_aggregation
Whether to use the “fold” or “single” aggregation. With “fold” each point in the final plot is a single fold. With “single” we pool all datapoint values from all test folds, so that each point in the final plot is one datapoint (i.e. one participant) In case of single, we look for the metric in the “test_single_<metric>” column. In case of fold, we look for the metric in the “test_<metric>” column. This further changes what other parameters make sense.
- overlay_scatter
Whether to overlay a scatterplot on top of the boxplot.
- label_grouper
A function that returns a group label for each data point. This can be used to split the data into multiple groups that are plotted independently to effectively create grouped boxplots. Most likely you want to use
group_by_data_labelto create this function. Note, that this setting only makes sense whenuse_aggregation="single".- invert_grouping
Whether to invert the grouping returned by
label_grouper. This will just change the order of the boxplots and which boxplots are grouped together. By default, all groups of one algorithm are plotted next to each other. Withinvert_grouping=Trueall boxplots of one group are plotted next to each other.- force_order
A list of algorithm names that specifies the order in which the boxplots are plotted. If you want to force the order of your groups, fix the order in the
label_grouperfunction.- matplotlib_boxplot_props
Additional properties to pass to the
sns.boxplotfunction in the matplotlib backend.
- Attributes:
- force_order
- label_grouper
- matplotlib_boxplot_props
Methods
bokeh()Create the plot using bokeh.
matplotlib([ax])Create the plot using matplotlib.
- __init__(cv_results: Dict[str, DataFrame], metric: str, use_aggregation: Literal['fold', 'single'] = 'single', overlay_scatter: bool = True, force_order: Optional[Sequence[str]] = None, label_grouper: Optional[Callable[[Series], Categorical]] = None, invert_grouping: bool = False, matplotlib_boxplot_props: Optional[Dict[str, Any]] = None) None[source]#