title: Understanding epoch, batch size, accuracy and performance gain in lstm forecasting model
body: <p>I am new to machine learning and lstm. I am referring this link <a href="https://machinelearningmastery.com/how-to-develop-lstm-models-for-multi-step-time-series-forecasting-of-household-power-consumption/" rel="nofollow noreferrer">LSTM for multistep forecasting</a>  for Encoder-Decoder LSTM Model With Multivariate Input section.</p>
  
  <p>Here is my dataset description after reshaping the train and test set.</p>
  
  <pre><code>print(dataset.shape)
  print(train_x.shape, train_y.shape)
  print((test.shape)
  
  (2192, 15)
  (1806, 14, 14) (1806, 7, 1)
  (364, 15)
  </code></pre>
  
  <p>In above I have <code>n_input=14, n_out=7</code>.</p>
  
  <p>Here is my lstm model description:</p>
  
  <pre><code>def build_model(train, n_input):
      # prepare data
      train_x, train_y = to_supervised(train, n_input)
      # define parameters
      verbose, epochs, batch_size = 2, 100, 16
      n_timesteps, n_features, n_outputs = train_x.shape[1], train_x.shape[2], train_y.shape[1]
      # reshape output into [samples, timesteps, features]
      train_y = train_y.reshape((train_y.shape[0], train_y.shape[1], 1))
      # define model
      model = Sequential()
      model.add(LSTM(200, activation='relu', input_shape=(n_timesteps, n_features)))
      model.add(RepeatVector(n_outputs))
      model.add(LSTM(200, activation='relu', return_sequences=True))
      model.add(TimeDistributed(Dense(100, activation='relu')))
      model.add(TimeDistributed(Dense(1)))
      model.compile(loss='mse', optimizer='adam')
      # fit network
      model.fit(train_x, train_y, epochs=epochs, batch_size=batch_size, verbose=verbose)
      return model
  </code></pre>
  
  <p>On evaluating the model, I am getting the output as:</p>
  
  <pre><code>Epoch 98/100
   - 8s - loss: 64.6554
  Epoch 99/100
   - 7s - loss: 64.4012
  Epoch 100/100
   - 7s - loss: 63.9625
  </code></pre>
  
  <p>According to my understanding: (Please correct me if I am wrong)</p>
  
  <p><code>Here my model accuracy is 63.9625</code> (by seeing the last epoch 100). Also, this is not stable since there is a gap between epoch 99 and epoch 100.</p>
  
  <p>Here are my questions:</p>
  
  <ol>
  <li><p>How epoch and batch size above defined is related to gaining model accuracy? How its increment and decrement affect model accuracy?</p></li>
  <li><p>Is my above-defined epoch, batch, n_input is correct for the model?</p></li>
  <li><p>How can I increase my model accuracy? Is the above dataset size is good enough for this model?</p></li>
  </ol>
  
  <p>I am not able to link all this parameter and kindly help me in understanding how to achieve more accuracy by the above factor.</p>