Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
---
|
5 |
+
Chaos Classifier: Logistic Map Regime Detection via 1D CNN
|
6 |
+
This model classifies time series sequences generated by the logistic map into one of three dynamical regimes:
|
7 |
+
|
8 |
+
0 β Stable (converges to a fixed point)
|
9 |
+
1 β Periodic (oscillates between repeating values)
|
10 |
+
2 β Chaotic (irregular, non-repeating behavior)
|
11 |
+
The goal is to simulate financial market regimes using a controlled chaotic system and train a model to learn phase transitions directly from raw sequences.
|
12 |
+
|
13 |
+
Motivation
|
14 |
+
Financial systems often exhibit regime shifts: stable growth, cyclical trends, and chaotic crashes.
|
15 |
+
This model uses the logistic map as a proxy to simulate such transitions and demonstrates how a neural network can classify them.
|
16 |
+
|
17 |
+
Data Generation
|
18 |
+
Sequences are generated from the logistic map equation:
|
19 |
+
|
20 |
+
[ x_{n+1} = r \cdot x_n \cdot (1 - x_n) ]
|
21 |
+
|
22 |
+
Where:
|
23 |
+
|
24 |
+
xβ β (0.1, 0.9) is the initial condition
|
25 |
+
r β [2.5, 4.0] controls behavior
|
26 |
+
Label assignment:
|
27 |
+
|
28 |
+
r < 3.0 β Stable (label = 0)
|
29 |
+
3.0 β€ r < 3.57 β Periodic (label = 1)
|
30 |
+
r β₯ 3.57 β Chaotic (label = 2)
|
31 |
+
Model Architecture
|
32 |
+
A 1D Convolutional Neural Network (CNN) was used:
|
33 |
+
|
34 |
+
Conv1D β BatchNorm β ReLU Γ 2
|
35 |
+
GlobalAvgPool1D
|
36 |
+
Linear β Softmax (via CrossEntropyLoss)
|
37 |
+
Advantages of 1D CNN:
|
38 |
+
|
39 |
+
Captures local temporal patterns
|
40 |
+
Learns wave shapes and jitters
|
41 |
+
Parameter-efficient vs. MLP
|
42 |
+
Performance
|
43 |
+
Trained on 500 synthetic sequences (length = 100), test accuracy reached:
|
44 |
+
|
45 |
+
98β99% accuracy
|
46 |
+
Smooth convergence
|
47 |
+
Robust generalization
|
48 |
+
Confusion matrix showed near-perfect stability detection and strong chaos/periodic separation
|
49 |
+
Inference Example
|
50 |
+
You can generate a prediction by passing an r value:
|
51 |
+
|
52 |
+
predict_regime(3.95, model, scaler, device)
|
53 |
+
# Output: Predicted Regime: Chaotic (Class 2)
|