MENU: Top | Importing & Narrowing | Intial Investigation | Preprocessing | Defining the Model | Training the Model | Results
from helpers import *
import numpy as np
import pandas as pd
from importlib import reload
import IPython.display
from sklearn.preprocessing import MinMaxScaler
import matplotlib.pyplot as plt
plt.style.use('ggplot')
from keras.models import Sequential, load_model
from keras.layers import LSTM, Dense, Dropout
from sklearn.model_selection import train_test_split
%matplotlib inline
2023-01-20 14:17:55.962450: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: SSE4.1 SSE4.2 To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Getting newest data from Yahoo Finance
import yfinance as yf
bitcoin = pd.DataFrame(yf.download("BTC-USD", period="10y"))
# bitcoin = pd.read_csv("BTC-USD.csv")
[*********************100%***********************] 1 of 1 completed
head_tail_horz(bitcoin, 5, "Bitcoin Data")
Open | High | Low | Close | Adj Close | Volume | |
---|---|---|---|---|---|---|
Date | ||||||
2014-09-17 | 465.86 | 468.17 | 452.42 | 457.33 | 457.33 | 21,056,800 |
2014-09-18 | 456.86 | 456.86 | 413.10 | 424.44 | 424.44 | 34,483,200 |
2014-09-19 | 424.10 | 427.83 | 384.53 | 394.80 | 394.80 | 37,919,700 |
2014-09-20 | 394.67 | 423.30 | 389.88 | 408.90 | 408.90 | 36,863,600 |
2014-09-21 | 408.08 | 412.43 | 393.18 | 398.82 | 398.82 | 26,580,100 |
Open | High | Low | Close | Adj Close | Volume | |
---|---|---|---|---|---|---|
Date | ||||||
2023-01-16 | 20,882.22 | 21,360.88 | 20,715.75 | 21,169.63 | 21,169.63 | 26,792,494,050 |
2023-01-17 | 21,175.83 | 21,438.66 | 20,978.53 | 21,161.52 | 21,161.52 | 24,999,983,362 |
2023-01-18 | 21,161.05 | 21,564.50 | 20,541.54 | 20,688.78 | 20,688.78 | 30,005,625,418 |
2023-01-19 | 20,686.75 | 21,163.01 | 20,685.38 | 21,086.79 | 21,086.79 | 21,152,848,261 |
2023-01-20 | 21,073.94 | 21,388.67 | 20,919.13 | 21,388.67 | 21,388.67 | 22,447,878,144 |
Using the most recent 5,000 records as data
bc_data = bitcoin[['Close']].tail(5000)
bc_data = bc_data.set_index(pd.to_datetime(bc_data.index))
fancy_plot(pd.DataFrame(bc_data), title="Bitcoin Data Initial View",
xlabel="Dates", ylabel="Price", cmap="spring")
see(bc_data.describe(), "bc_data.describe()")
Close | |
---|---|
count | 3,048.00 |
mean | 12,900.29 |
std | 16,139.70 |
min | 178.10 |
25% | 685.08 |
50% | 7,182.92 |
75% | 16,940.59 |
max | 67,566.83 |
Instantiating Scaler
scaler = MinMaxScaler()
bc_scaled = pd.DataFrame(scaler.fit_transform(bc_data),
columns=["Close"], index = bc_data.index)
head_tail_horz(bc_scaled, 5, "Scaled Data")
Close | |
---|---|
Date | |
2014-09-17 | 0.00 |
2014-09-18 | 0.00 |
2014-09-19 | 0.00 |
2014-09-20 | 0.00 |
2014-09-21 | 0.00 |
Close | |
---|---|
Date | |
2023-01-16 | 0.31 |
2023-01-17 | 0.31 |
2023-01-18 | 0.30 |
2023-01-19 | 0.31 |
2023-01-20 | 0.31 |
Splitting Data
steps_in
- number of days fed in, from which to determine the future stock pricessteps_out
- the number of days into the future for which we want to get predictionsend
- from whatever point the function currently is in the data up through the number of steps that are being used as input to get the following specified number of days / timestamps to have predicteddef split_data(data, steps_in, steps_out):
inputs, targets = [], []
for i in range(len(data)):
output_start = i + steps_in
output_end = output_start + steps_out
if output_end > len(data):
break
data_in, data_out = data[i: output_start], data[output_start : output_end]
inputs.append(data_in)
targets.append(data_out)
return np.array(inputs), np.array(targets)
Results Visualization
results.history
will be an attribute that comes from the modeldef visualize_results(results):
history = results.history
plt.figure(figsize=(13,7), facecolor="#cyan")
plt.plot(history['val_loss'])
plt.plot(history['loss'])
plt.legend(['val_loss', 'loss'])
plt.title("Model Loss")
plt.xlabel("Number of Epochs")
plt.ylabel("Loss Level")
plt.show()
plt.figure(figsize=(13,7), facecolor="#cyan")
plt.plot(history['val_accuracy'])
plt.plot(history['accuracy'])
plt.legend(['val_accuracy', 'accuracy'])
plt.title("Model Accuracy")
plt.xlabel("Number of Epochs")
plt.ylabel("Accuracy")
plt.show()
Defining Parameters & Reshaping for LSTM
steps_in = 30
steps_out = 10
num_features = 1
inputs, targets = split_data(list(bc_scaled.Close), steps_in, steps_out)
Make sure inputs have correct dimensions for LSTM
print("inputs.shape = ", inputs.shape)
inputs.shape = (3009, 30)
Defining Model
model = Sequential()
model.add(LSTM(30, activation='softsign', return_sequences=True, input_shape=(steps_in,num_features)))
model.add(LSTM(10, activation='softsign', return_sequences=True))
model.add(LSTM(20, activation='softsign', return_sequences=True))
model.add(LSTM(20, activation='softsign', return_sequences=True))
model.add(LSTM(30, activation='softsign', return_sequences=True))
model.add(LSTM(10, activation='softsign'))
model.add(Dense(steps_out))
model.summary()
Model: "sequential_1" _________________________________________________________________ Layer (type) Output Shape Param # ================================================================= lstm_6 (LSTM) (None, 30, 30) 3840 lstm_7 (LSTM) (None, 30, 10) 1640 lstm_8 (LSTM) (None, 30, 20) 2480 lstm_9 (LSTM) (None, 30, 20) 3280 lstm_10 (LSTM) (None, 30, 30) 6120 lstm_11 (LSTM) (None, 10) 1640 dense_1 (Dense) (None, 10) 110 ================================================================= Total params: 19,110 Trainable params: 19,110 Non-trainable params: 0 _________________________________________________________________
Compile Model
model.compile(optimizer='adam', loss='mse', metrics=['accuracy'])
Training the Model
# results = model.fit(inputs, targets,
# epochs=300, batch_size=32, validation_split=0.1)
Epoch 1/300 85/85 [==============================] - 6s 38ms/step - loss: 0.0418 - accuracy: 0.1215 - val_loss: 0.0195 - val_accuracy: 0.0731 Epoch 2/300 85/85 [==============================] - 3s 31ms/step - loss: 0.0038 - accuracy: 0.0783 - val_loss: 0.0225 - val_accuracy: 0.0764 Epoch 3/300 85/85 [==============================] - 3s 31ms/step - loss: 0.0033 - accuracy: 0.0812 - val_loss: 0.0129 - val_accuracy: 0.0797 Epoch 4/300 85/85 [==============================] - 3s 31ms/step - loss: 0.0028 - accuracy: 0.0905 - val_loss: 0.0173 - val_accuracy: 0.0963 Epoch 5/300 85/85 [==============================] - 3s 31ms/step - loss: 0.0029 - accuracy: 0.1019 - val_loss: 0.0095 - val_accuracy: 0.0764 Epoch 6/300 85/85 [==============================] - 3s 31ms/step - loss: 0.0025 - accuracy: 0.1093 - val_loss: 0.0086 - val_accuracy: 0.0764 Epoch 7/300 85/85 [==============================] - 3s 31ms/step - loss: 0.0026 - accuracy: 0.1123 - val_loss: 0.0107 - val_accuracy: 0.0997 Epoch 8/300 85/85 [==============================] - 3s 31ms/step - loss: 0.0022 - accuracy: 0.1208 - val_loss: 0.0042 - val_accuracy: 0.0764 Epoch 9/300 85/85 [==============================] - 3s 31ms/step - loss: 0.0022 - accuracy: 0.1097 - val_loss: 0.0137 - val_accuracy: 0.0897 Epoch 10/300 85/85 [==============================] - 3s 31ms/step - loss: 0.0019 - accuracy: 0.1045 - val_loss: 0.0094 - val_accuracy: 0.0930 Epoch 11/300 85/85 [==============================] - 3s 31ms/step - loss: 0.0019 - accuracy: 0.1230 - val_loss: 0.0029 - val_accuracy: 0.0698 Epoch 12/300 85/85 [==============================] - 3s 30ms/step - loss: 0.0018 - accuracy: 0.1152 - val_loss: 0.0092 - val_accuracy: 0.0897 Epoch 13/300 85/85 [==============================] - 3s 31ms/step - loss: 0.0019 - accuracy: 0.1045 - val_loss: 0.0058 - val_accuracy: 0.0532 Epoch 14/300 85/85 [==============================] - 3s 30ms/step - loss: 0.0018 - accuracy: 0.1108 - val_loss: 0.0079 - val_accuracy: 0.0831 Epoch 15/300 85/85 [==============================] - 3s 30ms/step - loss: 0.0016 - accuracy: 0.1082 - val_loss: 0.0031 - val_accuracy: 0.0698 Epoch 16/300 85/85 [==============================] - 3s 30ms/step - loss: 0.0016 - accuracy: 0.1219 - val_loss: 0.0075 - val_accuracy: 0.0598 Epoch 17/300 85/85 [==============================] - 3s 30ms/step - loss: 0.0017 - accuracy: 0.1152 - val_loss: 0.0055 - val_accuracy: 0.0532 Epoch 18/300 85/85 [==============================] - 3s 31ms/step - loss: 0.0015 - accuracy: 0.1326 - val_loss: 0.0050 - val_accuracy: 0.0598 Epoch 19/300 85/85 [==============================] - 3s 30ms/step - loss: 0.0016 - accuracy: 0.1182 - val_loss: 0.0128 - val_accuracy: 0.0731 Epoch 20/300 85/85 [==============================] - 3s 30ms/step - loss: 0.0015 - accuracy: 0.1174 - val_loss: 0.0028 - val_accuracy: 0.0631 Epoch 21/300 85/85 [==============================] - 3s 31ms/step - loss: 0.0014 - accuracy: 0.1189 - val_loss: 0.0092 - val_accuracy: 0.0731 Epoch 22/300 85/85 [==============================] - 3s 30ms/step - loss: 0.0015 - accuracy: 0.1425 - val_loss: 0.0035 - val_accuracy: 0.0698 Epoch 23/300 85/85 [==============================] - 3s 30ms/step - loss: 0.0013 - accuracy: 0.1134 - val_loss: 0.0045 - val_accuracy: 0.0731 Epoch 24/300 85/85 [==============================] - 3s 30ms/step - loss: 0.0013 - accuracy: 0.1244 - val_loss: 0.0059 - val_accuracy: 0.0631 Epoch 25/300 85/85 [==============================] - 3s 30ms/step - loss: 0.0012 - accuracy: 0.1274 - val_loss: 0.0041 - val_accuracy: 0.0664 Epoch 26/300 85/85 [==============================] - 3s 30ms/step - loss: 0.0012 - accuracy: 0.1208 - val_loss: 0.0031 - val_accuracy: 0.0764 Epoch 27/300 85/85 [==============================] - 3s 30ms/step - loss: 0.0012 - accuracy: 0.1274 - val_loss: 0.0061 - val_accuracy: 0.0963 Epoch 28/300 85/85 [==============================] - 3s 30ms/step - loss: 0.0013 - accuracy: 0.1329 - val_loss: 0.0046 - val_accuracy: 0.0598 Epoch 29/300 85/85 [==============================] - 3s 30ms/step - loss: 0.0012 - accuracy: 0.1230 - val_loss: 0.0029 - val_accuracy: 0.0698 Epoch 30/300 85/85 [==============================] - 3s 31ms/step - loss: 0.0012 - accuracy: 0.1270 - val_loss: 0.0073 - val_accuracy: 0.1030 Epoch 31/300 85/85 [==============================] - 3s 30ms/step - loss: 0.0012 - accuracy: 0.1182 - val_loss: 0.0087 - val_accuracy: 0.0731 Epoch 32/300 85/85 [==============================] - 3s 30ms/step - loss: 0.0011 - accuracy: 0.1215 - val_loss: 0.0059 - val_accuracy: 0.0764 Epoch 33/300 85/85 [==============================] - 3s 30ms/step - loss: 0.0011 - accuracy: 0.1182 - val_loss: 0.0043 - val_accuracy: 0.0797 Epoch 34/300 85/85 [==============================] - 3s 30ms/step - loss: 0.0010 - accuracy: 0.1311 - val_loss: 0.0040 - val_accuracy: 0.0764 Epoch 35/300 85/85 [==============================] - 3s 30ms/step - loss: 9.6310e-04 - accuracy: 0.1226 - val_loss: 0.0051 - val_accuracy: 0.0764 Epoch 36/300 85/85 [==============================] - 3s 31ms/step - loss: 0.0011 - accuracy: 0.1178 - val_loss: 0.0065 - val_accuracy: 0.0864 Epoch 37/300 85/85 [==============================] - 3s 32ms/step - loss: 9.7725e-04 - accuracy: 0.1326 - val_loss: 0.0067 - val_accuracy: 0.0797 Epoch 38/300 85/85 [==============================] - 3s 31ms/step - loss: 9.5105e-04 - accuracy: 0.1204 - val_loss: 0.0031 - val_accuracy: 0.0864 Epoch 39/300 85/85 [==============================] - 3s 31ms/step - loss: 0.0010 - accuracy: 0.1208 - val_loss: 0.0058 - val_accuracy: 0.0797 Epoch 40/300 85/85 [==============================] - 3s 31ms/step - loss: 9.7657e-04 - accuracy: 0.1230 - val_loss: 0.0079 - val_accuracy: 0.0864 Epoch 41/300 85/85 [==============================] - 3s 31ms/step - loss: 9.3205e-04 - accuracy: 0.1123 - val_loss: 0.0057 - val_accuracy: 0.0897 Epoch 42/300 85/85 [==============================] - 3s 31ms/step - loss: 0.0010 - accuracy: 0.1219 - val_loss: 0.0053 - val_accuracy: 0.0831 Epoch 43/300 85/85 [==============================] - 3s 31ms/step - loss: 8.7966e-04 - accuracy: 0.1322 - val_loss: 0.0063 - val_accuracy: 0.0764 Epoch 44/300 85/85 [==============================] - 3s 31ms/step - loss: 8.6629e-04 - accuracy: 0.1141 - val_loss: 0.0047 - val_accuracy: 0.0897 Epoch 45/300 85/85 [==============================] - 3s 31ms/step - loss: 8.2316e-04 - accuracy: 0.1311 - val_loss: 0.0053 - val_accuracy: 0.0731 Epoch 46/300 85/85 [==============================] - 3s 31ms/step - loss: 8.8688e-04 - accuracy: 0.1267 - val_loss: 0.0067 - val_accuracy: 0.0797 Epoch 47/300 85/85 [==============================] - 3s 31ms/step - loss: 8.2620e-04 - accuracy: 0.1171 - val_loss: 0.0088 - val_accuracy: 0.0997 Epoch 48/300 85/85 [==============================] - 3s 31ms/step - loss: 8.1818e-04 - accuracy: 0.1152 - val_loss: 0.0049 - val_accuracy: 0.0797 Epoch 49/300 85/85 [==============================] - 3s 31ms/step - loss: 8.7089e-04 - accuracy: 0.1219 - val_loss: 0.0085 - val_accuracy: 0.0664 Epoch 50/300 85/85 [==============================] - 3s 31ms/step - loss: 8.0206e-04 - accuracy: 0.1226 - val_loss: 0.0073 - val_accuracy: 0.0797 Epoch 51/300 85/85 [==============================] - 3s 30ms/step - loss: 8.4406e-04 - accuracy: 0.1233 - val_loss: 0.0061 - val_accuracy: 0.0897 Epoch 52/300 85/85 [==============================] - 3s 30ms/step - loss: 7.7688e-04 - accuracy: 0.1112 - val_loss: 0.0087 - val_accuracy: 0.0897 Epoch 53/300 85/85 [==============================] - 3s 30ms/step - loss: 8.1359e-04 - accuracy: 0.1078 - val_loss: 0.0069 - val_accuracy: 0.0797 Epoch 54/300 85/85 [==============================] - 3s 30ms/step - loss: 7.8715e-04 - accuracy: 0.1230 - val_loss: 0.0060 - val_accuracy: 0.0764 Epoch 55/300 85/85 [==============================] - 3s 30ms/step - loss: 7.7232e-04 - accuracy: 0.1222 - val_loss: 0.0078 - val_accuracy: 0.0797 Epoch 56/300 85/85 [==============================] - 3s 30ms/step - loss: 7.8082e-04 - accuracy: 0.1178 - val_loss: 0.0081 - val_accuracy: 0.0963 Epoch 57/300 85/85 [==============================] - 3s 30ms/step - loss: 8.8682e-04 - accuracy: 0.1196 - val_loss: 0.0086 - val_accuracy: 0.0731 Epoch 58/300 85/85 [==============================] - 3s 31ms/step - loss: 8.2810e-04 - accuracy: 0.1292 - val_loss: 0.0056 - val_accuracy: 0.0797 Epoch 59/300 85/85 [==============================] - 4s 47ms/step - loss: 7.4195e-04 - accuracy: 0.1281 - val_loss: 0.0076 - val_accuracy: 0.0864 Epoch 60/300 85/85 [==============================] - 3s 31ms/step - loss: 7.1575e-04 - accuracy: 0.1160 - val_loss: 0.0058 - val_accuracy: 0.0764 Epoch 61/300 85/85 [==============================] - 3s 31ms/step - loss: 7.4441e-04 - accuracy: 0.1267 - val_loss: 0.0062 - val_accuracy: 0.0764 Epoch 62/300 85/85 [==============================] - 3s 30ms/step - loss: 7.9483e-04 - accuracy: 0.1204 - val_loss: 0.0055 - val_accuracy: 0.0797 Epoch 63/300 85/85 [==============================] - 3s 30ms/step - loss: 7.0560e-04 - accuracy: 0.1270 - val_loss: 0.0044 - val_accuracy: 0.0664 Epoch 64/300 85/85 [==============================] - 3s 31ms/step - loss: 7.5139e-04 - accuracy: 0.1204 - val_loss: 0.0074 - val_accuracy: 0.0631 Epoch 65/300 85/85 [==============================] - 3s 30ms/step - loss: 7.0803e-04 - accuracy: 0.1385 - val_loss: 0.0070 - val_accuracy: 0.0864 Epoch 66/300 85/85 [==============================] - 3s 30ms/step - loss: 7.0084e-04 - accuracy: 0.1256 - val_loss: 0.0057 - val_accuracy: 0.1063 Epoch 67/300 85/85 [==============================] - 3s 30ms/step - loss: 7.5172e-04 - accuracy: 0.1307 - val_loss: 0.0059 - val_accuracy: 0.0831 Epoch 68/300 85/85 [==============================] - 3s 30ms/step - loss: 7.5686e-04 - accuracy: 0.1174 - val_loss: 0.0066 - val_accuracy: 0.0797 Epoch 69/300 85/85 [==============================] - 3s 30ms/step - loss: 7.3525e-04 - accuracy: 0.1274 - val_loss: 0.0058 - val_accuracy: 0.0731 Epoch 70/300 85/85 [==============================] - 3s 30ms/step - loss: 7.3589e-04 - accuracy: 0.1230 - val_loss: 0.0110 - val_accuracy: 0.0831 Epoch 71/300 85/85 [==============================] - 3s 30ms/step - loss: 7.1121e-04 - accuracy: 0.1377 - val_loss: 0.0050 - val_accuracy: 0.0731 Epoch 72/300 85/85 [==============================] - 3s 30ms/step - loss: 7.2211e-04 - accuracy: 0.1115 - val_loss: 0.0090 - val_accuracy: 0.0897 Epoch 73/300 85/85 [==============================] - 3s 31ms/step - loss: 7.0899e-04 - accuracy: 0.1259 - val_loss: 0.0085 - val_accuracy: 0.0731 Epoch 74/300 85/85 [==============================] - 3s 30ms/step - loss: 7.0108e-04 - accuracy: 0.1233 - val_loss: 0.0058 - val_accuracy: 0.0698 Epoch 75/300 85/85 [==============================] - 3s 30ms/step - loss: 7.0091e-04 - accuracy: 0.1215 - val_loss: 0.0064 - val_accuracy: 0.0864 Epoch 76/300 85/85 [==============================] - 3s 31ms/step - loss: 7.6846e-04 - accuracy: 0.1289 - val_loss: 0.0048 - val_accuracy: 0.0631 Epoch 77/300 85/85 [==============================] - 3s 31ms/step - loss: 6.8950e-04 - accuracy: 0.1097 - val_loss: 0.0096 - val_accuracy: 0.0797 Epoch 78/300 85/85 [==============================] - 3s 30ms/step - loss: 6.9475e-04 - accuracy: 0.1182 - val_loss: 0.0058 - val_accuracy: 0.0897 Epoch 79/300 85/85 [==============================] - 3s 31ms/step - loss: 7.9552e-04 - accuracy: 0.1215 - val_loss: 0.0063 - val_accuracy: 0.0963 Epoch 80/300 85/85 [==============================] - 3s 31ms/step - loss: 7.0129e-04 - accuracy: 0.1407 - val_loss: 0.0096 - val_accuracy: 0.0963 Epoch 81/300 85/85 [==============================] - 3s 31ms/step - loss: 7.0560e-04 - accuracy: 0.1145 - val_loss: 0.0091 - val_accuracy: 0.0731 Epoch 82/300 85/85 [==============================] - 3s 31ms/step - loss: 7.0910e-04 - accuracy: 0.1374 - val_loss: 0.0084 - val_accuracy: 0.0631 Epoch 83/300 85/85 [==============================] - 3s 31ms/step - loss: 6.8388e-04 - accuracy: 0.1355 - val_loss: 0.0073 - val_accuracy: 0.0831 Epoch 84/300 85/85 [==============================] - 3s 30ms/step - loss: 6.7370e-04 - accuracy: 0.1226 - val_loss: 0.0070 - val_accuracy: 0.0831 Epoch 85/300 85/85 [==============================] - 3s 30ms/step - loss: 6.8801e-04 - accuracy: 0.1322 - val_loss: 0.0084 - val_accuracy: 0.0664 Epoch 86/300 85/85 [==============================] - 3s 31ms/step - loss: 7.5738e-04 - accuracy: 0.1178 - val_loss: 0.0065 - val_accuracy: 0.0831 Epoch 87/300 85/85 [==============================] - 3s 30ms/step - loss: 7.2653e-04 - accuracy: 0.1289 - val_loss: 0.0090 - val_accuracy: 0.1030 Epoch 88/300 85/85 [==============================] - 3s 30ms/step - loss: 7.0931e-04 - accuracy: 0.1318 - val_loss: 0.0065 - val_accuracy: 0.0797 Epoch 89/300 85/85 [==============================] - 3s 30ms/step - loss: 6.7266e-04 - accuracy: 0.1174 - val_loss: 0.0059 - val_accuracy: 0.0797 Epoch 90/300 85/85 [==============================] - 3s 30ms/step - loss: 6.7035e-04 - accuracy: 0.1056 - val_loss: 0.0064 - val_accuracy: 0.1196 Epoch 91/300 85/85 [==============================] - 3s 31ms/step - loss: 6.8614e-04 - accuracy: 0.1222 - val_loss: 0.0073 - val_accuracy: 0.0797 Epoch 92/300 85/85 [==============================] - 3s 31ms/step - loss: 6.8775e-04 - accuracy: 0.1326 - val_loss: 0.0111 - val_accuracy: 0.0797 Epoch 93/300 85/85 [==============================] - 3s 31ms/step - loss: 6.4939e-04 - accuracy: 0.1304 - val_loss: 0.0055 - val_accuracy: 0.0664 Epoch 94/300 85/85 [==============================] - 3s 30ms/step - loss: 6.5714e-04 - accuracy: 0.1274 - val_loss: 0.0070 - val_accuracy: 0.1030 Epoch 95/300 85/85 [==============================] - 3s 31ms/step - loss: 6.9424e-04 - accuracy: 0.1304 - val_loss: 0.0048 - val_accuracy: 0.1163 Epoch 96/300 85/85 [==============================] - 3s 30ms/step - loss: 6.7166e-04 - accuracy: 0.1252 - val_loss: 0.0054 - val_accuracy: 0.0963 Epoch 97/300 85/85 [==============================] - 3s 30ms/step - loss: 6.3780e-04 - accuracy: 0.1311 - val_loss: 0.0091 - val_accuracy: 0.1130 Epoch 98/300 85/85 [==============================] - 3s 30ms/step - loss: 7.0911e-04 - accuracy: 0.1256 - val_loss: 0.0046 - val_accuracy: 0.1063 Epoch 99/300 85/85 [==============================] - 3s 30ms/step - loss: 6.6487e-04 - accuracy: 0.1278 - val_loss: 0.0025 - val_accuracy: 0.1262 Epoch 100/300 85/85 [==============================] - 3s 30ms/step - loss: 6.8354e-04 - accuracy: 0.1244 - val_loss: 0.0038 - val_accuracy: 0.1096 Epoch 101/300 85/85 [==============================] - 3s 30ms/step - loss: 7.1050e-04 - accuracy: 0.1326 - val_loss: 0.0049 - val_accuracy: 0.0963 Epoch 102/300 85/85 [==============================] - 3s 30ms/step - loss: 6.7002e-04 - accuracy: 0.1392 - val_loss: 0.0031 - val_accuracy: 0.0963 Epoch 103/300 85/85 [==============================] - 3s 31ms/step - loss: 6.4597e-04 - accuracy: 0.1381 - val_loss: 0.0054 - val_accuracy: 0.1130 Epoch 104/300 85/85 [==============================] - 3s 31ms/step - loss: 6.8828e-04 - accuracy: 0.1274 - val_loss: 0.0037 - val_accuracy: 0.1196 Epoch 105/300 85/85 [==============================] - 3s 30ms/step - loss: 6.5226e-04 - accuracy: 0.1296 - val_loss: 0.0045 - val_accuracy: 0.1130 Epoch 106/300 85/85 [==============================] - 3s 30ms/step - loss: 6.3622e-04 - accuracy: 0.1436 - val_loss: 0.0032 - val_accuracy: 0.0930 Epoch 107/300 85/85 [==============================] - 3s 30ms/step - loss: 6.0724e-04 - accuracy: 0.1595 - val_loss: 0.0046 - val_accuracy: 0.1096 Epoch 108/300 85/85 [==============================] - 3s 31ms/step - loss: 6.6556e-04 - accuracy: 0.1555 - val_loss: 0.0062 - val_accuracy: 0.1196 Epoch 109/300 85/85 [==============================] - 3s 30ms/step - loss: 7.2952e-04 - accuracy: 0.1318 - val_loss: 0.0035 - val_accuracy: 0.1163 Epoch 110/300 85/85 [==============================] - 3s 30ms/step - loss: 6.6560e-04 - accuracy: 0.1366 - val_loss: 0.0078 - val_accuracy: 0.1561 Epoch 111/300 85/85 [==============================] - 3s 30ms/step - loss: 6.2964e-04 - accuracy: 0.1322 - val_loss: 0.0045 - val_accuracy: 0.1329 Epoch 112/300 85/85 [==============================] - 3s 30ms/step - loss: 6.2669e-04 - accuracy: 0.1455 - val_loss: 0.0037 - val_accuracy: 0.1163 Epoch 113/300 85/85 [==============================] - 3s 30ms/step - loss: 5.8901e-04 - accuracy: 0.1425 - val_loss: 0.0062 - val_accuracy: 0.1362 Epoch 114/300 85/85 [==============================] - 3s 30ms/step - loss: 6.6107e-04 - accuracy: 0.1440 - val_loss: 0.0049 - val_accuracy: 0.1495 Epoch 115/300 85/85 [==============================] - 3s 30ms/step - loss: 6.1637e-04 - accuracy: 0.1311 - val_loss: 0.0062 - val_accuracy: 0.1894 Epoch 116/300 85/85 [==============================] - 3s 31ms/step - loss: 6.0117e-04 - accuracy: 0.1555 - val_loss: 0.0041 - val_accuracy: 0.1528 Epoch 117/300 85/85 [==============================] - 3s 30ms/step - loss: 5.8827e-04 - accuracy: 0.1448 - val_loss: 0.0041 - val_accuracy: 0.1561 Epoch 118/300 85/85 [==============================] - 3s 30ms/step - loss: 5.7926e-04 - accuracy: 0.1451 - val_loss: 0.0048 - val_accuracy: 0.0997 Epoch 119/300 85/85 [==============================] - 3s 31ms/step - loss: 5.4910e-04 - accuracy: 0.1488 - val_loss: 0.0053 - val_accuracy: 0.1229 Epoch 120/300 85/85 [==============================] - 3s 30ms/step - loss: 6.2500e-04 - accuracy: 0.1459 - val_loss: 0.0064 - val_accuracy: 0.1528 Epoch 121/300 85/85 [==============================] - 3s 30ms/step - loss: 5.3693e-04 - accuracy: 0.1555 - val_loss: 0.0049 - val_accuracy: 0.1196 Epoch 122/300 85/85 [==============================] - 3s 30ms/step - loss: 6.1282e-04 - accuracy: 0.1507 - val_loss: 0.0031 - val_accuracy: 0.1130 Epoch 123/300 85/85 [==============================] - 3s 30ms/step - loss: 6.8861e-04 - accuracy: 0.1433 - val_loss: 0.0039 - val_accuracy: 0.1163 Epoch 124/300 85/85 [==============================] - 3s 31ms/step - loss: 5.7419e-04 - accuracy: 0.1440 - val_loss: 0.0053 - val_accuracy: 0.1130 Epoch 125/300 85/85 [==============================] - 3s 31ms/step - loss: 5.1554e-04 - accuracy: 0.1555 - val_loss: 0.0079 - val_accuracy: 0.1595 Epoch 126/300 85/85 [==============================] - 3s 30ms/step - loss: 5.4679e-04 - accuracy: 0.1448 - val_loss: 0.0053 - val_accuracy: 0.1296 Epoch 127/300 85/85 [==============================] - 3s 31ms/step - loss: 5.4618e-04 - accuracy: 0.1355 - val_loss: 0.0063 - val_accuracy: 0.1229 Epoch 128/300 85/85 [==============================] - 3s 31ms/step - loss: 5.1107e-04 - accuracy: 0.1544 - val_loss: 0.0050 - val_accuracy: 0.0997 Epoch 129/300 85/85 [==============================] - 3s 30ms/step - loss: 5.4139e-04 - accuracy: 0.1514 - val_loss: 0.0063 - val_accuracy: 0.1196 Epoch 130/300 85/85 [==============================] - 3s 30ms/step - loss: 5.1625e-04 - accuracy: 0.1422 - val_loss: 0.0061 - val_accuracy: 0.1030 Epoch 131/300 85/85 [==============================] - 3s 31ms/step - loss: 5.4909e-04 - accuracy: 0.1588 - val_loss: 0.0034 - val_accuracy: 0.1196 Epoch 132/300 85/85 [==============================] - 3s 30ms/step - loss: 5.4460e-04 - accuracy: 0.1473 - val_loss: 0.0046 - val_accuracy: 0.1196 Epoch 133/300 85/85 [==============================] - 3s 31ms/step - loss: 5.0959e-04 - accuracy: 0.1433 - val_loss: 0.0064 - val_accuracy: 0.1661 Epoch 134/300 85/85 [==============================] - 3s 30ms/step - loss: 4.7570e-04 - accuracy: 0.1503 - val_loss: 0.0056 - val_accuracy: 0.1262 Epoch 135/300 85/85 [==============================] - 3s 30ms/step - loss: 5.1218e-04 - accuracy: 0.1518 - val_loss: 0.0044 - val_accuracy: 0.1030 Epoch 136/300 85/85 [==============================] - 3s 31ms/step - loss: 5.4856e-04 - accuracy: 0.1558 - val_loss: 0.0041 - val_accuracy: 0.1030 Epoch 137/300 85/85 [==============================] - 3s 30ms/step - loss: 5.2817e-04 - accuracy: 0.1496 - val_loss: 0.0055 - val_accuracy: 0.1329 Epoch 138/300 85/85 [==============================] - 3s 30ms/step - loss: 5.8363e-04 - accuracy: 0.1621 - val_loss: 0.0047 - val_accuracy: 0.1262 Epoch 139/300 85/85 [==============================] - 3s 31ms/step - loss: 4.9244e-04 - accuracy: 0.1381 - val_loss: 0.0071 - val_accuracy: 0.0963 Epoch 140/300 85/85 [==============================] - 3s 30ms/step - loss: 4.8839e-04 - accuracy: 0.1592 - val_loss: 0.0058 - val_accuracy: 0.1196 Epoch 141/300 85/85 [==============================] - 3s 31ms/step - loss: 4.6628e-04 - accuracy: 0.1518 - val_loss: 0.0045 - val_accuracy: 0.1130 Epoch 142/300 85/85 [==============================] - 3s 30ms/step - loss: 4.7037e-04 - accuracy: 0.1595 - val_loss: 0.0068 - val_accuracy: 0.1163 Epoch 143/300 85/85 [==============================] - 3s 30ms/step - loss: 5.0768e-04 - accuracy: 0.1499 - val_loss: 0.0059 - val_accuracy: 0.1096 Epoch 144/300 85/85 [==============================] - 3s 31ms/step - loss: 5.1482e-04 - accuracy: 0.1499 - val_loss: 0.0080 - val_accuracy: 0.1130 Epoch 145/300 85/85 [==============================] - 3s 30ms/step - loss: 4.7787e-04 - accuracy: 0.1473 - val_loss: 0.0065 - val_accuracy: 0.1694 Epoch 146/300 85/85 [==============================] - 3s 31ms/step - loss: 4.6040e-04 - accuracy: 0.1400 - val_loss: 0.0049 - val_accuracy: 0.1163 Epoch 147/300 85/85 [==============================] - 3s 31ms/step - loss: 5.0855e-04 - accuracy: 0.1525 - val_loss: 0.0072 - val_accuracy: 0.1229 Epoch 148/300 85/85 [==============================] - 3s 31ms/step - loss: 5.8927e-04 - accuracy: 0.1577 - val_loss: 0.0047 - val_accuracy: 0.1229 Epoch 149/300 85/85 [==============================] - 3s 30ms/step - loss: 4.8796e-04 - accuracy: 0.1425 - val_loss: 0.0088 - val_accuracy: 0.1362 Epoch 150/300 85/85 [==============================] - 3s 30ms/step - loss: 4.5753e-04 - accuracy: 0.1588 - val_loss: 0.0049 - val_accuracy: 0.1063 Epoch 151/300 85/85 [==============================] - 3s 31ms/step - loss: 5.3493e-04 - accuracy: 0.1477 - val_loss: 0.0060 - val_accuracy: 0.1229 Epoch 152/300 85/85 [==============================] - 3s 30ms/step - loss: 4.9014e-04 - accuracy: 0.1322 - val_loss: 0.0059 - val_accuracy: 0.1030 Epoch 153/300 85/85 [==============================] - 3s 31ms/step - loss: 4.4538e-04 - accuracy: 0.1643 - val_loss: 0.0060 - val_accuracy: 0.1728 Epoch 154/300 85/85 [==============================] - 3s 31ms/step - loss: 4.2098e-04 - accuracy: 0.1540 - val_loss: 0.0076 - val_accuracy: 0.1628 Epoch 155/300 85/85 [==============================] - 3s 31ms/step - loss: 4.1275e-04 - accuracy: 0.1614 - val_loss: 0.0061 - val_accuracy: 0.1462 Epoch 156/300 85/85 [==============================] - 3s 31ms/step - loss: 4.7991e-04 - accuracy: 0.1444 - val_loss: 0.0105 - val_accuracy: 0.1495 Epoch 157/300 85/85 [==============================] - 3s 31ms/step - loss: 4.5790e-04 - accuracy: 0.1359 - val_loss: 0.0068 - val_accuracy: 0.1096 Epoch 158/300 85/85 [==============================] - 2s 29ms/step - loss: 4.2864e-04 - accuracy: 0.1451 - val_loss: 0.0050 - val_accuracy: 0.1063 Epoch 159/300 85/85 [==============================] - 35s 418ms/step - loss: 4.6062e-04 - accuracy: 0.1411 - val_loss: 0.0071 - val_accuracy: 0.1561 Epoch 160/300 85/85 [==============================] - 3s 32ms/step - loss: 4.3296e-04 - accuracy: 0.1555 - val_loss: 0.0056 - val_accuracy: 0.1063 Epoch 161/300 85/85 [==============================] - 3s 34ms/step - loss: 4.6370e-04 - accuracy: 0.1569 - val_loss: 0.0052 - val_accuracy: 0.1694 Epoch 162/300 85/85 [==============================] - 3s 33ms/step - loss: 4.2650e-04 - accuracy: 0.1599 - val_loss: 0.0053 - val_accuracy: 0.1096 Epoch 163/300 85/85 [==============================] - 3s 33ms/step - loss: 4.2959e-04 - accuracy: 0.1558 - val_loss: 0.0058 - val_accuracy: 0.0930 Epoch 164/300 85/85 [==============================] - 3s 32ms/step - loss: 4.2439e-04 - accuracy: 0.1584 - val_loss: 0.0087 - val_accuracy: 0.1329 Epoch 165/300 85/85 [==============================] - 3s 32ms/step - loss: 4.9272e-04 - accuracy: 0.1348 - val_loss: 0.0087 - val_accuracy: 0.1362 Epoch 166/300 85/85 [==============================] - 3s 33ms/step - loss: 4.4624e-04 - accuracy: 0.1311 - val_loss: 0.0068 - val_accuracy: 0.1229 Epoch 167/300 85/85 [==============================] - 3s 32ms/step - loss: 4.3777e-04 - accuracy: 0.1429 - val_loss: 0.0098 - val_accuracy: 0.1495 Epoch 168/300 85/85 [==============================] - 3s 32ms/step - loss: 4.2943e-04 - accuracy: 0.1392 - val_loss: 0.0069 - val_accuracy: 0.0930 Epoch 169/300 85/85 [==============================] - 3s 33ms/step - loss: 3.9924e-04 - accuracy: 0.1473 - val_loss: 0.0096 - val_accuracy: 0.1628 Epoch 170/300 85/85 [==============================] - 3s 32ms/step - loss: 4.4346e-04 - accuracy: 0.1551 - val_loss: 0.0072 - val_accuracy: 0.1296 Epoch 171/300 85/85 [==============================] - 3s 32ms/step - loss: 6.4226e-04 - accuracy: 0.1381 - val_loss: 0.0075 - val_accuracy: 0.1561 Epoch 172/300 85/85 [==============================] - 3s 32ms/step - loss: 4.8951e-04 - accuracy: 0.1451 - val_loss: 0.0051 - val_accuracy: 0.1030 Epoch 173/300 85/85 [==============================] - 3s 32ms/step - loss: 4.2746e-04 - accuracy: 0.1392 - val_loss: 0.0081 - val_accuracy: 0.1063 Epoch 174/300 85/85 [==============================] - 3s 32ms/step - loss: 3.6426e-04 - accuracy: 0.1418 - val_loss: 0.0086 - val_accuracy: 0.1528 Epoch 175/300 85/85 [==============================] - 3s 32ms/step - loss: 3.5567e-04 - accuracy: 0.1636 - val_loss: 0.0066 - val_accuracy: 0.1262 Epoch 176/300 85/85 [==============================] - 3s 33ms/step - loss: 3.6010e-04 - accuracy: 0.1514 - val_loss: 0.0069 - val_accuracy: 0.1561 Epoch 177/300 85/85 [==============================] - 3s 32ms/step - loss: 3.5592e-04 - accuracy: 0.1569 - val_loss: 0.0056 - val_accuracy: 0.1296 Epoch 178/300 85/85 [==============================] - 3s 32ms/step - loss: 5.0159e-04 - accuracy: 0.1337 - val_loss: 0.0105 - val_accuracy: 0.1196 Epoch 179/300 85/85 [==============================] - 3s 32ms/step - loss: 4.2262e-04 - accuracy: 0.1466 - val_loss: 0.0084 - val_accuracy: 0.1229 Epoch 180/300 85/85 [==============================] - 3s 32ms/step - loss: 3.4586e-04 - accuracy: 0.1566 - val_loss: 0.0069 - val_accuracy: 0.1561 Epoch 181/300 85/85 [==============================] - 3s 33ms/step - loss: 3.1170e-04 - accuracy: 0.1654 - val_loss: 0.0061 - val_accuracy: 0.1030 Epoch 182/300 85/85 [==============================] - 3s 32ms/step - loss: 3.3171e-04 - accuracy: 0.1562 - val_loss: 0.0072 - val_accuracy: 0.1661 Epoch 183/300 85/85 [==============================] - 3s 32ms/step - loss: 3.4481e-04 - accuracy: 0.1544 - val_loss: 0.0063 - val_accuracy: 0.1262 Epoch 184/300 85/85 [==============================] - 3s 33ms/step - loss: 3.4205e-04 - accuracy: 0.1581 - val_loss: 0.0104 - val_accuracy: 0.1329 Epoch 185/300 85/85 [==============================] - 3s 33ms/step - loss: 3.2161e-04 - accuracy: 0.1518 - val_loss: 0.0073 - val_accuracy: 0.1229 Epoch 186/300 85/85 [==============================] - 3s 32ms/step - loss: 3.0185e-04 - accuracy: 0.1662 - val_loss: 0.0085 - val_accuracy: 0.1694 Epoch 187/300 85/85 [==============================] - 3s 32ms/step - loss: 3.6765e-04 - accuracy: 0.1636 - val_loss: 0.0103 - val_accuracy: 0.1329 Epoch 188/300 85/85 [==============================] - 3s 32ms/step - loss: 3.8963e-04 - accuracy: 0.1562 - val_loss: 0.0069 - val_accuracy: 0.1628 Epoch 189/300 85/85 [==============================] - 3s 32ms/step - loss: 4.1327e-04 - accuracy: 0.1673 - val_loss: 0.0065 - val_accuracy: 0.1329 Epoch 190/300 85/85 [==============================] - 3s 32ms/step - loss: 4.4322e-04 - accuracy: 0.1403 - val_loss: 0.0051 - val_accuracy: 0.1694 Epoch 191/300 85/85 [==============================] - 3s 33ms/step - loss: 3.7202e-04 - accuracy: 0.1643 - val_loss: 0.0095 - val_accuracy: 0.1628 Epoch 192/300 85/85 [==============================] - 3s 32ms/step - loss: 3.2286e-04 - accuracy: 0.1599 - val_loss: 0.0080 - val_accuracy: 0.1296 Epoch 193/300 85/85 [==============================] - 3s 32ms/step - loss: 2.7958e-04 - accuracy: 0.1536 - val_loss: 0.0092 - val_accuracy: 0.1561 Epoch 194/300 85/85 [==============================] - 3s 32ms/step - loss: 2.8039e-04 - accuracy: 0.1496 - val_loss: 0.0081 - val_accuracy: 0.1329 Epoch 195/300 85/85 [==============================] - 3s 32ms/step - loss: 3.2775e-04 - accuracy: 0.1584 - val_loss: 0.0097 - val_accuracy: 0.1495 Epoch 196/300 85/85 [==============================] - 3s 32ms/step - loss: 2.8586e-04 - accuracy: 0.1525 - val_loss: 0.0078 - val_accuracy: 0.1595 Epoch 197/300 85/85 [==============================] - 3s 32ms/step - loss: 2.7544e-04 - accuracy: 0.1562 - val_loss: 0.0093 - val_accuracy: 0.1694 Epoch 198/300 85/85 [==============================] - 3s 32ms/step - loss: 3.2142e-04 - accuracy: 0.1592 - val_loss: 0.0060 - val_accuracy: 0.1063 Epoch 199/300 85/85 [==============================] - 3s 32ms/step - loss: 2.7187e-04 - accuracy: 0.1629 - val_loss: 0.0082 - val_accuracy: 0.1429 Epoch 200/300 85/85 [==============================] - 3s 32ms/step - loss: 2.6597e-04 - accuracy: 0.1640 - val_loss: 0.0070 - val_accuracy: 0.1429 Epoch 201/300 85/85 [==============================] - 3s 32ms/step - loss: 3.2387e-04 - accuracy: 0.1584 - val_loss: 0.0076 - val_accuracy: 0.1661 Epoch 202/300 85/85 [==============================] - 3s 32ms/step - loss: 3.6524e-04 - accuracy: 0.1532 - val_loss: 0.0067 - val_accuracy: 0.1528 Epoch 203/300 85/85 [==============================] - 3s 33ms/step - loss: 5.4724e-04 - accuracy: 0.1581 - val_loss: 0.0089 - val_accuracy: 0.1561 Epoch 204/300 85/85 [==============================] - 3s 32ms/step - loss: 3.8675e-04 - accuracy: 0.1614 - val_loss: 0.0090 - val_accuracy: 0.1395 Epoch 205/300 85/85 [==============================] - 3s 32ms/step - loss: 3.0705e-04 - accuracy: 0.1444 - val_loss: 0.0097 - val_accuracy: 0.1495 Epoch 206/300 85/85 [==============================] - 3s 32ms/step - loss: 2.5721e-04 - accuracy: 0.1728 - val_loss: 0.0077 - val_accuracy: 0.1595 Epoch 207/300 85/85 [==============================] - 3s 32ms/step - loss: 2.5332e-04 - accuracy: 0.1665 - val_loss: 0.0072 - val_accuracy: 0.1130 Epoch 208/300 85/85 [==============================] - 3s 33ms/step - loss: 2.4559e-04 - accuracy: 0.1555 - val_loss: 0.0078 - val_accuracy: 0.1462 Epoch 209/300 85/85 [==============================] - 3s 33ms/step - loss: 2.4151e-04 - accuracy: 0.1640 - val_loss: 0.0075 - val_accuracy: 0.1362 Epoch 210/300 85/85 [==============================] - 3s 31ms/step - loss: 2.4307e-04 - accuracy: 0.1569 - val_loss: 0.0102 - val_accuracy: 0.1561 Epoch 211/300 85/85 [==============================] - 3s 33ms/step - loss: 2.8063e-04 - accuracy: 0.1562 - val_loss: 0.0076 - val_accuracy: 0.1229 Epoch 212/300 85/85 [==============================] - 3s 33ms/step - loss: 2.3956e-04 - accuracy: 0.1654 - val_loss: 0.0080 - val_accuracy: 0.1296 Epoch 213/300 85/85 [==============================] - 3s 32ms/step - loss: 3.4750e-04 - accuracy: 0.1558 - val_loss: 0.0077 - val_accuracy: 0.1694 Epoch 214/300 85/85 [==============================] - 3s 32ms/step - loss: 2.8845e-04 - accuracy: 0.1688 - val_loss: 0.0073 - val_accuracy: 0.1262 Epoch 215/300 85/85 [==============================] - 3s 32ms/step - loss: 2.5575e-04 - accuracy: 0.1651 - val_loss: 0.0086 - val_accuracy: 0.0930 Epoch 216/300 85/85 [==============================] - 3s 32ms/step - loss: 2.3991e-04 - accuracy: 0.1610 - val_loss: 0.0071 - val_accuracy: 0.1262 Epoch 217/300 85/85 [==============================] - 3s 32ms/step - loss: 2.2856e-04 - accuracy: 0.1710 - val_loss: 0.0091 - val_accuracy: 0.1728 Epoch 218/300 85/85 [==============================] - 3s 32ms/step - loss: 2.3022e-04 - accuracy: 0.1832 - val_loss: 0.0080 - val_accuracy: 0.1561 Epoch 219/300 85/85 [==============================] - 3s 32ms/step - loss: 2.1673e-04 - accuracy: 0.1773 - val_loss: 0.0083 - val_accuracy: 0.1495 Epoch 220/300 85/85 [==============================] - 3s 32ms/step - loss: 2.2031e-04 - accuracy: 0.1562 - val_loss: 0.0103 - val_accuracy: 0.1561 Epoch 221/300 85/85 [==============================] - 3s 32ms/step - loss: 2.1981e-04 - accuracy: 0.1725 - val_loss: 0.0101 - val_accuracy: 0.1262 Epoch 222/300 85/85 [==============================] - 3s 32ms/step - loss: 2.1127e-04 - accuracy: 0.1743 - val_loss: 0.0086 - val_accuracy: 0.1130 Epoch 223/300 85/85 [==============================] - 3s 32ms/step - loss: 2.6292e-04 - accuracy: 0.1680 - val_loss: 0.0074 - val_accuracy: 0.1130 Epoch 224/300 85/85 [==============================] - 3s 32ms/step - loss: 6.6618e-04 - accuracy: 0.1558 - val_loss: 0.0083 - val_accuracy: 0.1163 Epoch 225/300 85/85 [==============================] - 3s 33ms/step - loss: 3.7488e-04 - accuracy: 0.1677 - val_loss: 0.0063 - val_accuracy: 0.1462 Epoch 226/300 85/85 [==============================] - 3s 33ms/step - loss: 6.9396e-04 - accuracy: 0.1625 - val_loss: 0.0060 - val_accuracy: 0.1429 Epoch 227/300 85/85 [==============================] - 3s 32ms/step - loss: 4.6574e-04 - accuracy: 0.1662 - val_loss: 0.0079 - val_accuracy: 0.1096 Epoch 228/300 85/85 [==============================] - 3s 33ms/step - loss: 2.9066e-04 - accuracy: 0.1610 - val_loss: 0.0086 - val_accuracy: 0.1495 Epoch 229/300 85/85 [==============================] - 3s 34ms/step - loss: 2.5942e-04 - accuracy: 0.1529 - val_loss: 0.0078 - val_accuracy: 0.1262 Epoch 230/300 85/85 [==============================] - 3s 32ms/step - loss: 2.7177e-04 - accuracy: 0.1699 - val_loss: 0.0086 - val_accuracy: 0.1362 Epoch 231/300 85/85 [==============================] - 3s 32ms/step - loss: 2.6413e-04 - accuracy: 0.1680 - val_loss: 0.0084 - val_accuracy: 0.1395 Epoch 232/300 85/85 [==============================] - 3s 32ms/step - loss: 2.1452e-04 - accuracy: 0.1780 - val_loss: 0.0084 - val_accuracy: 0.1130 Epoch 233/300 85/85 [==============================] - 3s 32ms/step - loss: 2.0841e-04 - accuracy: 0.1828 - val_loss: 0.0089 - val_accuracy: 0.1595 Epoch 234/300 85/85 [==============================] - 3s 33ms/step - loss: 2.0179e-04 - accuracy: 0.1909 - val_loss: 0.0082 - val_accuracy: 0.1130 Epoch 235/300 85/85 [==============================] - 3s 32ms/step - loss: 2.0802e-04 - accuracy: 0.1754 - val_loss: 0.0072 - val_accuracy: 0.1296 Epoch 236/300 85/85 [==============================] - 3s 33ms/step - loss: 2.0091e-04 - accuracy: 0.1765 - val_loss: 0.0081 - val_accuracy: 0.1063 Epoch 237/300 85/85 [==============================] - 3s 32ms/step - loss: 2.3854e-04 - accuracy: 0.1736 - val_loss: 0.0078 - val_accuracy: 0.1163 Epoch 238/300 85/85 [==============================] - 3s 32ms/step - loss: 2.2894e-04 - accuracy: 0.1717 - val_loss: 0.0083 - val_accuracy: 0.1229 Epoch 239/300 85/85 [==============================] - 3s 32ms/step - loss: 2.1624e-04 - accuracy: 0.1824 - val_loss: 0.0080 - val_accuracy: 0.1296 Epoch 240/300 85/85 [==============================] - 3s 33ms/step - loss: 2.2339e-04 - accuracy: 0.1769 - val_loss: 0.0094 - val_accuracy: 0.1395 Epoch 241/300 85/85 [==============================] - 3s 33ms/step - loss: 4.0529e-04 - accuracy: 0.1699 - val_loss: 0.0068 - val_accuracy: 0.1528 Epoch 242/300 85/85 [==============================] - 3s 32ms/step - loss: 3.7847e-04 - accuracy: 0.1754 - val_loss: 0.0086 - val_accuracy: 0.1229 Epoch 243/300 85/85 [==============================] - 3s 32ms/step - loss: 2.3826e-04 - accuracy: 0.1846 - val_loss: 0.0081 - val_accuracy: 0.1196 Epoch 244/300 85/85 [==============================] - 3s 32ms/step - loss: 1.8986e-04 - accuracy: 0.1883 - val_loss: 0.0077 - val_accuracy: 0.1196 Epoch 245/300 85/85 [==============================] - 3s 32ms/step - loss: 1.9554e-04 - accuracy: 0.1747 - val_loss: 0.0078 - val_accuracy: 0.1296 Epoch 246/300 85/85 [==============================] - 3s 32ms/step - loss: 1.8324e-04 - accuracy: 0.1854 - val_loss: 0.0091 - val_accuracy: 0.1528 Epoch 247/300 85/85 [==============================] - 3s 32ms/step - loss: 1.8523e-04 - accuracy: 0.1743 - val_loss: 0.0089 - val_accuracy: 0.1296 Epoch 248/300 85/85 [==============================] - 3s 31ms/step - loss: 1.7693e-04 - accuracy: 0.1891 - val_loss: 0.0074 - val_accuracy: 0.1329 Epoch 249/300 85/85 [==============================] - 3s 32ms/step - loss: 1.8544e-04 - accuracy: 0.1843 - val_loss: 0.0082 - val_accuracy: 0.1196 Epoch 250/300 85/85 [==============================] - 3s 31ms/step - loss: 1.7698e-04 - accuracy: 0.1865 - val_loss: 0.0088 - val_accuracy: 0.1395 Epoch 251/300 85/85 [==============================] - 3s 31ms/step - loss: 1.8378e-04 - accuracy: 0.1758 - val_loss: 0.0064 - val_accuracy: 0.1163 Epoch 252/300 85/85 [==============================] - 3s 32ms/step - loss: 2.8670e-04 - accuracy: 0.1665 - val_loss: 0.0106 - val_accuracy: 0.1030 Epoch 253/300 85/85 [==============================] - 3s 31ms/step - loss: 3.3275e-04 - accuracy: 0.1680 - val_loss: 0.0071 - val_accuracy: 0.0997 Epoch 254/300 85/85 [==============================] - 3s 31ms/step - loss: 2.0433e-04 - accuracy: 0.1758 - val_loss: 0.0085 - val_accuracy: 0.1362 Epoch 255/300 85/85 [==============================] - 3s 31ms/step - loss: 1.8857e-04 - accuracy: 0.1769 - val_loss: 0.0077 - val_accuracy: 0.1561 Epoch 256/300 85/85 [==============================] - 3s 31ms/step - loss: 1.8027e-04 - accuracy: 0.1606 - val_loss: 0.0090 - val_accuracy: 0.1661 Epoch 257/300 85/85 [==============================] - 3s 31ms/step - loss: 1.7712e-04 - accuracy: 0.1824 - val_loss: 0.0073 - val_accuracy: 0.1196 Epoch 258/300 85/85 [==============================] - 3s 31ms/step - loss: 1.8213e-04 - accuracy: 0.1684 - val_loss: 0.0085 - val_accuracy: 0.1561 Epoch 259/300 85/85 [==============================] - 3s 31ms/step - loss: 1.8197e-04 - accuracy: 0.1832 - val_loss: 0.0073 - val_accuracy: 0.1628 Epoch 260/300 85/85 [==============================] - 3s 32ms/step - loss: 2.0240e-04 - accuracy: 0.1621 - val_loss: 0.0082 - val_accuracy: 0.1561 Epoch 261/300 85/85 [==============================] - 3s 32ms/step - loss: 2.3078e-04 - accuracy: 0.1813 - val_loss: 0.0076 - val_accuracy: 0.0963 Epoch 262/300 85/85 [==============================] - 3s 32ms/step - loss: 1.8620e-04 - accuracy: 0.1784 - val_loss: 0.0087 - val_accuracy: 0.1196 Epoch 263/300 85/85 [==============================] - 3s 31ms/step - loss: 1.7584e-04 - accuracy: 0.1795 - val_loss: 0.0084 - val_accuracy: 0.1429 Epoch 264/300 85/85 [==============================] - 3s 31ms/step - loss: 4.6043e-04 - accuracy: 0.1688 - val_loss: 0.0097 - val_accuracy: 0.1628 Epoch 265/300 85/85 [==============================] - 3s 32ms/step - loss: 4.9060e-04 - accuracy: 0.1684 - val_loss: 0.0068 - val_accuracy: 0.1229 Epoch 266/300 85/85 [==============================] - 3s 33ms/step - loss: 3.0577e-04 - accuracy: 0.1677 - val_loss: 0.0102 - val_accuracy: 0.1462 Epoch 267/300 85/85 [==============================] - 3s 35ms/step - loss: 2.4937e-04 - accuracy: 0.1857 - val_loss: 0.0109 - val_accuracy: 0.1595 Epoch 268/300 85/85 [==============================] - 3s 32ms/step - loss: 4.5277e-04 - accuracy: 0.1691 - val_loss: 0.0082 - val_accuracy: 0.1096 Epoch 269/300 85/85 [==============================] - 3s 32ms/step - loss: 4.6092e-04 - accuracy: 0.1595 - val_loss: 0.0141 - val_accuracy: 0.1694 Epoch 270/300 85/85 [==============================] - 3s 33ms/step - loss: 2.7472e-04 - accuracy: 0.1658 - val_loss: 0.0086 - val_accuracy: 0.1362 Epoch 271/300 85/85 [==============================] - 3s 32ms/step - loss: 1.9118e-04 - accuracy: 0.1913 - val_loss: 0.0088 - val_accuracy: 0.1628 Epoch 272/300 85/85 [==============================] - 3s 32ms/step - loss: 1.7644e-04 - accuracy: 0.1798 - val_loss: 0.0092 - val_accuracy: 0.1561 Epoch 273/300 85/85 [==============================] - 3s 32ms/step - loss: 1.7394e-04 - accuracy: 0.1968 - val_loss: 0.0095 - val_accuracy: 0.1761 Epoch 274/300 85/85 [==============================] - 3s 34ms/step - loss: 1.6944e-04 - accuracy: 0.1843 - val_loss: 0.0094 - val_accuracy: 0.1528 Epoch 275/300 85/85 [==============================] - 3s 33ms/step - loss: 1.6645e-04 - accuracy: 0.1913 - val_loss: 0.0084 - val_accuracy: 0.1595 Epoch 276/300 85/85 [==============================] - 3s 32ms/step - loss: 1.5933e-04 - accuracy: 0.1950 - val_loss: 0.0082 - val_accuracy: 0.1462 Epoch 277/300 85/85 [==============================] - 3s 31ms/step - loss: 1.6282e-04 - accuracy: 0.1843 - val_loss: 0.0095 - val_accuracy: 0.1595 Epoch 278/300 85/85 [==============================] - 3s 31ms/step - loss: 1.7163e-04 - accuracy: 0.1913 - val_loss: 0.0087 - val_accuracy: 0.1595 Epoch 279/300 85/85 [==============================] - 3s 31ms/step - loss: 1.6696e-04 - accuracy: 0.1883 - val_loss: 0.0074 - val_accuracy: 0.1495 Epoch 280/300 85/85 [==============================] - 3s 31ms/step - loss: 1.7976e-04 - accuracy: 0.1850 - val_loss: 0.0075 - val_accuracy: 0.1561 Epoch 281/300 85/85 [==============================] - 3s 30ms/step - loss: 1.6432e-04 - accuracy: 0.1824 - val_loss: 0.0093 - val_accuracy: 0.1595 Epoch 282/300 85/85 [==============================] - 3s 32ms/step - loss: 1.6231e-04 - accuracy: 0.1942 - val_loss: 0.0081 - val_accuracy: 0.1661 Epoch 283/300 85/85 [==============================] - 3s 33ms/step - loss: 1.7167e-04 - accuracy: 0.1743 - val_loss: 0.0078 - val_accuracy: 0.1595 Epoch 284/300 85/85 [==============================] - 3s 33ms/step - loss: 1.6507e-04 - accuracy: 0.1972 - val_loss: 0.0082 - val_accuracy: 0.1561 Epoch 285/300 85/85 [==============================] - 3s 32ms/step - loss: 1.6498e-04 - accuracy: 0.1865 - val_loss: 0.0081 - val_accuracy: 0.1429 Epoch 286/300 85/85 [==============================] - 3s 32ms/step - loss: 1.6122e-04 - accuracy: 0.1839 - val_loss: 0.0095 - val_accuracy: 0.1595 Epoch 287/300 85/85 [==============================] - 3s 32ms/step - loss: 1.9508e-04 - accuracy: 0.1957 - val_loss: 0.0060 - val_accuracy: 0.1561 Epoch 288/300 85/85 [==============================] - 3s 32ms/step - loss: 9.5596e-04 - accuracy: 0.1521 - val_loss: 0.0097 - val_accuracy: 0.1096 Epoch 289/300 85/85 [==============================] - 3s 32ms/step - loss: 4.4825e-04 - accuracy: 0.1581 - val_loss: 0.0101 - val_accuracy: 0.1528 Epoch 290/300 85/85 [==============================] - 3s 32ms/step - loss: 2.4948e-04 - accuracy: 0.1917 - val_loss: 0.0095 - val_accuracy: 0.1429 Epoch 291/300 85/85 [==============================] - 3s 32ms/step - loss: 2.1302e-04 - accuracy: 0.1739 - val_loss: 0.0078 - val_accuracy: 0.1262 Epoch 292/300 85/85 [==============================] - 3s 32ms/step - loss: 2.3691e-04 - accuracy: 0.1662 - val_loss: 0.0086 - val_accuracy: 0.1296 Epoch 293/300 85/85 [==============================] - 3s 32ms/step - loss: 1.7278e-04 - accuracy: 0.1880 - val_loss: 0.0093 - val_accuracy: 0.1495 Epoch 294/300 85/85 [==============================] - 3s 32ms/step - loss: 1.5853e-04 - accuracy: 0.1894 - val_loss: 0.0089 - val_accuracy: 0.1595 Epoch 295/300 85/85 [==============================] - 3s 32ms/step - loss: 1.6417e-04 - accuracy: 0.1891 - val_loss: 0.0083 - val_accuracy: 0.1495 Epoch 296/300 85/85 [==============================] - 3s 32ms/step - loss: 1.5662e-04 - accuracy: 0.1835 - val_loss: 0.0081 - val_accuracy: 0.1495 Epoch 297/300 85/85 [==============================] - 3s 31ms/step - loss: 1.5482e-04 - accuracy: 0.1998 - val_loss: 0.0096 - val_accuracy: 0.1661 Epoch 298/300 85/85 [==============================] - 3s 31ms/step - loss: 1.8015e-04 - accuracy: 0.1813 - val_loss: 0.0088 - val_accuracy: 0.1761 Epoch 299/300 85/85 [==============================] - 3s 31ms/step - loss: 1.7617e-04 - accuracy: 0.2094 - val_loss: 0.0084 - val_accuracy: 0.1628 Epoch 300/300 85/85 [==============================] - 3s 31ms/step - loss: 1.6028e-04 - accuracy: 0.1839 - val_loss: 0.0089 - val_accuracy: 0.1694
# model.save("forecasting_mode.h5")
model.load("forecasting_mode.h5")
Visualizing the Results
plt.figure(figsize=(12,4))
predictions = model.predict(inputs[-1].reshape(1, steps_in, num_features)).tolist()[0]
predictions = scaler.inverse_transform(np.array(predictions).reshape(-1,1)).tolist()
actual = scaler.inverse_transform(targets[-1].reshape(-1,1))
# print("predicted ", predictions)
plt.plot(predictions, label='predicted')
# print("actual ", actual.tolist())
plt.plot(actual.tolist(), label='actual')
plt.title("Predicted vs Actual")
plt.xlabel("Time")
plt.ylabel('Price')
plt.legend()
plt.show()
1/1 [==============================] - 0s 24ms/step
Visualizing Forecast Predictions
predictions = model.predict(np.array(bc_scaled.tail(steps_in)).reshape(1, steps_in, num_features)).tolist()[0]
predictions = scaler.inverse_transform(np.array(predictions).reshape(-1,1)).tolist()
predictions = pd.DataFrame(predictions,
index=pd.date_range(start=bc_scaled.index[-1],
periods=len(predictions),freq="D"),
columns=bc_scaled.columns)
# print(preds)
periods = 10
actual = pd.DataFrame(scaler.inverse_transform(bc_scaled.tail(periods)),
index = bc_scaled.Close.tail(periods).index,
columns = bc_scaled.columns)
actual = pd.concat([actual, predictions.head(1)])
plt.figure(figsize=(12,4))
plt.plot(actual, label='actuals')
plt.plot(predictions, label='predictions')
plt.ylabel("price")
plt.xlabel('dates')
plt.title(f'Forecasting the next {len(predictions)} days')
plt.legend()
plt.show()
1/1 [==============================] - 0s 25ms/step