scikit_posthocs.outliers_iqr

scikit_posthocs.outliers_iqr(x: List | ndarray, ret: str = 'filtered', coef: float = 1.5) ndarray

Simple detection of potential outliers based on interquartile range (IQR). Data that lie within the lower and upper limits are considered non-outliers. The lower limit is the number that lies 1.5 IQRs below (coefficient may be changed with an argument, see Parameters) the first quartile; the upper limit is the number that lies 1.5 IQRs above the third quartile.

Parameters:
  • x (Union[List, np.ndarray]) – An array, any object exposing the array interface, containing p values.

  • ret (str = 'filtered') –

    Specifies object to be returned. Available options are:

    • filtered: return a filtered array (default)

    • outliers: return outliers

    • indices: return indices of non-outliers

    • outliers_indices: return indices of outliers

  • coef (float = 1.5) – Coefficient by which IQR is multiplied.

Returns:

One of the following objects:

  • Filtered array (default) if ret is set to filtered.

  • Array with indices of elements lying within the specified limits if ret is set to indices.

  • Array with outliers if ret is set to outliers.

  • Array with indices of outlier elements if ret is set to outliers_indices.

Return type:

numpy.ndarray

Examples

>>> x = np.array([4, 5, 6, 10, 12, 4, 3, 1, 2, 3, 23, 5, 3])
>>> outliers_iqr(x, ret = 'outliers')
array([12, 23])