HoBu4okok2021-09-27 22:55:52
HoBu4okok, 2021-09-27 22:55:52

[AI] How to predict a day ahead?

There is an artificial intelligence code (keras library) in Python that receives chart data via the Binance API as input, learns from this data and builds its own chart:
The chart is built up to today. It is necessary to make sure that the schedule is completed at least 1 day ahead.


import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from binance.client import Client
from keras.layers import Dense
from keras.layers import LSTM
from keras.models import Sequential
from sklearn.preprocessing import MinMaxScaler

Code with artificial intelligence:
training_set = data[:10000]
test_set = data[10000:]

X_train, y_train = training_set[0:len(training_set)-1], training_set[1:len(training_set)]
X_test, y_test = test_set[0:len(test_set)-1], test_set[1:len(test_set)]
X_train, X_test = np.reshape(X_train, (len(X_train), 1, X_train.shape[1])), np.reshape(X_test, (len(X_test), 1, X_test.shape[1]))

model = Sequential()
model.add(LSTM(256, return_sequences=True, input_shape=(X_train.shape[1], X_train.shape[2])))

model.compile(loss='mean_squared_error', optimizer='adam')
model.fit(X_train, y_train, epochs=50, batch_size=16, shuffle=False)
model.save('BTCUSDT' + '_model.h5')

predicted_price = model.predict(X_test)
predicted_price = scaler.inverse_transform(predicted_price)
real_price = scaler.inverse_transform(y_test)

plt.figure(figsize=(10, 4))
red_patch = mpatches.Patch(color='red', label='Искуcственный интеллект ' + symbol)
blue_patch = mpatches.Patch(color='blue', label='Настоящий график ' + symbol)
plt.legend(handles=[blue_patch, red_patch])
plt.plot(predicted_price, color='red', label='Искуcственный интеллект ' + symbol)
plt.plot(real_price, color='blue', label='Цена ' + symbol)
plt.title('Искусcтвенный интеллект и настоящий график ' + symbol)
plt.savefig(symbol + '.png')

I will be glad to see your suggestions.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Alan Gibizov, 2021-09-27

No way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question