NBEATSDetector<T>
Models & Types · AiDotNet.AnomalyDetection.TimeSeries
Implements N-BEATS (Neural Basis Expansion Analysis for Time Series) for anomaly detection.
Inheritance: ModelBase<T, Matrix<T>, Vector<T>> → AnomalyDetectorBase<T> → NBEATSDetector<T>
Implements: IGeneratedParameterRegistrar<T>
For Beginners
N-BEATS is a deep neural architecture for time series forecasting that uses stacked blocks with basis expansion. For anomaly detection, it predicts the next value and uses the prediction error as the anomaly score.
How It Works
The algorithm works by:
- Stack multiple blocks, each outputting a partial forecast and backcast
- Each block uses fully-connected layers with basis expansion
- Residual learning allows progressive refinement
- High prediction errors indicate anomalies
When to use:
- Univariate or multivariate time series
- When interpretability of forecasts matters
- Long-horizon forecasting-based anomaly detection
Industry Standard Defaults:
- Number of stacks: 2
- Number of blocks per stack: 3
- Hidden dimensions: 64
- Lookback: 10
- Epochs: 50
- Contamination: 0.1 (10%)
Reference: Oreshkin, B. N., et al. (2020). “N-BEATS: Neural Basis Expansion Analysis for Interpretable Time Series Forecasting.” ICLR.
Constructors
| Constructor | Summary |
|---|---|
NBEATSDetector(int numStacks, int numBlocks, int hiddenDim, int lookback, int epochs, double learningRate, double contamination, int randomSeed) |
Creates a new N-BEATS anomaly detector. |
Properties
| Property | Summary |
|---|---|
int Lookback { get; } |
Gets the lookback window size. |
int NumBlocks { get; } |
Gets the number of blocks per stack. |
int NumStacks { get; } |
Gets the number of stacks. |
Methods
| Method | Summary |
|---|---|
Vector<T> ScoreAnomalies(Matrix<T> X) |
|
void Fit(Matrix<T> X) |