Я работаю над прогнозной моделью временного ряда с pmdarima
.
Мой временной ряд короток, но ведет себя не так плохо. Следующий код выдает ошибку на sklearn \ utils \ validation.py
from pmdarima import auto_arima
from statsmodels.tsa.seasonal import seasonal_decompose
from statsmodels.tsa.stattools import adfuller
import datetime
import pandas as pd
datelist = pd.date_range('2018-01-01', periods=24, freq='MS')
sales = [26.000000,27.100000,26.000000,28.014286,28.057143,
30.128571,39.800000,33.000000,37.971429,45.914286,
37.942857,33.885714,36.285714,34.971429,40.042857,
27.157143,30.685714,35.585714,43.400000,51.357143,
45.628571,49.942857,42.028571,52.714286]
df = pd.DataFrame(data=sales,index=datelist,columns=['sales'])
observations = df['sales']
size = df['sales'].size
shape = df['sales'].shape
maxdate = max(df.index).strftime("%Y-%m-%d")
mindate = min(df.index).strftime("%Y-%m-%d")
asc = seasonal_decompose(df, model='add')
if asc.seasonal[asc.seasonal.notnull()].size == df['sales'].size:
seasonality = True
else:
seasonality = False
# Check Stationarity
aftest = adfuller(df['sales'])
if aftest[1] <= 0.05:
stationarity = True
else:
stationarity = False
results = auto_arima(observations,
seasonal=seasonality,
stationary=stationarity,
m=12,
error_action="ignore")
~\AppData\Roaming\Python\Python37\site-packages\sklearn\utils\validation.py in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator)
584 " minimum of %d is required%s."
585 % (n_samples, array.shape, ensure_min_samples,
--> 586 context))
587
588 if ensure_min_features > 0 and array.ndim == 2:
ValueError: Found array with 0 sample(s) (shape=(0,)) while a minimum of 1 is required.
Однако, если я изменю первое значение серии продаж с 26 на 30, это сработает.
Что здесь может быть не так?