I have a problem with the prediction. The program is designed to predict stock market prices. Here EUR / USD. I trained the model and tested it with the test data. The results look good. At this point I can't get any further.
How can I make a prediction? I tested the program with data from yesterday. How can I predict today's data? What should I enter and in what format?
import math
import matplotlib.pyplot as plt
import keras
import pandas as pd
import numpy as np
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import LSTM
from keras.layers import Dropout
from keras.layers import *
from sklearn.preprocessing import MinMaxScaler
from sklearn.metrics import mean_squared_error
from sklearn.metrics import mean_absolute_error
from sklearn.model_selection import train_test_split
from keras.callbacks import EarlyStopping
daten=open("C:")
df = pd.read_csv(daten)
df
training_set = df.iloc[436065:438073, 4:5]
test_set = df.iloc[438074:438170, 4:5]
sc = MinMaxScaler(feature_range = (0, 1))
training_set_scaled = sc.fit_transform(training_set)
X_train = []
y_train = []
for i in range(70, 2000):
X_train.append(training_set_scaled[i-70:i, 0])
y_train.append(training_set_scaled[i, 0])
X_train, y_train = np.array(X_train), np.array(y_train)
X_train = np.reshape(X_train, (X_train.shape[0], X_train.shape[1], 1))
n=50
dop=0.1
model = Sequential()#1
model.add(LSTM(units = n, return_sequences = True, input_shape = (X_train.shape[1], 1)))
model.add(Dropout(dop))#2
model.add(LSTM(units = n, return_sequences = True))
model.add(Dropout(dop))#3
model.add(LSTM(units = n, return_sequences = True))
model.add(Dropout(dop))#4
model.add(LSTM(units = n, return_sequences = True))
model.add(Dropout(dop))#5
model.add(LSTM(units = n, return_sequences = True))
model.add(Dropout(dop))#6
model.add(LSTM(units = n, return_sequences = True))
model.add(Dropout(dop))#7
model.add(LSTM(units = n))
model.add(Dropout(dop))
model.add(Dense(units = 1))
model.compile(optimizer = 'adam', loss = 'mean_squared_error')
model.fit(X_train, y_train, epochs = 100, batch_size =32)
dataset_total = pd.concat((training_set, test_set), axis = 0)
inputs = dataset_total[len(dataset_total) - len(test_set) - 70:].values
inputs = inputs.reshape(-1,1)
inputs = sc.transform(inputs)
type(inputs.shape)
X_test = []
for i in range(70, 167):
X_test.append(inputs[i-70:i, 0])
X_test = np.array(X_test)
X_test = np.reshape(X_test, (X_test.shape[0], X_test.shape[1], 1))
print(X_test.shape)
predicted_stock_price = model.predict(X_test)
predicted_stock_price = sc.inverse_transform(predicted_stock_price)
predicted_stock_price.shape
plt.plot(df.loc[438074:438170, "Close"])
plt.grid(True)
plt.plot(predicted_stock_price)
plt.grid(True)