When using LSTM (Long Short-Term Memory) or GRU (Gated Recurrent Unit) for time series prediction tasks such as stock price forecasting, it’s generally not recommended to shuffle the training data.
The reason is that these models are designed to learn from sequences of data and make predictions based on the temporal order of events. Shuffling the data would disrupt the temporal order and the models might not be able to learn the sequential patterns effectively.
In time series problems, the order of the data points is important because the prediction for a certain time point is often dependent on the previous time points. For example, the stock price tomorrow is likely to be influenced by the stock prices today and in the recent past.
Therefore, when preparing your data for training, you would typically sort your data by date and then split it into training and validation sets in a way that maintains the temporal order. For example, you might use the first 80% of your data for training and the remaining 20% for validation.