File size: 4,470 Bytes
4a5fd15
 
 
 
 
 
 
1914d4d
4a5fd15
dadd5fa
d777fcd
dadd5fa
d777fcd
dadd5fa
bbfeada
dadd5fa
b7693e3
d777fcd
b7693e3
dadd5fa
 
 
 
 
 
 
 
 
 
 
d777fcd
b7693e3
d777fcd
dadd5fa
5862689
dadd5fa
 
 
bbfeada
dadd5fa
 
 
b7693e3
dadd5fa
 
d777fcd
dadd5fa
d777fcd
dadd5fa
 
 
 
 
 
 
 
d777fcd
dadd5fa
 
 
 
b7693e3
dadd5fa
b7693e3
 
 
 
 
 
 
dadd5fa
 
 
b7693e3
 
 
 
 
dadd5fa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5862689
dadd5fa
 
b7693e3
dadd5fa
 
 
b7693e3
5862689
dadd5fa
d777fcd
b7693e3
 
 
d777fcd
dadd5fa
 
 
b7693e3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
---
license: mit
language:
- en
tags:
- futurepredictionai
- ai
pipeline_tag: time-series-forecasting
---
# Future Prediction Models (6 topics + Unified)

An end-to-end multi-domain AI forecasting system. Real datasets, two model modes, ChatGPT-style predictions.

## Models: separate vs unified

- **Separate** (`model_<topic>.pt`) — 6 dedicated 2-layer LSTMs, one per topic
- **Unified** (`unified_model.pt`) — One combined model for all 6 domains: shared LSTM backbone + per-domain embedding + per-domain heads, trained jointly from merged separate models

The unified model merges weights from all 6 trained separate models into a single checkpoint, enabling cross-domain knowledge transfer and a single model that can predict any of the 6 topics.

## Topics & datasets (all real, fetched automatically)

| Topic | Asset | Source | Points |
|---|---|---|---|
| **AI** | NVIDIA daily close | Yahoo Finance | 6,938 |
| **Programming** | Daily `react` npm downloads | npm registry API | 547 |
| **Finance** | Bitcoin BTC-USD close | Yahoo Finance (Hugging Face fallback) | 4,252 |
| **Sports** | ATP world #1 Elo rating | Hugging Face tennis (93,028 matches, Elo computed from results) | 10,944 |
| **Weather** | Daily mean temperature (any city) | Open-Meteo archive | 4,248 |
| **Economy** | S&P 500 daily close | Yahoo Finance | 6,699 |

Weather city is configurable. Every topic falls back gracefully: Hugging Face search -> API -> synthetic data if fully offline.

## Validated accuracy (held-out test set, no data leakage)

**Separate per-topic models:**

| Topic | MAE | H1 MAPE | vs naive baseline |
|---|---|---|---|
| AI (NVIDIA) | $2.17 | 2.26% | ~naive |
| Economy (S&P 500) | $37.37 | 0.71% | beats naive by 0.5% |
| Finance (Bitcoin) | $1,437.46 | 1.61% | ~naive |
| Programming (react) | 1.17M downloads | 7.12% | beats naive by 77.5% |
| Sports (ATP #1 Elo) | 3.40 Elo | 0.06% | ~naive |
| Weather (Chennai temp) | 0.99 K | 0.18% | beats naive by 1.9% |

**Unified single model (merged from 6 separate models):**

| Topic | MAE | H1 MAPE |
|---|---|---|
| AI | $3.40 | 2.36% |
| Economy | $72.21 | 0.75% |
| Finance | $2,863.45 | 1.74% |
| Programming | 1.14M downloads | 5.42% |
| Sports | 2.75 Elo | 0.04% |
| Weather | 0.94 K | 0.18% |

> Markets behave near a random walk, so 100% accuracy is impossible — these are honest, validated numbers. No model can guarantee the future.

## Architecture (normal mode shows only the final response)

User question -> intent detection -> prediction engine -> response formatter -> chat output

- Chat CLI — only the final assistant response reaches the user
- Intent detection + orchestration (topic, location, horizon, style)
- Prediction engine — runs the LSTM, returns structured metrics: net change, forecast range, current-to-forecast, direction, primary forecast
- Response formatter — presents metrics naturally; opens with a one-sentence ChatGPT-style summary; never invents confidence, probability, or values
- Multi-topic data pipeline (fetchers + caching)
- 2-layer LSTM, Huber loss, AdamW, early stopping, temporal split
- Per-topic model loader, rollout forecast, chart + text report

## Ask it anything (ChatGPT-style)

Interactive chat with natural language queries:
- "what will bitcoin do next week?"
- "compare all topics"
- "predict programming for 14 days"
- "predict ai for 3 days"

Example response:
```
In short, the model expects Bitcoin to stay roughly stable next week, hovering near $63,228.

Bitcoin Forecast
August 18-24, 2026

The model forecasts relatively sideways movement for Bitcoin next week, with an
estimated level around **$63,228**.

Outlook: Sideways
Predicted level (2026-08-24): ~$63,228
Expected change: <0.01%
Forecast range: <0.01%
From latest observed value ($63,229, 2026-08-17): <0.01%

This is a model-generated forecast, and actual market behavior may differ.
```

## Weather for any city

Configure city via environment variables or city registry, then query weather predictions.

## Train / refresh

Run training for all topics or individual domains. Outputs: model checkpoints, configs, predictions, charts, and results.

## Add a new domain

1. Add entry to topics configuration (label, unit, asset name)
2. Add a fetcher returning date + value columns
3. Run training — everything else is automatic

## Hugging Face Repository

All models and configs are available at:
**https://huggingface.co/CodeDevX/future-prediction-multi-domain-lstm**