Skip to content

Commit 9caa8d9

Browse files
committed
updated stock price prediction tutorial
1 parent f54aac5 commit 9caa8d9

File tree

28 files changed

+7536
-3492
lines changed

28 files changed

+7536
-3492
lines changed

machine-learning/stock-prediction/csv-results/2020-12-11_AMZN-sh-1-sc-1-sbd-0-huber_loss-adam-LSTM-seq-50-step-15-layers-2-units-256.csv

+1,176
Large diffs are not rendered by default.

machine-learning/stock-prediction/data/AMZN_2020-12-11.csv

+5,936
Large diffs are not rendered by default.

machine-learning/stock-prediction/data/TSLA_2020-09-03.csv

-2,566
This file was deleted.

machine-learning/stock-prediction/parameters.py

+18-9
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@
22
import time
33
from tensorflow.keras.layers import LSTM
44

5-
65
# Window size or the sequence length
7-
N_STEPS = 70
6+
N_STEPS = 50
87
# Lookup step, 1 is the next day
9-
LOOKUP_STEP = 1
10-
8+
LOOKUP_STEP = 15
9+
10+
# whether to scale feature columns & output price as well
11+
SCALE = True
12+
scale_str = f"sc-{int(SCALE)}"
13+
# whether to shuffle the dataset
14+
SHUFFLE = True
15+
shuffle_str = f"sh-{int(SHUFFLE)}"
16+
# whether to split the training/testing set by date
17+
SPLIT_BY_DATE = False
18+
split_by_date_str = f"sbd-{int(SPLIT_BY_DATE)}"
1119
# test ratio size, 0.2 is 20%
1220
TEST_SIZE = 0.2
1321
# features to use
@@ -17,7 +25,7 @@
1725

1826
### model parameters
1927

20-
N_LAYERS = 3
28+
N_LAYERS = 2
2129
# LSTM cell
2230
CELL = LSTM
2331
# 256 LSTM neurons
@@ -35,12 +43,13 @@
3543
LOSS = "huber_loss"
3644
OPTIMIZER = "adam"
3745
BATCH_SIZE = 64
38-
EPOCHS = 400
46+
EPOCHS = 500
3947

40-
# Tesla stock market
41-
ticker = "TSLA"
48+
# Amazon stock market
49+
ticker = "AMZN"
4250
ticker_data_filename = os.path.join("data", f"{ticker}_{date_now}.csv")
4351
# model name to save, making it as unique as possible based on parameters
44-
model_name = f"{date_now}_{ticker}-{LOSS}-{OPTIMIZER}-{CELL.__name__}-seq-{N_STEPS}-step-{LOOKUP_STEP}-layers-{N_LAYERS}-units-{UNITS}"
52+
model_name = f"{date_now}_{ticker}-{shuffle_str}-{scale_str}-{split_by_date_str}-\
53+
{LOSS}-{OPTIMIZER}-{CELL.__name__}-seq-{N_STEPS}-step-{LOOKUP_STEP}-layers-{N_LAYERS}-units-{UNITS}"
4554
if BIDIRECTIONAL:
4655
model_name += "-b"

0 commit comments

Comments
 (0)