STLDetector<T>
Models & Types · AiDotNet.AnomalyDetection.TimeSeries
Detects anomalies using STL (Seasonal and Trend decomposition using Loess).
Inheritance: ModelBase<T, Matrix<T>, Vector<T>> → AnomalyDetectorBase<T> → STLDetector<T>
Implements: IGeneratedParameterRegistrar<T>
For Beginners
STL decomposes a time series into three components: trend, seasonal, and residual. The residual component contains the irregular variations. Large residuals indicate anomalies that don’t fit the expected trend and seasonal patterns.
How It Works
The algorithm works by:
- Apply STL decomposition to extract trend, seasonal, and residual
- Standardize the residual component
- Large standardized residuals indicate anomalies
When to use:
- Time series with clear trend and/or seasonal patterns
- When anomalies disrupt expected patterns
- Sales, weather, sensor data with periodicity
Industry Standard Defaults:
- Season length: 7 (weekly pattern)
- Trend smoothness: 15
- Contamination: 0.1 (10%)
Reference: Cleveland, R.B., et al. (1990). “STL: A Seasonal-Trend Decomposition Procedure Based on Loess.” Journal of Official Statistics.
Constructors
| Constructor | Summary |
|---|---|
STLDetector(int seasonLength, int trendSmoothness, double contamination, int randomSeed) |
Creates a new STL anomaly detector. |
Properties
| Property | Summary |
|---|---|
int SeasonLength { get; } |
Gets the season length. |
int TrendSmoothness { get; } |
Gets the trend smoothness parameter. |
Methods
| Method | Summary |
|---|---|
Vector<T> ScoreAnomalies(Matrix<T> X) |
|
void Fit(Matrix<T> X) |