title: Efficient approach to calculate test RMSE score in Time series forecasting
body: <p>I have trained a Time series LSTM model of unique product id each having n days data. I used a keras Dataloader to send those product id in singularity to train.
  I'm calculating RMSE score using this code</p>
  <pre><code>start_time = time.time()
  
  for i in range(10000):
  
  ext=l[I]
  '''ext here repserents unique product id'''
  train,test=r[ext][:21],r[ext][20:31]
  
  
  global trainX,trainY,testX,testY
  trainX, trainY = create_dataset(train, look_back)
  testX, testY = create_dataset(test, look_back)
  trainX = np.reshape(trainX, (trainX.shape[0], 1, trainX.shape[1]))
  testX = np.reshape(testX, (testX.shape[0], 1, testX.shape[1]))
  
  
  trainPredict = new_model.predict(trainX)
  testPredict = new_model.predict(testX)
  trainPredictinv = scalar.inverse_transform(trainPredict)
  
  trainYinv = scalar.inverse_transform([trainY])
  
  testPredictinv = scalar.inverse_transform(testPredict)
  testYinv = scalar.inverse_transform([testY])
  
  trainScore = np.sqrt(mean_squared_error(trainYinv[0], trainPredictinv[:,0]))
  
  prodtrainScore.append(trainScore)
  testScore = np.sqrt(mean_squared_error(testYinv[0], testPredictinv[:,0]))
  prodtestScore.append(testScore)
  
  
  
  end_time = time.time()
  print('Execution time = %.6f seconds' % (end_time-start_time))  
  </code></pre>
  <p>this is taking a lot of time to calculate RMSE of 1000000 queries.
  How can I improvise this?</p>
  <p>Create dataset function used above:</p>
  <pre><code>def create_dataset(dataset, look_back=1):
  dataX, dataY = [], []
  for p in range(len(dataset)-(look_back-1)):
      a = dataset[p:(p+look_back)]
      dataX.append(a)
      dataY.append(dataset[p])
  return np.array(dataX), np.array(dataY)
  </code></pre>