IQRDetector<T>
Models & Types · AiDotNet.AnomalyDetection.Statistical
Detects anomalies using the Interquartile Range (IQR) method.
Inheritance: ModelBase<T, Matrix<T>, Vector<T>> → AnomalyDetectorBase<T> → IQRDetector<T>
Implements: IGeneratedParameterRegistrar<T>
For Beginners
The IQR method is based on quartiles, which divide your data into four parts:
- Q1 (25th percentile): 25% of data is below this value
- Q3 (75th percentile): 75% of data is below this value
- IQR = Q3 - Q1: The range containing the middle 50% of data
Outliers are points below Q1 - kIQR or above Q3 + kIQR, where k is the multiplier (typically 1.5).
How It Works
When to use:
- Your data may not be normally distributed
- You want a robust method that isn’t affected by extreme outliers
- This is the same method used in box plots
Industry Standard Defaults:
- Multiplier: 1.5 (identifies “mild” outliers)
- Use 3.0 for “extreme” outliers only
Constructors
| Constructor | Summary |
|---|---|
IQRDetector(double multiplier, double contamination, int randomSeed) |
Creates a new IQR-based anomaly detector. |
Properties
| Property | Summary |
|---|---|
Vector<T> IQR { get; } |
Gets the IQR values for each feature. |
Vector<T> LowerBounds { get; } |
Gets the lower bounds (Q1 - multiplier * IQR) for each feature. |
Vector<T> Q1 { get; } |
Gets the Q1 (25th percentile) values for each feature. |
Vector<T> Q3 { get; } |
Gets the Q3 (75th percentile) values for each feature. |
Vector<T> UpperBounds { get; } |
Gets the upper bounds (Q3 + multiplier * IQR) for each feature. |
double Multiplier { get; } |
Gets the IQR multiplier for determining outlier boundaries. |
Methods
| Method | Summary |
|---|---|
Vector<T> ScoreAnomalies(Matrix<T> X) |
|
void Fit(Matrix<T> X) |