IQRClipper<T>

Models & Types · AiDotNet.Preprocessing.OutlierHandling

Clips outliers using the Interquartile Range (IQR) method.

Inheritance: TransformerBase<T, Matrix<T>, Matrix<T>> → IQRClipper<T>

For Beginners

The IQR is the range where the middle 50% of data falls. Values outside 1.5× this range are considered outliers:

  • Q1 (25th percentile): 25% of data is below this value
  • Q3 (75th percentile): 75% of data is below this value
  • IQR = Q3 - Q1: The spread of the middle 50%
  • Outliers: Values below Q1 - 1.5×IQR or above Q3 + 1.5×IQR

How It Works

IQRClipper identifies outliers using the IQR method:

  • Lower bound = Q1 - k * IQR
  • Upper bound = Q3 + k * IQR

where IQR = Q3 - Q1 and k is the multiplier (default 1.5).

This is the same method used in box plots for identifying outliers. A multiplier of 1.5 identifies “mild” outliers, while 3.0 identifies “extreme” outliers.

Constructors

Constructor Summary
IQRClipper(double multiplier, int[] columnIndices) Creates a new instance of IQRClipper.

Properties

Property Summary
Vector<T> IQRValues { get; } Gets the IQR values for each feature.
Vector<T> LowerBounds { get; } Gets the fitted lower bounds for each feature.
Vector<T> Q1Values { get; } Gets the Q1 (25th percentile) values for each feature.
Vector<T> Q3Values { get; } Gets the Q3 (75th percentile) values for each feature.
Vector<T> UpperBounds { get; } Gets the fitted upper bounds for each feature.
bool SupportsInverseTransform { get; } Gets whether this transformer supports inverse transformation.
double Multiplier { get; } Gets the IQR multiplier for determining outlier boundaries.

Methods

Method Summary
bool[] GetOutlierMask(Matrix<T> data) Gets a mask indicating which values are outliers in the input data.
int[] CountOutliersPerFeature(Matrix<T> data) Counts the number of outliers per feature.
string[] GetFeatureNamesOut(string[] inputFeatureNames) Gets the output feature names after transformation.