I have used different machine learning algorithms to predict solar panels' power output. There are ten independent features for weather data. In all models, I set time as an index and have used the following rule for splitting the data :
X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.18, random_state=42)
With the mentioned splitting rule, all models perform well on the testing set, but I get the worst accuracy when not using a random rule for the testing set.
Does it make sense to use a random rule for splitting the dataset into training and testing sets? Or do I have to use only the latest data (20%) for the test split?