Random forest regressor accuracy reduces when the input data is not shuffled I am using a random forest regressor and I split the independent variables with shuffle = True, I get a good r squared but when I don't shuffle the data the accuracy gets reduced significantly. I am splitting the data as below-
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25,random_state=rand, shuffle=True)
I fit the random forest regressor as below-
reg = RandomForestRegressor()
reg.fit(X_train, y_train)

When I do the cross-validation with unshuffled data, the accuracy is not good, but it improves when the data is shuffled.
This is how the response variable I am trying to predict looks like-

What could be the reason behind that?

When the data aren't shuffled, the data are split into two parts along the first axis. Observing a large difference in performance between the shuffled and non-shuffled data indicates that something about how the data X, y are sorted is meaningful in some way.
As an example, imagine that your data are sorted by one of the features, and this feature is important for prediction. Without information about that feature in the 25% of the data you've reserved for testing (test_size=0.25), the model can't predict well for those values of the feature.

In a comment, OP has clarified that the data are a time series (yearly data). So what's probably happened is that shuffling the data is letting the model use information from the future to predict the past, essentially giving the model precognition. To avoid optimistic bias, you should split the data so that you're always training the model on data from the past and evaluating it on data from the future.

*

*Cross-validation for timeseries data with regression

*Splitting Time Series Data into Train/Test/Validation Sets
