-
-
Notifications
You must be signed in to change notification settings - Fork 7
Fix issue 402 in AiDotNet #446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…n for Issue #402 This commit implements Phase 3 of advanced time series capabilities as requested in issue #402: **Foundation Models (Critical Priority):** - Temporal Fusion Transformer (TFT): Multi-horizon interpretable forecasting with attention mechanisms, variable selection, and probabilistic quantile predictions - Chronos Foundation Model: Zero-shot forecasting using tokenization and transformer architecture inspired by language models **Advanced Architectures (High Priority):** - N-HiTS: Neural Hierarchical Interpolation for Time Series with multi-rate sampling, hierarchical pooling, and interpolation-based basis functions for efficient long-horizon forecasting - DeepAR: Probabilistic autoregressive forecasting with LSTM networks, supporting multiple related time series and uncertainty quantification - Informer: Efficient transformer with ProbSparse attention (O(L log L) complexity) and self-attention distilling for long-sequence forecasting **Anomaly Detection (High Priority):** - DeepANT: Deep learning-based anomaly detection using CNN for time series prediction and error-based anomaly scoring - LSTM-VAE: Variational Autoencoder with LSTM encoder/decoder for unsupervised anomaly detection via reconstruction error **Key Features:** - Multi-horizon forecasting capabilities across all models - Probabilistic prediction support with quantile forecasts (TFT, DeepAR, Chronos) - Comprehensive options classes for model configuration - Serialization/deserialization support for model persistence - Anomaly detection subdirectory structure under src/TimeSeries/AnomalyDetection/ - All models follow existing TimeSeriesModelBase patterns for consistency **Technical Implementation:** - All models inherit from TimeSeriesModelBase<T> - Support for generic numeric types (float, double) - Comprehensive XML documentation for beginners and advanced users - Parameter-efficient architectures with proper initialization - Training with numerical gradient computation (production systems would use automatic differentiation) These implementations provide state-of-the-art capabilities for: - Long-horizon forecasting (N-HiTS, Informer) - Interpretable predictions (TFT) - Probabilistic forecasts (DeepAR, TFT, Chronos) - Zero-shot learning (Chronos) - Anomaly detection (DeepANT, LSTM-VAE) Addresses requirements from Issue #402 for modern time series foundation models and anomaly detection capabilities.
|
Warning Rate limit exceeded@ooples has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 27 minutes and 35 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (11)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request introduces advanced time series forecasting and anomaly detection models to the AiDotNet library, significantly expanding its capabilities for temporal data analysis.
Key Changes
- Implementation of 5 state-of-the-art forecasting models: Temporal Fusion Transformer (TFT), N-HiTS, Informer, DeepAR, and Chronos Foundation Model
- Addition of 2 anomaly detection models: LSTM-VAE and DeepANT
- Comprehensive configuration options classes for all new models with beginner-friendly documentation
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 50 comments.
Show a summary per file
| File | Description |
|---|---|
| src/TimeSeries/TemporalFusionTransformer.cs | Implements TFT with attention mechanisms, quantile predictions, and multi-horizon forecasting |
| src/TimeSeries/NHiTSModel.cs | Implements N-HiTS with hierarchical interpolation and multi-rate sampling for long-horizon forecasting |
| src/TimeSeries/InformerModel.cs | Implements efficient Informer model with ProbSparse attention for long-sequence forecasting |
| src/TimeSeries/DeepARModel.cs | Implements probabilistic DeepAR model with LSTM-based autoregressive architecture |
| src/TimeSeries/ChronosFoundationModel.cs | Implements foundation model approach with tokenization for zero-shot forecasting |
| src/TimeSeries/AnomalyDetection/LSTMVAE.cs | Implements LSTM-VAE for anomaly detection using reconstruction error |
| src/TimeSeries/AnomalyDetection/DeepANT.cs | Implements CNN-based DeepANT for unsupervised anomaly detection |
| src/Models/Options/TemporalFusionTransformerOptions.cs | Configuration options for TFT with extensive documentation |
| src/Models/Options/NHiTSOptions.cs | Configuration options for N-HiTS with pooling and interpolation settings |
| src/Models/Options/InformerOptions.cs | Configuration options for Informer with distilling parameters; contains formatting issue |
| src/Models/Options/DeepAROptions.cs | Configuration options for DeepAR with probabilistic forecasting settings |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// the sequence length of the previous one. | ||
| /// </para> | ||
| /// </remarks> | ||
| public int DistillingFactor { get; set} = 2; |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space before closing brace in property accessor. Should be { get; set; } not { get; set} to maintain consistent formatting with the rest of the file.
| public int DistillingFactor { get; set} = 2; | |
| public int DistillingFactor { get; set; } = 2; |
| if (q <= 0 || q >= 1) | ||
| throw new ArgumentException("Quantile levels must be between 0 and 1."); |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validation for quantile levels uses an exclusive comparison (q <= 0 || q >= 1), but quantiles of exactly 0 or 1 are valid edge cases representing minimum and maximum values. The condition should be q < 0 || q > 1 instead.
| if (q <= 0 || q >= 1) | |
| throw new ArgumentException("Quantile levels must be between 0 and 1."); | |
| if (q < 0 || q > 1) | |
| throw new ArgumentException("Quantile levels must be between 0 and 1 (inclusive)."); |
| foreach (var q in _options.QuantileLevels) | ||
| { | ||
| if (q <= 0 || q >= 1) | ||
| throw new ArgumentException("Quantile levels must be between 0 and 1."); | ||
| } |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This foreach loop implicitly filters its target sequence - consider filtering the sequence explicitly using '.Where(...)'.
| foreach (var error in predictionErrors) | ||
| { | ||
| T diff = _numOps.Subtract(error, mean); | ||
| variance = _numOps.Add(variance, _numOps.Multiply(diff, diff)); | ||
| } |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This foreach loop immediately maps its iteration variable to another variable - consider mapping the sequence explicitly using '.Select(...)'.
| foreach (var lstm in _lstmLayers) | ||
| { | ||
| var parameters = lstm.GetParameters(); | ||
| writer.Write(parameters.Length); | ||
| for (int i = 0; i < parameters.Length; i++) | ||
| writer.Write(Convert.ToDouble(parameters[i])); | ||
| } |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This foreach loop immediately maps its iteration variable to another variable - consider mapping the sequence explicitly using '.Select(...)'.
| { | ||
| private readonly NHiTSOptions<T> _options; | ||
| private readonly INumericOperations<T> _numOps; | ||
| private List<NHiTSStack<T>> _stacks; |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Field '_stacks' can be 'readonly'.
| private List<NHiTSStack<T>> _stacks; | |
| private readonly List<NHiTSStack<T>> _stacks; |
| private readonly int _hiddenSize; | ||
| private readonly int _numLayers; | ||
| private readonly int _poolingSize; | ||
| private List<Matrix<T>> _weights; |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Field '_weights' can be 'readonly'.
| private List<Matrix<T>> _weights; | |
| private readonly List<Matrix<T>> _weights; |
| private readonly int _numLayers; | ||
| private readonly int _poolingSize; | ||
| private List<Matrix<T>> _weights; | ||
| private List<Vector<T>> _biases; |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Field '_biases' can be 'readonly'.
| private List<Vector<T>> _biases; | |
| private readonly List<Vector<T>> _biases; |
| private readonly INumericOperations<T> _numOps; | ||
|
|
||
| // Model components | ||
| private List<Matrix<T>> _weights; |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Field '_weights' can be 'readonly'.
| private List<Matrix<T>> _weights; | |
| private readonly List<Matrix<T>> _weights; |
|
|
||
| // Model components | ||
| private List<Matrix<T>> _weights; | ||
| private List<Vector<T>> _biases; |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Field '_biases' can be 'readonly'.
| private List<Vector<T>> _biases; | |
| private readonly List<Vector<T>> _biases; |
…n for Issue #402
This commit implements Phase 3 of advanced time series capabilities as requested in issue #402:
Foundation Models (Critical Priority):
Advanced Architectures (High Priority):
Anomaly Detection (High Priority):
Key Features:
Technical Implementation:
These implementations provide state-of-the-art capabilities for:
Addresses requirements from Issue #402 for modern time series foundation models and anomaly detection capabilities.
User Story / Context
merge-dev2-to-masterSummary
Verification
Copilot Review Loop (Outcome-Based)
Record counts before/after your last push:
Files Modified
Notes