#python #pandas #tensorflow #data-science #pandas-datareader
Вопрос:
У меня возникли проблемы с моим биржевым предсказателем. Мои прогнозируемые данные предсказывали данные за день до того, как это должно было произойти, и все мои фреймы данных, похоже, верны. вот весь код, так как я не знаю, где ошибка:
from tensorflow import keras
import numpy as np
import pandas as pd
from pandas_datareader.data import DataReader
import pandas_datareader.data as web
import matplotlib.pyplot as plt
#returns a list of the exponential simple moving average for the amount of past days and has to be in range with the maximum rolling days among all of these function
def EMA(days:int, prices, max_ma_days):
ema = prices.ewm(
span=days,
adjust=False,
min_periods=0
).mean().to_numpy()
return np.round(ema, decimals=3)[max_ma_days-1:]
#returns a list of the simple moving average for the amount of past days and has to be in range with the maximum rolling days among all of these function
def SMA(days:int, prices, max_ma_days):
sma = prices.rolling(
window=days,
min_periods=days
).mean().to_numpy()
return np.round(sma, decimals=3)[max_ma_days-1:]
#returns a list of the standard deviation for the amount of past days and has to be in range with the maximum rolling days among all of these function
def StdDev(days:int, prices, max_ma_days):
std = prices.rolling(
days,
min_periods=days
).std(ddof=0)
return np.round(std, decimals=3)[max_ma_days-1:]
#returns a list of the differences between two lists
def difference(dat1, dat2):
if len(dat1) == len(dat2):
return [i-j for i, j in zip(dat1, dat2)]
else:
return Error("enter arrays with the same length")
MaxMaDays = 50
#gets training data
train_data = web.get_data_yahoo("AAPL", "2004-01-20", "2018-12-7")
train_stocks = train_data.iloc[:-1]
#gets testing data
test_data = web.get_data_yahoo("AAPL", "2019-01-21", "2021-6-10")
test_stocks = test_data.iloc[:-1]
# training data
train_close = train_stocks['Close']
#creates the dataframes for the three previous days
data_train_1 = pd.DataFrame(train_close).drop('Close', axis=1)[MaxMaDays 1:]
data_train_2 = pd.DataFrame(train_close).drop('Close', axis=1)[MaxMaDays:-1]
data_train_3 = pd.DataFrame(train_close).drop('Close', axis=1)[MaxMaDays-1:-2]
#y_train data for the predictions for the next day
next_day_close_train = np.array([[i] for i in train_data['Close'][MaxMaDays 2:]])
#displays y_train data
print('y_train: n', train_data['Close'][MaxMaDays 2:])
#adds data to the three previous days dataframe
data_train_1['O-C'] = np.round(np.array([i-j for i, j in zip(train_stocks['Open'], train_close)]), decimals=3)[MaxMaDays 1:]
data_train_2['O-C'] = np.round(np.array([i-j for i, j in zip(train_stocks['Open'], train_close)]), decimals=3)[MaxMaDays:-1]
data_train_3['O-C'] = np.round(np.array([i-j for i, j in zip(train_stocks['Open'], train_close)]), decimals=3)[MaxMaDays-1:-2]
data_train_1['Mid'] = np.round(np.array([(i j x)/3 for i, j, x in zip(train_stocks['High'], train_stocks['Low'], train_close)]), decimals=3)[MaxMaDays 1:]
data_train_2['Mid'] = np.round(np.array([(i j x)/3 for i, j, x in zip(train_stocks['High'], train_stocks['Low'], train_close)]), decimals=3)[MaxMaDays:-1]
data_train_3['Mid'] = np.round(np.array([(i j x)/3 for i, j, x in zip(train_stocks['High'], train_stocks['Low'], train_close)]), decimals=3)[MaxMaDays-1:-2]
data_train_1['H-L'] = np.round(np.array([i-j for i, j in zip(train_stocks['High'], train_stocks['Low'])]), decimals=3)[MaxMaDays 1:]
data_train_2['H-L'] = np.round(np.array([i-j for i, j in zip(train_stocks['High'], train_stocks['Low'])]), decimals=3)[MaxMaDays:-1]
data_train_3['H-L'] = np.round(np.array([i-j for i, j in zip(train_stocks['High'], train_stocks['Low'])]), decimals=3)[MaxMaDays-1:-2]
data_train_1['Adj'] = np.round(train_stocks["Adj Close"], decimals=3)[MaxMaDays 1:]
data_train_2['Adj'] = np.round(train_stocks["Adj Close"], decimals=3)[MaxMaDays:-1]
data_train_3['Adj'] = np.round(train_stocks["Adj Close"], decimals=3)[MaxMaDays-1:-2]
data_train_1['Vol'] = np.round(train_stocks["Volume"].to_numpy()/1000000000, decimals=3)[MaxMaDays 1:]
data_train_2['Vol'] = np.round(train_stocks["Volume"].to_numpy()/1000000000, decimals=3)[MaxMaDays:-1]
data_train_3['Vol'] = np.round(train_stocks["Volume"].to_numpy()/1000000000, decimals=3)[MaxMaDays-1:-2]
data_train_1['Std7'] = StdDev(7, train_close, MaxMaDays)[2:]
data_train_1['Std14'] = StdDev(14, train_close, MaxMaDays)[2:]
data_train_1['Std21'] = StdDev(21, train_close, MaxMaDays)[2:]
data_train_1['Std28'] = StdDev(28, train_close, MaxMaDays)[2:]
data_train_1['Std50'] = StdDev(50, train_close, MaxMaDays)[2:]
data_train_1['Ema7'] = EMA(7, train_close, MaxMaDays)[2:]
data_train_1['Ema14'] = EMA(14, train_close, MaxMaDays)[2:]
data_train_1['Ema21'] = EMA(21, train_close, MaxMaDays)[2:]
data_train_1['Ema28'] = EMA(28, train_close, MaxMaDays)[2:]
data_train_1['Ema50'] = EMA(50, train_close, MaxMaDays)[2:]
data_train_1['Ma7'] = SMA(7, train_close, MaxMaDays)[2:]
data_train_1['Ma14'] = SMA(14, train_close, MaxMaDays)[2:]
data_train_1['Ma21'] = SMA(21, train_close, MaxMaDays)[2:]
data_train_1['Ma28'] = SMA(28, train_close, MaxMaDays)[2:]
data_train_1['Ma50'] = SMA(50, train_close, MaxMaDays)[2:]
data_train_2['Std7'] = StdDev(7, train_close, MaxMaDays)[1:-1]
data_train_2['Std14'] = StdDev(14, train_close, MaxMaDays)[1:-1]
data_train_2['Std21'] = StdDev(21, train_close, MaxMaDays)[1:-1]
data_train_2['Std28'] = StdDev(28, train_close, MaxMaDays)[1:-1]
data_train_2['Std50'] = StdDev(50, train_close, MaxMaDays)[1:-1]
data_train_2['Ema7'] = EMA(7, train_close, MaxMaDays)[1:-1]
data_train_2['Ema14'] = EMA(14, train_close, MaxMaDays)[1:-1]
data_train_2['Ema21'] = EMA(21, train_close, MaxMaDays)[1:-1]
data_train_2['Ema28'] = EMA(28, train_close, MaxMaDays)[1:-1]
data_train_2['Ema50'] = EMA(50, train_close, MaxMaDays)[1:-1]
data_train_2['Ma7'] = SMA(7, train_close, MaxMaDays)[1:-1]
data_train_2['Ma14'] = SMA(14, train_close, MaxMaDays)[1:-1]
data_train_2['Ma21'] = SMA(21, train_close, MaxMaDays)[1:-1]
data_train_2['Ma28'] = SMA(28, train_close, MaxMaDays)[1:-1]
data_train_2['Ma50'] = SMA(50, train_close, MaxMaDays)[1:-1]
data_train_3['Std7'] = StdDev(7, train_close, MaxMaDays)[0:-2]
data_train_3['Std14'] = StdDev(14, train_close, MaxMaDays)[0:-2]
data_train_3['Std21'] = StdDev(21, train_close, MaxMaDays)[0:-2]
data_train_3['Std28'] = StdDev(28, train_close, MaxMaDays)[0:-2]
data_train_3['Std50'] = StdDev(50, train_close, MaxMaDays)[0:-2]
data_train_3['Ema7'] = EMA(7, train_close, MaxMaDays)[0:-2]
data_train_3['Ema14'] = EMA(14, train_close, MaxMaDays)[0:-2]
data_train_3['Ema21'] = EMA(21, train_close, MaxMaDays)[0:-2]
data_train_3['Ema28'] = EMA(28, train_close, MaxMaDays)[0:-2]
data_train_3['Ema50'] = EMA(50, train_close, MaxMaDays)[0:-2]
data_train_3['Ma7'] = SMA(7, train_close, MaxMaDays)[0:-2]
data_train_3['Ma14'] = SMA(14, train_close, MaxMaDays)[0:-2]
data_train_3['Ma21'] = SMA(21, train_close, MaxMaDays)[0:-2]
data_train_3['Ma28'] = SMA(28, train_close, MaxMaDays)[0:-2]
data_train_3['Ma50'] = SMA(50, train_close, MaxMaDays)[0:-2]
print('previous day train data: n', data_train_1)
print('2 days before train data: n', data_train_2)
print('3 days before train data: n', data_train_3)
# testing data
test_close = test_stocks['Close']
#creates the dataframes for the three previous days
data_test_1 = pd.DataFrame(test_close).drop('Close', axis=1)[MaxMaDays 1:]
data_test_2 = pd.DataFrame(test_close).drop('Close', axis=1)[MaxMaDays:-1]
data_test_3 = pd.DataFrame(test_close).drop('Close', axis=1)[MaxMaDays-1:-2]
#y_test data for the predictions for the next day
next_day_close_test = np.array([[i] for i in test_data['Close'][MaxMaDays 2:]])
#displays y_test data
print('y_test ', test_data['Close'][MaxMaDays 2:])
#adds data to the three previous days dataframe
data_test_1['O-C'] = np.round(np.array([i-j for i, j in zip(test_stocks['Open'], test_close)]), decimals=3)[MaxMaDays 1:]
data_test_2['O-C'] = np.round(np.array([i-j for i, j in zip(test_stocks['Open'], test_close)]), decimals=3)[MaxMaDays:-1]
data_test_3['O-C'] = np.round(np.array([i-j for i, j in zip(test_stocks['Open'], test_close)]), decimals=3)[MaxMaDays-1:-2]
data_test_1['Mid'] = np.round(np.array([(i j x)/3 for i, j, x in zip(test_stocks['High'], test_stocks['Low'], test_close)]), decimals=3)[MaxMaDays 1:]
data_test_2['Mid'] = np.round(np.array([(i j x)/3 for i, j, x in zip(test_stocks['High'], test_stocks['Low'], test_close)]), decimals=3)[MaxMaDays:-1]
data_test_3['Mid'] = np.round(np.array([(i j x)/3 for i, j, x in zip(test_stocks['High'], test_stocks['Low'], test_close)]), decimals=3)[MaxMaDays-1:-2]
data_test_1['H-L'] = np.round(np.array([i-j for i, j in zip(test_stocks['High'], test_stocks['Low'])]), decimals=3)[MaxMaDays 1:]
data_test_2['H-L'] = np.round(np.array([i-j for i, j in zip(test_stocks['High'], test_stocks['Low'])]), decimals=3)[MaxMaDays:-1]
data_test_3['H-L'] = np.round(np.array([i-j for i, j in zip(test_stocks['High'], test_stocks['Low'])]), decimals=3)[MaxMaDays-1:-2]
data_test_1['Adj'] = np.round(test_stocks["Adj Close"], decimals=3)[MaxMaDays 1:]
data_test_2['Adj'] = np.round(test_stocks["Adj Close"], decimals=3)[MaxMaDays:-1]
data_test_3['Adj'] = np.round(test_stocks["Adj Close"], decimals=3)[MaxMaDays-1:-2]
data_test_1['Vol'] = np.round(test_stocks["Volume"].to_numpy()/1000000000, decimals=3)[MaxMaDays 1:]
data_test_2['Vol'] = np.round(test_stocks["Volume"].to_numpy()/1000000000, decimals=3)[MaxMaDays:-1]
data_test_3['Vol'] = np.round(test_stocks["Volume"].to_numpy()/1000000000, decimals=3)[MaxMaDays-1:-2]
data_test_1['Std7'] = StdDev(7, test_close, MaxMaDays)[2:]
data_test_1['Std14'] = StdDev(14, test_close, MaxMaDays)[2:]
data_test_1['Std21'] = StdDev(21, test_close, MaxMaDays)[2:]
data_test_1['Std28'] = StdDev(28, test_close, MaxMaDays)[2:]
data_test_1['Std50'] = StdDev(50, test_close, MaxMaDays)[2:]
data_test_1['Ema7'] = EMA(7, test_close, MaxMaDays)[2:]
data_test_1['Ema14'] = EMA(14, test_close, MaxMaDays)[2:]
data_test_1['Ema21'] = EMA(21, test_close, MaxMaDays)[2:]
data_test_1['Ema28'] = EMA(28, test_close, MaxMaDays)[2:]
data_test_1['Ema50'] = EMA(50, test_close, MaxMaDays)[2:]
data_test_1['Ma7'] = SMA(7, test_close, MaxMaDays)[2:]
data_test_1['Ma14'] = SMA(14, test_close, MaxMaDays)[2:]
data_test_1['Ma21'] = SMA(21, test_close, MaxMaDays)[2:]
data_test_1['Ma28'] = SMA(28, test_close, MaxMaDays)[2:]
data_test_1['Ma50'] = SMA(50, test_close, MaxMaDays)[2:]
data_test_2['Std7'] = StdDev(7, test_close, MaxMaDays)[1:-1]
data_test_2['Std14'] = StdDev(14, test_close, MaxMaDays)[1:-1]
data_test_2['Std21'] = StdDev(21, test_close, MaxMaDays)[1:-1]
data_test_2['Std28'] = StdDev(28, test_close, MaxMaDays)[1:-1]
data_test_2['Std50'] = StdDev(50, test_close, MaxMaDays)[1:-1]
data_test_2['Ema7'] = EMA(7, test_close, MaxMaDays)[1:-1]
data_test_2['Ema14'] = EMA(14, test_close, MaxMaDays)[1:-1]
data_test_2['Ema21'] = EMA(21, test_close, MaxMaDays)[1:-1]
data_test_2['Ema28'] = EMA(28, test_close, MaxMaDays)[1:-1]
data_test_2['Ema50'] = EMA(50, test_close, MaxMaDays)[1:-1]
data_test_2['Ma7'] = SMA(7, test_close, MaxMaDays)[1:-1]
data_test_2['Ma14'] = SMA(14, test_close, MaxMaDays)[1:-1]
data_test_2['Ma21'] = SMA(21, test_close, MaxMaDays)[1:-1]
data_test_2['Ma28'] = SMA(28, test_close, MaxMaDays)[1:-1]
data_test_2['Ma50'] = SMA(50, test_close, MaxMaDays)[1:-1]
data_test_3['Std7'] = StdDev(7, test_close, MaxMaDays)[0:-2]
data_test_3['Std14'] = StdDev(14, test_close, MaxMaDays)[0:-2]
data_test_3['Std21'] = StdDev(21, test_close, MaxMaDays)[0:-2]
data_test_3['Std28'] = StdDev(28, test_close, MaxMaDays)[0:-2]
data_test_3['Std50'] = StdDev(50, test_close, MaxMaDays)[0:-2]
data_test_3['Ema7'] = EMA(7, test_close, MaxMaDays)[0:-2]
data_test_3['Ema14'] = EMA(14, test_close, MaxMaDays)[0:-2]
data_test_3['Ema21'] = EMA(21, test_close, MaxMaDays)[0:-2]
data_test_3['Ema28'] = EMA(28, test_close, MaxMaDays)[0:-2]
data_test_3['Ema50'] = EMA(50, test_close, MaxMaDays)[0:-2]
data_test_3['Ma7'] = SMA(7, test_close, MaxMaDays)[0:-2]
data_test_3['Ma14'] = SMA(14, test_close, MaxMaDays)[0:-2]
data_test_3['Ma21'] = SMA(21, test_close, MaxMaDays)[0:-2]
data_test_3['Ma28'] = SMA(28, test_close, MaxMaDays)[0:-2]
data_test_3['Ma50'] = SMA(50, test_close, MaxMaDays)[0:-2]
print('previous day test data: n', data_test_1)
print('2 days before test data: n', data_test_2)
print('3 days before test data: n', data_test_3)
input_format = ['H-L', "O-C", "7Ma", "14Ma", "21Ma", "7STD", "vol"]
#creates the x_train or x_test data
def input_data(dat1, dat2, dat3):
l = []
l2= []
for i in range(len(dat1['Vol'])):
for j in dat1:
l2.append(dat1[j][i])
l2.append(dat2[j][i])
l2.append(dat3[j][i])
l.append(l2)
l2 = []
return l
#x_test
test_inputs = np.array(input_data(data_test_1, data_test_2, data_test_3))
#x_train
train_inputs = np.array(input_data(data_train_1, data_train_2, data_train_3))
model = keras.models.Sequential()
model.add(keras.layers.Dense(60,))
model.add(keras.layers.Dense(8, activation='relu'))
model.add(keras.layers.Dense(1))
working:dict = {"23":4, "27":5}
model.compile(optimizer='adamax', loss="mape",)
model.fit(train_inputs, next_day_close_train, epochs=300,)
#model.save('AAPL_prediction_model.h5')
#model = keras.models.load_model('AAPL_prediction_model.h5')
#makes predictions
predictions = model.predict(test_inputs)[:10]
#gets the actual price
actual = next_day_close_test[:10]
#gets the price differences
dif = difference(actual, predictions)
print(f"predictions:{predictions}n")
print(f"actual:{actual}n")
highp:int = 160
# plots the predictions and the actual prices
fig, ax = plt.subplots() # Create a figure and an axes.
ax.plot(predictions, color='blue', marker='o', label='Predictions') # Plot some data on the axes.
ax.plot(actual, color='green', marker='o', label='Actual Price') # Plot more data on the axes...
ax.set_xlabel('Time') # Add an x-label to the axes.
ax.set_ylabel('Price') # Add a y-label to the axes.
ax.set_title("Apple Stock Predictions") # Add a title to the axes.
ax.legend() # Add a legend.
plt.show()
# prints the differenvces of the actual prices and predictions
difference_plot = plt.plot(dif)
plt.title('Price Differences')
plt.xlabel('Time')
plt.xlabel('Price difference')
plt.show()
вот выходные данные фреймов данных:
y_train:
Date
2004-04-02 0.491071
2004-04-05 0.505714
2004-04-06 0.496964
2004-04-07 0.487679
2004-04-08 0.491607
...
2018-11-30 44.645000
2018-12-03 46.205002
2018-12-04 44.172501
2018-12-06 43.680000
2018-12-07 42.122501
Name: Close, Length: 3697, dtype: float64
previous day train data:
O-C Mid H-L Adj ... Ma14 Ma21 Ma28 Ma50
Date ...
2004-04-01 -0.004 0.482 0.012 0.416 ... 0.473 0.474 0.460 0.436
2004-04-02 0.004 0.492 0.012 0.422 ... 0.474 0.476 0.464 0.438
2004-04-05 -0.015 0.501 0.017 0.434 ... 0.477 0.478 0.467 0.440
2004-04-06 -0.002 0.496 0.013 0.427 ... 0.479 0.479 0.470 0.442
2004-04-07 0.005 0.488 0.014 0.419 ... 0.481 0.479 0.472 0.443
... ... ... ... ... ... ... ... ... ...
2018-11-29 0.778 45.004 1.275 43.639 ... 46.141 48.288 49.789 52.343
2018-11-30 0.427 44.662 0.825 43.404 ... 45.678 47.809 49.413 52.136
2018-12-03 -0.090 45.914 0.932 44.920 ... 45.511 47.364 49.075 51.972
2018-12-04 1.065 44.613 1.530 42.944 ... 45.234 46.997 48.732 51.751
2018-12-06 -0.740 43.327 1.090 42.465 ... 45.018 46.677 48.329 51.514
[3697 rows x 20 columns]
2 days before train data:
O-C Mid H-L Adj ... Ma14 Ma21 Ma28 Ma50
Date ...
2004-03-31 0.016 0.488 0.018 0.415 ... 0.473 0.472 0.457 0.435
2004-04-01 -0.004 0.482 0.012 0.416 ... 0.473 0.474 0.460 0.436
2004-04-02 0.004 0.492 0.012 0.422 ... 0.474 0.476 0.464 0.438
2004-04-05 -0.015 0.501 0.017 0.434 ... 0.477 0.478 0.467 0.440
2004-04-06 -0.002 0.496 0.013 0.427 ... 0.479 0.479 0.470 0.442
... ... ... ... ... ... ... ... ... ...
2018-11-28 -1.053 44.763 1.590 43.977 ... 46.657 48.690 50.144 52.537
2018-11-29 0.778 45.004 1.275 43.639 ... 46.141 48.288 49.789 52.343
2018-11-30 0.427 44.662 0.825 43.404 ... 45.678 47.809 49.413 52.136
2018-12-03 -0.090 45.914 0.932 44.920 ... 45.511 47.364 49.075 51.972
2018-12-04 1.065 44.613 1.530 42.944 ... 45.234 46.997 48.732 51.751
[3697 rows x 20 columns]
3 days before train data:
O-C Mid H-L Adj ... Ma14 Ma21 Ma28 Ma50
Date ...
2004-03-30 -0.003 0.495 0.011 0.428 ... 0.473 0.469 0.454 0.433
2004-03-31 0.016 0.488 0.018 0.415 ... 0.473 0.472 0.457 0.435
2004-04-01 -0.004 0.482 0.012 0.416 ... 0.473 0.474 0.460 0.436
2004-04-02 0.004 0.492 0.012 0.422 ... 0.474 0.476 0.464 0.438
2004-04-05 -0.015 0.501 0.017 0.434 ... 0.477 0.478 0.467 0.440
... ... ... ... ... ... ... ... ... ...
2018-11-27 -0.683 43.324 0.972 42.349 ... 47.175 49.063 50.457 52.724
2018-11-28 -1.053 44.763 1.590 43.977 ... 46.657 48.690 50.144 52.537
2018-11-29 0.778 45.004 1.275 43.639 ... 46.141 48.288 49.789 52.343
2018-11-30 0.427 44.662 0.825 43.404 ... 45.678 47.809 49.413 52.136
2018-12-03 -0.090 45.914 0.932 44.920 ... 45.511 47.364 49.075 51.972
[3697 rows x 20 columns]
y_test Date
2019-04-05 49.250000
2019-04-08 50.025002
2019-04-09 49.875000
2019-04-10 50.154999
2019-04-11 49.737499
...
2021-06-04 125.889999
2021-06-07 125.900002
2021-06-08 126.739998
2021-06-09 127.129997
2021-06-10 126.110001
Name: Close, Length: 550, dtype: float64
previous day test data:
O-C Mid H-L Adj ... Ma14 Ma21 Ma28 Ma50
Date ...
2019-04-04 -0.225 48.767 0.807 47.766 ... 47.640 46.721 45.963 44.207
2019-04-05 -0.138 49.169 0.293 48.086 ... 47.800 47.013 46.165 44.429
2019-04-08 -0.920 49.722 0.972 48.843 ... 48.042 47.337 46.390 44.640
2019-04-09 0.205 50.132 0.905 48.696 ... 48.245 47.582 46.626 44.856
2019-04-10 -0.485 49.962 0.640 48.970 ... 48.344 47.817 46.855 45.086
... ... ... ... ... ... ... ... ... ...
2021-06-03 1.140 123.840 1.720 123.355 ... 125.687 126.103 127.721 128.039
2021-06-04 -1.820 125.300 2.310 125.702 ... 125.576 125.998 127.406 128.155
2021-06-07 0.270 125.683 1.490 125.712 ... 125.549 125.815 127.103 128.261
2021-06-08 -0.140 127.137 2.250 126.550 ... 125.684 125.650 126.858 128.372
2021-06-09 0.080 127.133 1.230 126.940 ... 125.859 125.663 126.631 128.487
[550 rows x 20 columns]
2 days before test data:
O-C Mid H-L Adj ... Ma14 Ma21 Ma28 Ma50
Date ...
2019-04-03 -0.525 48.750 0.838 47.683 ... 47.469 46.469 45.771 43.998
2019-04-04 -0.225 48.767 0.807 47.766 ... 47.640 46.721 45.963 44.207
2019-04-05 -0.138 49.169 0.293 48.086 ... 47.800 47.013 46.165 44.429
2019-04-08 -0.920 49.722 0.972 48.843 ... 48.042 47.337 46.390 44.640
2019-04-09 0.205 50.132 0.905 48.696 ... 48.245 47.582 46.626 44.856
... ... ... ... ... ... ... ... ... ...
2021-06-02 -0.780 124.783 1.190 124.873 ... 125.789 126.309 128.106 128.019
2021-06-03 1.140 123.840 1.720 123.355 ... 125.687 126.103 127.721 128.039
2021-06-04 -1.820 125.300 2.310 125.702 ... 125.576 125.998 127.406 128.155
2021-06-07 0.270 125.683 1.490 125.712 ... 125.549 125.815 127.103 128.261
2021-06-08 -0.140 127.137 2.250 126.550 ... 125.684 125.650 126.858 128.372
[550 rows x 20 columns]
3 days before test data:
O-C Mid H-L Adj ... Ma14 Ma21 Ma28 Ma50
Date ...
2019-04-02 -0.733 48.294 0.853 47.359 ... 47.261 46.233 45.571 43.788
2019-04-03 -0.525 48.750 0.838 47.683 ... 47.469 46.469 45.771 43.998
2019-04-04 -0.225 48.767 0.807 47.766 ... 47.640 46.721 45.963 44.207
2019-04-05 -0.138 49.169 0.293 48.086 ... 47.800 47.013 46.165 44.429
2019-04-08 -0.920 49.722 0.972 48.843 ... 48.042 47.337 46.390 44.640
... ... ... ... ... ... ... ... ... ...
2021-06-01 0.800 124.523 1.410 124.094 ... 125.626 126.665 128.352 127.986
2021-06-02 -0.780 124.783 1.190 124.873 ... 125.789 126.309 128.106 128.019
2021-06-03 1.140 123.840 1.720 123.355 ... 125.687 126.103 127.721 128.039
2021-06-04 -1.820 125.300 2.310 125.702 ... 125.576 125.998 127.406 128.155
2021-06-07 0.270 125.683 1.490 125.712 ... 125.549 125.815 127.103 128.261
[550 rows x 20 columns]
***AI training output***
predictions:[[49.19401 ]
[49.537914]
[50.36593 ]
[50.18346 ]
[50.49021 ]
[50.042454]
[49.84023 ]
[49.969204]
[50.043602]
[50.887325]]
actual:[[49.25 ]
[50.02500153]
[49.875 ]
[50.15499878]
[49.73749924]
[49.71749878]
[49.80749893]
[49.8125 ]
[50.78250122]
[50.96500015]]
это график выходных данных для фактической цены и прогноза:
это данные, полученные на графике
мы очень признательны за любую помощь в устранении этой проблемы.