# How to handle non consistent time series( using LSTM )

The time series dataset I am working on has missing samples. I am trying to use keras and LSTM for prediction. How should I handle the missing timestamp samples ( sometimes there are missing weeks even months)?

Does this affect the overall performance of the LSTM predictor?

If you have missing data you can add a Masking layer to your model which will prevent contributions from those time steps to be included. You can see the documentation for it here: https://keras.io/layers/core/#masking

Example taken from the keras documentation:

Consider a Numpy data array x of shape (samples, timesteps, features), to be fed to an LSTM layer. You want to mask timestep #3 and #5 because you lack data for these timesteps. You can:

set x[:, 3, :] = 0. and x[:, 5, :] = 0. insert a Masking layer with mask_value=0. before the LSTM layer:

With example code:

model = Sequential()