Skip to content

Instantly share code, notes, and snippets.

Last active Aug 11, 2020
What would you like to do?
Tada's usage (see discussion)
""" From: """
from keras.models import Sequential
from keras.layers.core import TimeDistributedDense, Activation, Dropout
from keras.layers.recurrent import GRU
import numpy as np
def _load_data(data, steps = 40):
docX, docY = [], []
for i in range(0, data.shape[0]/steps-1):
alsX = np.array(docX)
alsY = np.array(docY)
return alsX, alsY
def train_test_split(data, test_size=0.15):
# This just splits data to training and testing parts
X,Y = _load_data(data)
ntrn = round(X.shape[0] * (1 - test_size))
perms = np.random.permutation(X.shape[0])
X_train, Y_train = X.take(perms[0:ntrn],axis=0), Y.take(perms[0:ntrn],axis=0)
X_test, Y_test = X.take(perms[ntrn:],axis=0),Y.take(perms[ntrn:],axis=0)
return (X_train, Y_train), (X_test, Y_test)
np.random.seed(0) # For reproducability
data = np.genfromtxt('closingAdjLog.csv', delimiter=',')
(X_train, y_train), (X_test, y_test) = train_test_split(np.flipud(data)) # retrieve data
print "Data loaded."
in_out_neurons = 20
hidden_neurons = 200
model = Sequential()
model.add(GRU(hidden_neurons, input_dim=in_out_neurons, return_sequences=True))
model.compile(loss="mean_squared_error", optimizer="rmsprop")
print "Model compiled."
# and now train the model., y_train, batch_size=30, nb_epoch=200, validation_split=0.1)
predicted = model.predict(X_test)
print np.sqrt(((predicted - y_test) ** 2).mean(axis=0)).mean() # Printing RMSE
Copy link

ogencoglu commented Oct 23, 2015

Any chance to have access to 'closingAdjLog.csv' as well?

Copy link

andrewcz commented Nov 7, 2015

me to please.
I was wondering what the file looks like?
Many thanks

Copy link

llydia90 commented Nov 25, 2015

is there any chance to have access to 'closingAdjLog.csv'?

Copy link

wangdelp commented Feb 14, 2016

@hnykda Hi I wonder what are in the closingAdjLog file? Could you share that or just tell what should be the input format? Thank you.

Copy link

emigmo commented Apr 6, 2016

can you share what are in the closingAdjLog file? or the format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment