labelstats#

dataeval.metrics.stats.labelstats(labels: Iterable[ArrayLike]) LabelStatsOutput#

Calculates statistics for data labels

This function computes counting metrics (e.g., total per class, total per image) on the labels.

Parameters:

labels (ArrayLike, shape - [label] | [[label]] or (N,M) | (N,)) – Lists or numpy array of labels. A set of lists where each list contains all labels per image - (e.g. [[label1, label2], [label2], [label1, label3]] or [label1, label2, label1, label3]). If a numpy array, N is the number of images, M is the number of labels per image.

Returns:

A dictionary-like object containing the computed counting metrics for the labels.

Return type:

LabelStatsOutput

Examples

Calculating the statistics on labels for a set of data

>>> stats = labelstats(labels)
>>> stats.label_counts_per_class
{'chicken': 3, 'cow': 8, 'horse': 9, 'pig': 7, 'sheep': 7}
>>> stats.label_counts_per_image
[3, 2, 3, 4, 1, 5, 4, 4, 4, 4]
>>> stats.image_counts_per_label
{'chicken': 2, 'cow': 6, 'horse': 7, 'pig': 5, 'sheep': 7}
>>> (stats.image_count, stats.class_count, stats.label_count)
(10, 5, 34)