# Sarima : Fitting on train subset works but fitting on whole train does not [closed]

I use SARIMAX from statsmodels.tsa.statespace.sarimax in Python.
I have a simple one column energy consumption dataset with 27679 rows. The frequency is Hour.

I do hyperparameters optimization thanks to Gridsearch and Hyperopt.
To do so, I split NOT RANDOMLY (I used shuffle=False) the dataset into X_train and X_test datasets, and then I split X_train a second time into X_train_subset and X_valid set so I can do the optimization over the X_valid set, and I never use the X_test set except at the end.

from sklearn.model_selection import train_test_split

# We want to forecast on 72 hours, 3 days
test_size = 72/len(result_data)

X_train, X_test = train_test_split(result_data, test_size=test_size, shuffle=False)
X_train_subset, X_valid = train_test_split(X_train, test_size=0.3, shuffle=False)


The problem is that, sometimes, I got the best hyperparameters which results from the optimization (fitting on X_train_subset & calculating metrics over X_valid) and then, when I fit the model with these hyperparams on X_train, it won't fit, I got :

ValueError: Non-stationary starting autoregressive parameters found with enforce_stationarity set to True.


To resume, for one Sarima model with one combination of hyperparams:

• It fits on X_train_subset.
• It does not fit on X_train.
• X_train_subset is 70% of X_train.
• Both X_train and X_train_subset are stationnary (Dickey Fuller test < 10e-11)

Does someone knows why I got this behaviour and what it means about my model ?

## closed as off-topic by Michael Chernick, mkt, kjetil b halvorsen, mdewey, Siong Thye GohAug 13 at 8:28

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – Michael Chernick, mkt, kjetil b halvorsen, mdewey, Siong Thye Goh
If this question can be reworded to fit the rules in the help center, please edit the question.