These are chat archives for FreeCodeCamp/DataScience
discussion on how we can use statistical methods to measure and improve the efficacy of http://freeCodeCamp.com
i'm using keras LSTM model for time series prediction but i'm having trouble setting the parameters and the input (train , test) data the time serie is not long (61 monthly observations) im splitting the data into 50 for training 11 for testing but the result i'm getting are weird (the prediction is constant which it should be at least close to the time series
# load dataset with open('/home/rida/Desktop/projetpfe/ML/Algos/ARIMA/client_conso_elec.csv') as f: data = csv.reader(f) power =  nb_of_values = 0 next(data,None) for line in data: power.append(float(line)) nb_of_values += 1 train_size = 50 series = power train, test = series[0:train_size], series[train_size:len(series)] look_back = 1 trainX, trainY = create_dataset(train, look_back) testX, testY = create_dataset(test, look_back) trainX = np.reshape(trainX, (trainX.shape, trainX.shape, 1)) testX = np.reshape(testX, (testX.shape, testX.shape, 1)) return [trainX, trainY, testX, testY]
here's how i'm splitting the data (the file is just one colum with the observations ) and here's the model
def build_model(): model = Sequential() layers = [1, 64, 256, 100, 1] model.add(LSTM( layers, input_shape=(None, layers), return_sequences=True)) model.add(Dropout(0.2)) model.add(LSTM( layers, return_sequences=True)) model.add(Dropout(0.2)) model.add(LSTM( layers, return_sequences=False)) model.add(Dropout(0.2)) model.add(Dense( layers)) model.add(Activation("linear")) start = time.time() model.compile(loss="mse", optimizer="rmsprop") print "Compilation Time : ", time.time() - start return model
and this is the prediction function
try: print("Training...") model.fit( X_train, y_train, batch_size=batch_size, epochs=epochs, validation_split=0.05) print("Predicting...") predicted = model.predict(X_test) print("Reshaping predicted") predicted = np.reshape(predicted, (predicted.size,)) except KeyboardInterrupt: print("prediction exception") print 'Training duration (s) : ', time.time() - global_start_time return model, y_test, 0
I haven' t run any LSTM on time series data so I looked and found the following reference:
Based on that, I would suggest:
Nonein the following parameter :
Falsein the last
add. For the few examples I checked this parameter was always kept as
True. Probably ok for your problem?
I am just guessing right now. Hope this helps though.
@ankit-jain2 : I don' t know if I understood your question. Quizzes like these ones http://www.quizzes.net/, but in FB? Depends... It is my impression that in the example I gave to you it is possible that they used an unpersonalised/content-based approach. I would be surprise if they try some personalised recommendation, to be honest.
What are you up to, if I can ask? This is a field where I have more experience so I probably can help you more.