These are chat archives for FreeCodeCamp/DataScience

May 2017
May 23 2017 11:38

hey guys,
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
            for line in data:
                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[0], trainX.shape[1], 1))
    testX = np.reshape(testX, (testX.shape[0], testX.shape[1], 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]

        input_shape=(None, layers[0]),




    start = time.time()
    model.compile(loss="mse", optimizer="rmsprop")
    print "Compilation Time : ", time.time() - start
    return model

and this is the prediction function

                X_train, y_train,
                batch_size=batch_size, epochs=epochs, validation_split=0.05)
        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
and this is the result im getting
Leonardo Raduy Lemos
May 23 2017 12:39
@becausealice2, @satenndrra Hi! What kind of input should I generate to D3.js? I'm crunching the survey data with R.
May 23 2017 13:05
Hi there, what is the best recommendation model for a website dealing with fb quizzes?
Alice Jiang
May 23 2017 16:23
@PunkDado I'm not super sure what you're asking.
What format to save the data from R to feed into D3?
Leonardo Raduy Lemos
May 23 2017 16:27
Or another file type?
Or some specially formatted txt?
Alice Jiang
May 23 2017 17:16
D3 assumes JSON but it has built in functionality to convert anything so whatever you like.
If you're using Rmd you can set it up to feed the data to D3 in the same file
May 23 2017 19:09

@ridaamine :
I haven' t run any LSTM on time series data so I looked and found the following reference:

Based on that, I would suggest:

  • Have you tried to check for any overfitting?
  • By looking your neuron structure I suspect for the way you are injecting the parameters that you are building a large network? Have you tried something smaller?
  • I don't remember how Dropout behaves when using recurrent ones. I remember there are some cases where you should NOT use it, but I think yours is not between those cases. Still mentioning, probably helpful...
  • Can you research the effect of the None in the following parameter : input_shape=(None, layers[0]) ?
  • Verify the values of the arguments of the batch input shape?
  • You changed the return_sequence to False in 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, 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.

Neha Sehrawat
May 23 2017 23:56
Hey there I'm new here could someone advice me some platform like this for learning cyber security?