CompStats.utils¶
- progress_bar(arg, use_tqdm: bool = True, **kwargs)[source]¶
Wrap arg in a
tqdm.tqdmprogress bar.Returns arg unchanged when tqdm is not installed or
use_tqdmis False, so callers can iterate over the result the same way regardless of whether a progress bar is actually shown.- Parameters:
arg – Iterable to wrap.
use_tqdm (bool) – Whether to show the progress bar, default=True.
kwargs – Extra keyword arguments passed to
tqdm.tqdm.
- Returns:
arg, optionally wrapped in a
tqdm.tqdmiterator.
- metrics_docs(hy_name='y_pred', bib: bool = True)[source]¶
Decorator that injects the shared
Perfdocstring into aCompStats.metricswrapper (e.g.f1_score).- Parameters:
hy_name (str) – Name used for the predictions parameter in the generated docstring (e.g.
y_predory_score, matching the wrappedsklearn.metricsfunction’s own parameter name).bib (bool) – Whether the wrapped function’s measure is score-type (bigger is better) or error-type (smaller is better); used only to describe the measure’s direction in the generated docstring, matching the
.BiBtag set on the wrapper’s.measurefactory.
- dataframe(instance, value_name: str = 'Score', var_name: str = 'Performance', alg_legend: str = 'Algorithm', perf_names: list = None)[source]¶
Melt a
PerforDifferenceinstance’s bootstrap samples into a long-formatpandas.DataFrame, ready for seaborn’scatplot(used byplotandplot).- Parameters:
instance (CompStats.interface.Perf or CompStats.interface.Difference) – Instance holding the bootstrap samples to melt.
value_name (str) – Column name for the statistic’s value.
var_name (str) – Column name identifying which measure a row belongs to, only used when instance holds more than one measure.
alg_legend (str) – Column name identifying which algorithm a row belongs to.
perf_names (list) – Display name for each measure, only used when instance holds more than one measure.
- Returns:
Long-format dataframe with one row per bootstrap sample.
- Return type: