Upload 19 files
Browse files- .gitattributes +2 -0
- LICENSE +21 -0
- Neuro Symbolic AI - Forecasting Trend Predictor.docx +3 -0
- README.md +52 -16
- SymbolicSeem-NeuroAI-LSTM-Stocks-Forecasting-Report.pdf +3 -0
- configs/model_config.yaml +50 -0
- configs/rules_config.yaml +58 -0
- gitignore +42 -0
- models_backup_50stocks.zip +3 -0
- models_backup_50stocks/kg_rules_50.pkl +3 -0
- models_backup_50stocks/model_50stock.pth +3 -0
- models_backup_50stocks/model_50stocks.pth +3 -0
- models_backup_50stocks/multi_config.pkl +3 -0
- models_backup_50stocks/multi_kg_rules.pkl +3 -0
- models_backup_50stocks/multi_scalers.pkl +3 -0
- models_backup_50stocks/multi_stock_model.pth +3 -0
- models_backup_50stocks/neural_checkpoint.pth +3 -0
- models_backup_50stocks/scalers_50.pkl +3 -0
- neuro-symbolic-ai-forecasting.ipynb +0 -0
- requirements.txt +104 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
Neuro[[:space:]]Symbolic[[:space:]]AI[[:space:]]-[[:space:]]Forecasting[[:space:]]Trend[[:space:]]Predictor.docx filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
SymbolicSeem-NeuroAI-LSTM-Stocks-Forecasting-Report.pdf filter=lfs diff=lfs merge=lfs -text
|
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2024 Sanaullah Tareen
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
Neuro Symbolic AI - Forecasting Trend Predictor.docx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:51e8e7a3aff51e237bef1a381972c45b556333960b19b2f32e4ebb508afacc59
|
| 3 |
+
size 213346
|
README.md
CHANGED
|
@@ -1,17 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
- defeatbeta/yahoo-finance-data
|
| 5 |
-
language:
|
| 6 |
-
- en
|
| 7 |
-
metrics:
|
| 8 |
-
- r_squared
|
| 9 |
-
pipeline_tag: graph-ml
|
| 10 |
-
tags:
|
| 11 |
-
- graph-machine-learning
|
| 12 |
-
- lstm
|
| 13 |
-
- neuro-ai
|
| 14 |
-
- symbolic-seen
|
| 15 |
-
- unpredictable-market-trend
|
| 16 |
-
- stock-price-prediction
|
| 17 |
-
---
|
|
|
|
| 1 |
+
# Neuro-Symbolic AI Forecasting: The Symbolic Seam
|
| 2 |
+
|
| 3 |
+
## What It Does
|
| 4 |
+
Combines neural forecasting (LSTM) with Knowledge Graph constraints via Quadratic Programming. Ensures predictions respect real-world limits — even during crises.
|
| 5 |
+
|
| 6 |
+
## Key Results
|
| 7 |
+
| Condition | Neural Baseline | Symbolic Seam |
|
| 8 |
+
|-----------|---|---|
|
| 9 |
+
| Normal markets | RMSE 3.698 | RMSE 3.695 (identical) |
|
| 10 |
+
| Black Swan crisis | 95.33% violations | 6.00% violations ✅ |
|
| 11 |
+
| Violations prevented | — | **938 / 1,050** |
|
| 12 |
+
|
| 13 |
+
## How It Works
|
| 14 |
+
1. **System 1 (LSTM)**: Predicts prices from historical data
|
| 15 |
+
2. **System 2 (KG)**: Defines operational bounds (min/max price, daily change limit)
|
| 16 |
+
3. **Symbolic Seam**: Projects forecast into constraint space using QP solver
|
| 17 |
+
|
| 18 |
+
## Quick Start
|
| 19 |
+
```bash
|
| 20 |
+
pip install yfinance cvxpy torch pandas scikit-learn -q
|
| 21 |
+
jupyter notebook Neuro_Symbolic_Forecasting_Kaggle.ipynb
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
## Dataset
|
| 25 |
+
- **Source**: Yahoo Finance (yfinance)
|
| 26 |
+
- **Stocks**: 50 S&P 500 stocks
|
| 27 |
+
- **Period**: Jan 2020 – Jan 2024
|
| 28 |
+
- **Sequences**: 48,800 (30-day windows)
|
| 29 |
+
|
| 30 |
+
## Model
|
| 31 |
+
- LSTM: 64 hidden, 2 layers
|
| 32 |
+
- Training: 15 epochs, batch 64
|
| 33 |
+
- Best val loss: 0.000539
|
| 34 |
+
|
| 35 |
+
## Key Findings
|
| 36 |
+
- **Normal**: Zero accuracy penalty (3.698 → 3.695 RMSE)
|
| 37 |
+
- **Crisis**: 89.33pp improvement in constraint compliance (95.33% → 6.00% violations)
|
| 38 |
+
- **Per-stock**: High-volatility stocks improve most (CRM +5.2%, DHR +1.7%)
|
| 39 |
+
|
| 40 |
+
## Why This Matters
|
| 41 |
+
Neural models fail when rules change (tariffs, limits, regulations). Symbolic Seam enforces hard constraints at inference time without retraining.
|
| 42 |
+
|
| 43 |
+
## Files
|
| 44 |
+
- `Neuro_Symbolic_Forecasting_Kaggle.ipynb` — Single notebook, all stages
|
| 45 |
+
- `IEEE_Symbolic_Seam_Full.docx` — Full research paper
|
| 46 |
+
- `models_backup_50stock.zip` — Trained model + config
|
| 47 |
+
|
| 48 |
+
## Author
|
| 49 |
+
Sanaullah Tareen | PAF-IAST | [@SanaullahTareen](https://github.com/SanaullahTareen)
|
| 50 |
+
|
| 51 |
---
|
| 52 |
+
|
| 53 |
+
Full details in IEEE paper or Kaggle notebook.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SymbolicSeem-NeuroAI-LSTM-Stocks-Forecasting-Report.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:68437c396feca66b4bb5b7a232b08e70ea958eb8c517d8f5ec5a73a1ba18a00f
|
| 3 |
+
size 294554
|
configs/model_config.yaml
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Model Configuration for Neuro-Symbolic Forecasting
|
| 2 |
+
# System 1: Neural Perception Layer (LSTM)
|
| 3 |
+
|
| 4 |
+
model:
|
| 5 |
+
type: "LSTM"
|
| 6 |
+
shared: true # One model, all 50 stocks
|
| 7 |
+
|
| 8 |
+
lstm:
|
| 9 |
+
input_size: 1
|
| 10 |
+
hidden_size: 64
|
| 11 |
+
num_layers: 2
|
| 12 |
+
dropout: 0.2
|
| 13 |
+
batch_first: true
|
| 14 |
+
|
| 15 |
+
output_layer:
|
| 16 |
+
type: "Linear"
|
| 17 |
+
output_size: 1
|
| 18 |
+
|
| 19 |
+
training:
|
| 20 |
+
optimizer: "Adam"
|
| 21 |
+
learning_rate: 0.001
|
| 22 |
+
weight_decay: 0.0
|
| 23 |
+
epochs: 15
|
| 24 |
+
batch_size: 64
|
| 25 |
+
early_stopping_patience: 3
|
| 26 |
+
|
| 27 |
+
data:
|
| 28 |
+
sequence_length: 30 # 30-day look-back window
|
| 29 |
+
forecast_horizon: 1 # Predict next 1 day
|
| 30 |
+
train_split: 0.70
|
| 31 |
+
val_split: 0.15
|
| 32 |
+
test_split: 0.15
|
| 33 |
+
normalization: "MinMaxScaler"
|
| 34 |
+
scaler_range: [0, 1]
|
| 35 |
+
|
| 36 |
+
hardware:
|
| 37 |
+
device: "cuda"
|
| 38 |
+
multi_gpu: true
|
| 39 |
+
gpus: 2
|
| 40 |
+
mixed_precision: false
|
| 41 |
+
|
| 42 |
+
paths:
|
| 43 |
+
model_save: "models/neural_checkpoint.pth"
|
| 44 |
+
scaler_save: "models/scaler.pkl"
|
| 45 |
+
best_model: "models/multi_stock_model.pth"
|
| 46 |
+
|
| 47 |
+
monitoring:
|
| 48 |
+
log_frequency: 5 # Log every 5 epochs
|
| 49 |
+
save_best: true
|
| 50 |
+
best_metric: "val_loss"
|
configs/rules_config.yaml
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Knowledge Graph Configuration for Symbolic Seam
|
| 2 |
+
# System 2: Symbolic Logic Layer (Constraints)
|
| 3 |
+
|
| 4 |
+
constraints:
|
| 5 |
+
price_bounds:
|
| 6 |
+
type: "relative_to_mean"
|
| 7 |
+
min_multiplier: 0.95 # 5% below mean
|
| 8 |
+
max_multiplier: 1.05 # 5% above mean
|
| 9 |
+
description: "Price cannot deviate >5% from historical mean"
|
| 10 |
+
|
| 11 |
+
rate_of_change:
|
| 12 |
+
type: "daily_change_limit"
|
| 13 |
+
max_daily_change_pct: 0.05 # 5% max change per day
|
| 14 |
+
description: "Circuit breaker: limit 5% move in single day"
|
| 15 |
+
|
| 16 |
+
market_hours:
|
| 17 |
+
type: "trading_hours"
|
| 18 |
+
enabled: false
|
| 19 |
+
market_open: "09:30"
|
| 20 |
+
market_close: "16:00"
|
| 21 |
+
timezone: "America/New_York"
|
| 22 |
+
|
| 23 |
+
trading_halts:
|
| 24 |
+
type: "blackout_dates"
|
| 25 |
+
enabled: false
|
| 26 |
+
holidays: ["2024-01-01", "2024-07-04", "2024-12-25"]
|
| 27 |
+
description: "NYSE closed on holidays"
|
| 28 |
+
|
| 29 |
+
solver:
|
| 30 |
+
type: "QP"
|
| 31 |
+
backend: "OSQP"
|
| 32 |
+
timeout_ms: 2
|
| 33 |
+
verbose: false
|
| 34 |
+
max_iterations: 100
|
| 35 |
+
|
| 36 |
+
constraint_enforcement:
|
| 37 |
+
method: "hard" # Hard constraints (feasibility guaranteed)
|
| 38 |
+
fallback: "clamp" # If QP fails, clamp to bounds
|
| 39 |
+
projection_type: "l2" # L2 norm minimization (closest point)
|
| 40 |
+
|
| 41 |
+
paths:
|
| 42 |
+
kg_save: "models/kg_rules_50.pkl"
|
| 43 |
+
bounds_save: "models/bounds.json"
|
| 44 |
+
|
| 45 |
+
stocks:
|
| 46 |
+
count: 50
|
| 47 |
+
list: ["AAPL", "MSFT", "GOOGL", "AMZN", "TSLA", "JPM", "V", "JNJ",
|
| 48 |
+
"WMT", "XOM", "NVDA", "META", "PG", "KO", "DIS", "BAC",
|
| 49 |
+
"HD", "MA", "PFE", "CSCO", "INTC", "VZ", "ADBE", "NFLX",
|
| 50 |
+
"CRM", "ABT", "T", "MRK", "PEP", "AVGO", "COST", "TMO",
|
| 51 |
+
"ACN", "NKE", "MCD", "LLY", "DHR", "TXN", "NEE", "UPS",
|
| 52 |
+
"PM", "QCOM", "HON", "UNH", "LOW", "IBM", "GE", "CAT", "BA", "AMD"]
|
| 53 |
+
|
| 54 |
+
stress_test:
|
| 55 |
+
black_swan_enabled: true
|
| 56 |
+
shock_magnitude: 0.50 # 50% price spike
|
| 57 |
+
test_period: "2020-03-01:2020-03-31" # COVID crash
|
| 58 |
+
measure_violations: true
|
gitignore
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Python
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.py[cod]
|
| 4 |
+
*$py.class
|
| 5 |
+
*.so
|
| 6 |
+
.Python
|
| 7 |
+
env/
|
| 8 |
+
venv/
|
| 9 |
+
ENV/
|
| 10 |
+
build/
|
| 11 |
+
dist/
|
| 12 |
+
*.egg-info/
|
| 13 |
+
*.egg
|
| 14 |
+
|
| 15 |
+
# Jupyter
|
| 16 |
+
.ipynb_checkpoints/
|
| 17 |
+
*.ipynb_checkpoints
|
| 18 |
+
|
| 19 |
+
# Data
|
| 20 |
+
data/raw/*.csv
|
| 21 |
+
data/raw/*.json
|
| 22 |
+
data/processed/*.npy
|
| 23 |
+
data/processed/*.pkl
|
| 24 |
+
|
| 25 |
+
# Models & Results
|
| 26 |
+
models/*.pth
|
| 27 |
+
models/*.pkl
|
| 28 |
+
results/metrics/*.csv
|
| 29 |
+
results/plots/*.png
|
| 30 |
+
results/predictions/*.csv
|
| 31 |
+
|
| 32 |
+
# IDE
|
| 33 |
+
.vscode/
|
| 34 |
+
.idea/
|
| 35 |
+
*.swp
|
| 36 |
+
|
| 37 |
+
# OS
|
| 38 |
+
.DS_Store
|
| 39 |
+
Thumbs.db
|
| 40 |
+
|
| 41 |
+
# Logs
|
| 42 |
+
*.log
|
models_backup_50stocks.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a45173e223a2fbe0bc17af50deb89cc8c40b780f2e7dc2f81284dc20d93cdd66
|
| 3 |
+
size 758692
|
models_backup_50stocks/kg_rules_50.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1e482732a420519571370f1629831301a41aab426ae9ee5c2e3e1802207c600c
|
| 3 |
+
size 2210
|
models_backup_50stocks/model_50stock.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dd7143078d05912a6451b53adc79b94ca19bd3be3e0ef940eefb4a2e247ad3cc
|
| 3 |
+
size 204951
|
models_backup_50stocks/model_50stocks.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:448752e5b0f17ce5b06c52c9a5784635a1809b12c0e55c61765e3d3553a5840a
|
| 3 |
+
size 204960
|
models_backup_50stocks/multi_config.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4d15bcc04d0afd5176559372aa82b76215ecf8113fd1ccb53d01feacd3f9e000
|
| 3 |
+
size 139
|
models_backup_50stocks/multi_kg_rules.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:de9a1ab37c4c2d87f77f63f2bfc8ae2c72405b5ce39dea74d1cab42be671ec03
|
| 3 |
+
size 706
|
models_backup_50stocks/multi_scalers.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:60a17f08844a5c7c181f28d42a3137f15dfcc3e52a2118cec86dcb405bcd03a8
|
| 3 |
+
size 3882
|
models_backup_50stocks/multi_stock_model.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a68fc384dae0397859a2ee23e4d05acaf4ba5cc80b4cef84314222943beab83c
|
| 3 |
+
size 204987
|
models_backup_50stocks/neural_checkpoint.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e66972677490a0f292117f5df87d84c9704d70eea9eee6c8dfe2e2ff57433636
|
| 3 |
+
size 204987
|
models_backup_50stocks/scalers_50.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4222911e5e4a9c7d41c533cab3f2bc5288b0fe0b436286d86a3597b09a5185b9
|
| 3 |
+
size 12246
|
neuro-symbolic-ai-forecasting.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
requirements.txt
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Neuro-Symbolic AI Forecasting - Requirements
|
| 2 |
+
|
| 3 |
+
# ============================================
|
| 4 |
+
# Python Version
|
| 5 |
+
# ============================================
|
| 6 |
+
# Python 3.9+ required
|
| 7 |
+
# Tested on: Python 3.10, 3.11
|
| 8 |
+
|
| 9 |
+
# ============================================
|
| 10 |
+
# Core Dependencies
|
| 11 |
+
# ============================================
|
| 12 |
+
|
| 13 |
+
# Deep Learning Framework
|
| 14 |
+
torch>=2.0.0 # PyTorch for neural network and GPU support
|
| 15 |
+
torchvision>=0.15.0 # For data loading utilities
|
| 16 |
+
|
| 17 |
+
# Data Processing & Analysis
|
| 18 |
+
numpy>=1.21.0 # Numerical computing
|
| 19 |
+
pandas>=1.3.0 # Data manipulation and time series handling
|
| 20 |
+
scikit-learn>=1.0.0 # Machine learning utilities (MinMaxScaler)
|
| 21 |
+
|
| 22 |
+
# Financial Data
|
| 23 |
+
yfinance>=0.2.28 # Download stock data from Yahoo Finance
|
| 24 |
+
|
| 25 |
+
# Optimization (Symbolic Layer)
|
| 26 |
+
cvxpy>=1.3.0 # Convex optimization for symbolic seam projection
|
| 27 |
+
osqp>=0.6.2 # OSQP solver (backend for cvxpy)
|
| 28 |
+
|
| 29 |
+
# Visualization
|
| 30 |
+
matplotlib>=3.5.0 # Plotting and visualization
|
| 31 |
+
|
| 32 |
+
# ============================================
|
| 33 |
+
# Optional Dependencies
|
| 34 |
+
# ============================================
|
| 35 |
+
|
| 36 |
+
# Jupyter Notebooks
|
| 37 |
+
jupyter>=1.0.0 # Jupyter notebook support
|
| 38 |
+
ipython>=8.0.0 # Enhanced interactive Python
|
| 39 |
+
|
| 40 |
+
# Development & Testing
|
| 41 |
+
pytest>=7.0.0 # Unit testing framework
|
| 42 |
+
black>=22.0.0 # Code formatting
|
| 43 |
+
pylint>=2.12.0 # Code linting
|
| 44 |
+
|
| 45 |
+
# ============================================
|
| 46 |
+
# GPU/CPU Requirements
|
| 47 |
+
# ============================================
|
| 48 |
+
|
| 49 |
+
# GPU Support (Optional but Recommended)
|
| 50 |
+
# For NVIDIA GPU: Install CUDA 11.8 or 12.1
|
| 51 |
+
# Command: pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
|
| 52 |
+
|
| 53 |
+
# For CPU-only (slower training, 10-20x slower on large datasets):
|
| 54 |
+
# Already included in default torch installation
|
| 55 |
+
|
| 56 |
+
# ============================================
|
| 57 |
+
# Hardware Specifications
|
| 58 |
+
# ============================================
|
| 59 |
+
|
| 60 |
+
# Minimum (CPU-only):
|
| 61 |
+
# - Processor: 4 cores
|
| 62 |
+
# - RAM: 8 GB
|
| 63 |
+
# - Storage: 2 GB
|
| 64 |
+
# - Time to train: ~30 minutes per epoch
|
| 65 |
+
|
| 66 |
+
# Recommended (GPU):
|
| 67 |
+
# - GPU: NVIDIA with 4GB+ VRAM (tested on T4, V100)
|
| 68 |
+
# - Processor: 8 cores
|
| 69 |
+
# - RAM: 16 GB
|
| 70 |
+
# - Storage: 5 GB
|
| 71 |
+
# - Time to train: ~1-2 minutes per epoch
|
| 72 |
+
|
| 73 |
+
# ============================================
|
| 74 |
+
# Installation Instructions
|
| 75 |
+
# ============================================
|
| 76 |
+
|
| 77 |
+
# 1. Create virtual environment
|
| 78 |
+
# python -m venv neuro-symbolic-env
|
| 79 |
+
# .\neuro-symbolic-env\Scripts\activate # Windows
|
| 80 |
+
# source neuro-symbolic-env/bin/activate # Linux/Mac
|
| 81 |
+
|
| 82 |
+
# 2. Install basic requirements
|
| 83 |
+
# pip install -r requirements.txt
|
| 84 |
+
|
| 85 |
+
# 3. For GPU support (NVIDIA only)
|
| 86 |
+
# pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
|
| 87 |
+
|
| 88 |
+
# 4. Verify installation
|
| 89 |
+
# python -c "import torch; print(torch.__version__); print(torch.cuda.is_available())"
|
| 90 |
+
|
| 91 |
+
# ============================================
|
| 92 |
+
# Version Pinning (Exact Versions Used)
|
| 93 |
+
# ============================================
|
| 94 |
+
|
| 95 |
+
# Uncomment below to use exact versions that were tested:
|
| 96 |
+
# torch==2.1.0
|
| 97 |
+
# torchvision==0.16.0
|
| 98 |
+
# numpy==1.24.3
|
| 99 |
+
# pandas==2.0.3
|
| 100 |
+
# scikit-learn==1.3.0
|
| 101 |
+
# yfinance==0.2.32
|
| 102 |
+
# cvxpy==1.3.2
|
| 103 |
+
# matplotlib==3.7.2
|
| 104 |
+
# jupyter==1.0.0
|