First time here? Checkout the FAQ!
x
+1 vote
243 views
asked in Machine Learning by (210 points)  
edited by

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

  

1 Answer

0 votes
answered by (116k points)  
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

0 votes
1 answer 597 views
+1 vote
1 answer 703 views
+1 vote
0 answers 265 views
...