Linter

class dataeval.detectors.Linter(flags: ImageProperty | ImageVisuals | ImageStatistics | Sequence[ImageProperty | ImageVisuals | ImageStatistics] | None = None, outlier_method: Literal['zscore', 'modzscore', 'iqr'] = 'modzscore', outlier_threshold: float | None = None)

Calculates statistical outliers of a dataset using various statistical tests applied to each image

Parameters:
  • flags ([ImageProperty | ImageStatistics | ImageVisuals], default None) – Metric(s) to calculate for each image - calculates all metrics if None

  • outlier_method (["modzscore" | "zscore" | "iqr"], optional - default "modzscore") – Statistical method used to identify outliers

  • outlier_threshold (float, optional - default None) – Threshold value for the given outlier_method, above which data is considered an outlier. Uses method specific default if None

stats

Class to hold the value of each metric for each image

Type:

ImageStats

See also

Duplicates

Notes

There are 3 different statistical methods:

  • zscore

  • modzscore

  • iqr

The z score method is based on the difference between the data point and the mean of the data. The default threshold value for zscore is 3.
Z score = \(|x_i - \mu| / \sigma\)
The modified z score method is based on the difference between the data point and the median of the data. The default threshold value for modzscore is 3.5.
Modified z score = \(0.6745 * |x_i - x̃| / MAD\), where \(MAD\) is the median absolute deviation
The interquartile range method is based on the difference between the data point and the difference between the 75th and 25th qartile. The default threshold value for iqr is 1.5.
Interquartile range = \(threshold * (Q_3 - Q_1)\)

Examples

Initialize the Linter class:

>>> lint = Linter()

Specifying specific metrics to analyze:

>>> lint = Linter(flags=[ImageProperty.SIZE, ImageVisuals.ALL])

Specifying an outlier method:

>>> lint = Linter(outlier_method="iqr")

Specifying an outlier method and threshold:

>>> lint = Linter(outlier_method="zscore", outlier_threshold=2.5)
evaluate(images: Iterable[_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]]) dict

Returns indices of outliers with the issues identified for each

Parameters:

images (Iterable[ArrayLike], shape - (N, C, H, W)) – A dataset in an ArrayLike format. Function expects the data to have 3 dimensions, CxHxW.

Returns:

Dictionary containing the indices of outliers and a dictionary showing the issues and calculated values for the given index.

Return type:

Dict[int, Dict[str, float]]

Example

Evaluate the dataset:

>>> lint.evaluate(images)
{18: {'brightness': 0.78}, 25: {'brightness': 0.98}}