SentinelGuard is an end-to-end, production-ready time-series anomaly detection system built using deep learning autoencoders. It detects abnormal patterns in historical financial data using unsupervised learning, dynamic thresholding, and interactive visualization.
🔹 Primary Model: LSTM Autoencoder (high accuracy, stable)
🔹 Secondary Model: GRU Autoencoder (fast, lightweight comparison)
🔹 Unsupervised Learning: No manual anomaly labels required
🔹 Dynamic Thresholding: Adaptive percentile-based detection
🔹 Temporal Awareness: Detects anomalies across time windows
🔹 Interactive UI: Built with Streamlit
🔹 Production-Ready Architecture
Traditional anomaly detection systems rely on static rules or labeled anomalies, which are often unavailable in real-world scenarios.
SentinelGuard solves this by:
Learning normal behavior from historical data
Detecting deviations using reconstruction error
Providing interpretable visual outputs for validation
Data Ingestion (Yahoo Finance)
↓
Preprocessing & Sequence Builder
↓
Autoencoder Models (LSTM / GRU)
↓
Reconstruction Error Calculation
↓
Dynamic Thresholding
↓
Anomaly Detection
↓
Streamlit Dashboard (Visualization)
cdacproject/
│
├── app.py # Streamlit dashboard
│
├── src/
│ ├── data_ingestion/
│ │ └── yahoo_finance_ingest.py
│ │
│ ├── preprocessing/
│ │ └── sequence_builder.py
│ │
│ ├── labeling/
│ │ └── volatility_labeling.py
│ │
│ ├── models/
│ │ ├── lstm_autoencoder.py # Primary model
│ │ └── gru_autoencoder.py # Secondary model
│ │
│ └── evaluation/
│ └── lstm_point_evaluate.py
│
├── data/
│ └── processed/
│ └── finance/
│ ├── sp500_labeled.csv
│ ├── lstm_reconstruction_errors.npy
│ └── gru_reconstruction_errors.npy
│
└── README.md
Captures long-term temporal dependencies
More stable and accurate for financial time series
Used as the main decision model
Faster and computationally lighter
Used for comparison and validation
Demonstrates engineering trade-offs
Train autoencoder on historical data
Compute reconstruction error
Apply model-aware dynamic threshold
LSTM → stricter threshold
GRU → relaxed threshold
Points exceeding threshold are flagged as anomalies
Results are visualized in:
Original time-series space
Reconstruction error space
Model selector (LSTM / GRU)
Accuracy (proxy metric)
Total anomalies detected
Historical price chart with anomaly markers
Reconstruction error graph with threshold
Clear explanation of system design
conda create -n sentinelguard python=3.10
conda activate sentinelguardpip install numpy pandas matplotlib plotly streamlit tensorflow yfinancepython src/data_ingestion/yahoo_finance_ingest.pypython src/preprocessing/sequence_builder.pypython src/models/lstm_autoencoder.py
python src/models/gru_autoencoder.pypython src/evaluation/lstm_point_evaluate.pystreamlit run app.pyDetection Accuracy (Proxy)
Number of Anomalies Detected
Precision/Recall/F1 are avoided in UI due to the unsupervised nature of the task.
| Model | Anomalies Detected | Accuracy (Proxy) |
|---|---|---|
| LSTM | ~85–95 | ~0.85–0.90 |
| GRU | ~110–130 | ~0.79–0.85 |
Accuracy is a proxy metric due to unsupervised learning
Real-time streaming can be added as future work
Thresholds may need tuning for different datasets
Real-time Kafka / WebSocket ingestion
Multivariate time-series support
Adaptive threshold learning
Alerting system integration