jengyang commited on
Commit
f4f6611
·
verified ·
1 Parent(s): e2dd0c1

Upload LSTM stock prediction model with sentiment analysis

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ 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
+ stage2_universal_lstm_20250705_170829.keras filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: tensorflow
3
+ tags:
4
+ - lstm
5
+ - stock-prediction
6
+ - time-series
7
+ - financial-analysis
8
+ - tensorflow
9
+ - keras
10
+ pipeline_tag: tabular-regression
11
+ ---
12
+
13
+ # Universal LSTM Stock Prediction Model
14
+
15
+ ## Model Description
16
+
17
+ This is a Universal LSTM model trained for stock price prediction with sentiment analysis integration. The model can predict stock prices for multiple stocks using technical indicators and sentiment features.
18
+
19
+ ## Model Details
20
+
21
+ - **Model Type**: LSTM (Long Short-Term Memory) Neural Network
22
+ - **Framework**: TensorFlow/Keras
23
+ - **Task**: Time Series Prediction / Stock Price Forecasting
24
+ - **Training Date**: July 5, 2025
25
+ - **Input Features**: Technical indicators + Sentiment scores
26
+ - **Output**: Next-day stock price prediction
27
+
28
+ ## Architecture
29
+
30
+ - **Input Shape**: (None, 60, 6)
31
+ - **Output Shape**: (None, 1)
32
+ - **Parameters**: 31,651
33
+
34
+ The model uses a multi-layer LSTM architecture optimized for financial time series prediction.
35
+
36
+ ## Training Data
37
+
38
+ - **Stocks**: Multiple stocks including AAPL, MSFT, GOOGL, AMZN, TSLA, META, NVDA
39
+ - **Features**:
40
+ - Technical indicators (Open, High, Low, Close, Volume)
41
+ - Sentiment scores from financial news analysis
42
+ - Moving averages and other derived features
43
+ - **Time Period**: Historical stock data with corresponding news sentiment
44
+ - **Preprocessing**: StandardScaler normalization
45
+
46
+ ## Performance
47
+
48
+ The model has been evaluated on multiple stocks with varying performance metrics. Best performance achieved:
49
+ - **RMSE**: Varies by stock (typically 5-15 points)
50
+ - **Architecture**: Optimized through hyperparameter tuning
51
+
52
+ ## Usage
53
+
54
+ ```python
55
+ import tensorflow as tf
56
+ import pickle
57
+ import numpy as np
58
+
59
+ # Load the model
60
+ model = tf.keras.models.load_model('stage2_universal_lstm_20250705_170829.keras')
61
+
62
+ # Load the scaler
63
+ with open('stage2_scalers_20250705_170829.pkl', 'rb') as f:
64
+ scalers = pickle.load(f)
65
+
66
+ # Prepare your data (X should be scaled using the same scaler)
67
+ # X = your_data # Shape: (batch_size, sequence_length, features)
68
+ # predictions = model.predict(X)
69
+ ```
70
+
71
+ ## Files Included
72
+
73
+ - `stage2_universal_lstm_20250705_170829.keras`: Main model file
74
+ - `stage2_scalers_20250705_170829.pkl`: Feature scalers for preprocessing
75
+ - `stage2_metadata_20250705_170829.json`: Model metadata and configuration
76
+ - `stage2_architecture_20250705_170829.txt`: Detailed architecture description
77
+
78
+ ## Citation
79
+
80
+ If you use this model in your research, please cite:
81
+
82
+ ```
83
+ @misc{lstm_stock_prediction_2025,
84
+ title={Universal LSTM Stock Prediction Model with Sentiment Analysis},
85
+ author={Jeng Yang},
86
+ year={2025},
87
+ url={https://huggingface.co/jengyang/lstm-stock-prediction-model}
88
+ }
89
+ ```
90
+
91
+ ## Disclaimer
92
+
93
+ This model is for research and educational purposes only. Stock market predictions are inherently uncertain and this model should not be used as the sole basis for financial decisions. Always consult with financial professionals and conduct your own research before making investment decisions.
94
+
95
+ ## Contact
96
+
97
+ For questions or issues, please open an issue in the model repository.
stage2_architecture_20250705_170829.txt ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Stage 2 Simple Universal LSTM Model Architecture
3
+ =============================================
4
+
5
+ Model Type: Sequential LSTM
6
+ Training Date: 20250705_170829
7
+ Training Stocks: 20 stocks
8
+ Features: 6 features
9
+ Target: Close
10
+
11
+ Architecture:
12
+ 1. LSTM Layer 1: 50 units, return_sequences=True
13
+ 2. Dropout: 0.2
14
+ 3. LSTM Layer 2: 50 units, return_sequences=False
15
+ 4. Dropout: 0.2
16
+ 5. Dense Output: 1 unit
17
+
18
+ Training Parameters:
19
+ - Batch Size: 16
20
+ - Learning Rate: 0.001
21
+ - Epochs Trained: 88
22
+ - Early Stopping Patience: 12
23
+
24
+ Performance Metrics:
25
+ - RMSE: $26.85
26
+ - MAE: $12.60
27
+ - R�: 0.9903
28
+ - MAPE: 2.68%
29
+
30
+ Features Used:
31
+ - Open
32
+ - High
33
+ - Low
34
+ - Close
35
+ - Volume
36
+ - sentiment_10d_avg
37
+
38
+ Stocks Trained On:
39
+ - AAPL
40
+ - AMZN
41
+ - AVGO
42
+ - BRK.B
43
+ - COST
44
+ - GOOG
45
+ - JNJ
46
+ - JPM
47
+ - LLY
48
+ - MA
49
+ - META
50
+ - MSFT
51
+ - NFLX
52
+ - NVDA
53
+ - ORCL
54
+ - PG
55
+ - TSLA
56
+ - V
57
+ - WMT
58
+ - XOM
59
+
60
+ Usage Instructions:
61
+ 1. Load model: model = tf.keras.models.load_model('../models\stage2_universal_lstm_20250705_170829.keras')
62
+ 2. Load scalers: scalers = joblib.load('../models\stage2_scalers_20250705_170829.pkl')
63
+ 3. Preprocess data using feature_scaler and target_scaler
64
+ 4. Make predictions on sequences of shape (batch_size, 60, 6)
65
+ 5. Inverse transform predictions using target_scaler
stage2_metadata_20250705_170829.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_name": "Stage 2 Simple Universal LSTM",
3
+ "stocks": [
4
+ "AAPL",
5
+ "AMZN",
6
+ "AVGO",
7
+ "BRK.B",
8
+ "COST",
9
+ "GOOG",
10
+ "JNJ",
11
+ "JPM",
12
+ "LLY",
13
+ "MA",
14
+ "META",
15
+ "MSFT",
16
+ "NFLX",
17
+ "NVDA",
18
+ "ORCL",
19
+ "PG",
20
+ "TSLA",
21
+ "V",
22
+ "WMT",
23
+ "XOM"
24
+ ],
25
+ "features": [
26
+ "Open",
27
+ "High",
28
+ "Low",
29
+ "Close",
30
+ "Volume",
31
+ "sentiment_10d_avg"
32
+ ],
33
+ "target": "Close",
34
+ "time_steps": 60,
35
+ "batch_size": 16,
36
+ "epochs_trained": 88,
37
+ "final_val_loss": 0.0008096768870018423,
38
+ "rmse": 26.850322364411017,
39
+ "mae": 12.60320354323313,
40
+ "r2": 0.9902821175992801,
41
+ "mape": 2.679250893651326,
42
+ "created_at": "20250705_170829",
43
+ "architecture": {
44
+ "lstm1_units": 50,
45
+ "lstm2_units": 50,
46
+ "dropout_rate": 0.2,
47
+ "dense_units": 1
48
+ }
49
+ }
stage2_scalers_20250705_170829.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:854aed206979a676a362470fb1137e86e16cfa51a46b10f7f918f1cba35cfa3b
3
+ size 1289
stage2_universal_lstm_20250705_170829.keras ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7e5844c9c50e36dc3df1495111e66b06babaa061400125bb6371939b34735192
3
+ size 416407