edited by
768 views
1 1 vote

the code is

 

import numpy as np
import pandas as pd
from keras.models import Sequential
from keras.layers import Dense, LSTM, Dropout
from keras.layers.core import Dense, Activation, Dropout
from sklearn.preprocessing import MinMaxScaler
from sklearn.metrics import mean_squared_error
import matplotlib.pyplot as plt

def create_dataset(signal_data, look_back=1):
dataX, dataY = [], []
for i in range(len(signal_data) - look_back):
dataX.append(signal_data[i:(i + look_back), 0])
dataY.append(signal_data[i + look_back, 0])
return np.array(dataX), np.array(dataY)



look_back = 10

# 1. 데이터셋 생성하기
#signal_data = np.cos(np.arange(1600) * (20 * np.pi / 1000))[:, None]
df = pd.read_csv('test.csv')
signal_data = df.Close.values.astype('float32')
signal_data = signal_data.reshape(len(df), 1)

train_size = int(len(signal_data) * 0.80)
test_size = len(signal_data) - train_size
train, test = signal_data[0:train_size,:], signal_data[train_size:len(signal_data),:]

trainX, trainY = create_dataset(train, look_back)
testX, testY = create_dataset(test, look_back)

trainX = np.reshape(trainX, (trainX.shape[0], trainX.shape[1], 1))
testX = np.reshape(testX, (testX.shape[0], testX.shape[1], 1 ))

model = Sequential()
model.add(LSTM(32, input_shape=(look_back, 1)))
model.add(Dropout(0.3))
model.add(Dense(1))

# 3. 모델 학습과정 설정하기
model.compile(loss='mean_squared_error', optimizer='adam')

# 4. 모델 학습시키기
hist = model.fit(trainX, trainY, epochs=10, batch_size=16)
plt.plot(testY)

p = model.predict(testX)
plt.plot(testY)
plt.plot(p)
plt.legend(['testY', 'p'], loc='upper right')
plt.show()

 

and test.csv is

then

i got

i don't know what am i wrong...

help me plz

 

test.csv is https://docs.google.com/spreadsheets/d/13kvyiD7MRsneTiFv3Y6N2fWOPkI-VQ8XdK66fxB026Y/edit?usp=sharing

0% Accept Rate Accepted 0 answers out of 3 questions

1 Answer

0 0 votes
The way I see the results it seems the model is in its local minimum because of the ripples I see, however it is also possible other reasons are involved. Could you please share "test.csv"?

Related questions

1 1 vote
1 1 answer
685
685 views
kmr1994 asked May 1, 2019
685 views
https://stackoverflow.com/questions/55930051/is-impossible-predict-hours-time-series-to-minutes-time-series i want to this hours time series predict model to minute predi...
0 0 votes
1 1 answer
1.1k
1.1k views
Kesz asked Nov 17, 2020
1,143 views
Hi. I have a question about model-based predictions when data is only available after the fact. Let me give you an example. I try to predict the result (HOME, AWAY or a D...
1 1 vote
1 answers 1 answer
1.6k
1.6k views
Kesz asked Oct 27, 2020
1,551 views
So far, I have modeled on known historical data. What if there are variables known only after the fact?Let me give you an example. I want to predict the outcome of the ma...
1 1 vote
1 1 answer
690
690 views
logic asked Sep 28, 2020
690 views
Is that possible to train a machine using another trained machine?
1 1 vote
0 0 answers
1.0k
1.0k views
kmr1994 asked Apr 29, 2019
1,031 views
Here is LSTM predict model and i want to convert Linear Regression.... model.fit(x_train, y_train, epochs=10, batch_size=16) trainPredict = model.predict(x_train) testPre...