"ValueWarning: No supported index is available. Prediction results will be given with an integer index beginning at `start`. return get_prediction_index("
Describe the bug
I updated from 2.0.2 to 2.0.3, and now I am unable to call the predict() method on my SARIMAX model without getting the following warning:
C:\Users\Owner\anaconda3\envs\x0\lib\site-packages\statsmodels\tsa\base\tsa_model.py:834: ValueWarning: No supported index is available. Prediction results will be given with an integer index beginning atstart. return get_prediction_index(
I found this bug report from statsmodels discussing this issue: https://github.com/statsmodels/statsmodels/issues/8487
The developer there says the following:
"This is because you could have any kind of integer index; while the one you gave [3, 4, 5, 6, 7, 8] works with the logic you proposed, we could also have been given e.g. [2, -5, 18, 100, 22, 17], in which case it is not obvious what the "next" integer should be.
We do fully support / recommend RangeIndex since then it is always clear what the "next" value should be."
With this in mind, I changed the index of the DataFrame passed to predict() to a RangeIndex starting at 0 to conform to their standard, yet I am still thrown the same warning.
To Reproduce
- Train a SARIMAX model.
- Generate a pandas DataFrame comprised of 81 rows and 1 column comprised of floats called "sample_df"
- Call the predict method as shown below.
mod.predict(sample_df.shape[0], sample_df)
Versions
System:
python: 3.10.11 | packaged by Anaconda, Inc. | (main, Apr 20 2023, 18:56:50) [MSC v.1916 64 bit (AMD64)]
executable: C:\Users\Owner\anaconda3\envs\x0\python.exe
machine: Windows-10-10.0.18363-SP0
Python dependencies:
pip: 23.0.1
setuptools: 66.0.0
sklearn: 1.2.2
statsmodels: 0.13.5
numpy: 1.24.3
scipy: 1.10.0
Cython: 0.29.32
pandas: 1.5.3
joblib: 1.1.1
pmdarima: 2.0.3
C:\Users\Owner\anaconda3\envs\x0\lib\site-packages\_distutils_hack\__init__.py:33: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
Expected Behavior
I expected the the predict() method to run without a problem as it had always done, returning me the model's predicted values.
Actual Behavior
The predict() method throws the aforementioned warning every time it calculates. In the context of a simulation with thousands of runs, it slows everything down prohibitively.
Additional Context
The abrupt nature in which the warning ends " return get_prediction_index(" seems like it may be instructive.