Could you please tell me how can we randomly split time series data. I have a time series data from July 2007 to July 2010(37 month). Currently I’m taking the first 30 months to train the model and rest 7 for test. The problem is there has been sudden increase in the months of test data set for few months which the model is not able to predict which leads to poor MAPE, as it was not observed with the data the model was trained with.
How can I randomly split time series and then test the model? Please mention code as I’m not aware of this.