将函数auto_arima()
中参数start_p
的值作为4
传递,则参数查找应从4即
开始。(4,x,x)(x,x,x)但它从(0,x,x)(x,x,x)开始(x,x,x,x)完全避免了参数4
。
import pandas as pd
from pmdarima import auto_arima
train_df = pd.read_csv('https://raw.githubusercontent.com/vyaduvanshi/helper-files/master/train_SO.csv')
auto_arima(train_df.new_cases, start_p=4, d=0, start_q=0, max_p=5, max_d=0, max_q=5,
start_P=0, D=0, start_Q=0, max_P=5, max_D=0, max_Q=5, seasonal=True, m=7, maxiter=200, trace=True,
information_criterion='aic', with_intercept=False, stepwise=False, max_order=None)
下面是我运行代码后的样子-
ARIMA(0,0,0)(0,0,0)[7] : AIC=13942.223, Time=0.01 sec
ARIMA(0,0,0)(0,0,1)[7] : AIC=13625.127, Time=0.06 sec
ARIMA(0,0,0)(0,0,2)[7] : AIC=13572.472, Time=0.11 sec
ARIMA(0,0,0)(0,0,3)[7] : AIC=13573.420, Time=0.22 sec
ARIMA(0,0,0)(0,0,4)[7] : AIC=13591.829, Time=0.40 sec
ARIMA(0,0,0)(0,0,5)[7] : AIC=13612.307, Time=1.04 sec
ARIMA(0,0,0)(1,0,0)[7] : AIC=inf, Time=0.08 sec
...
...
...
我找到了如何处理它,但要注意,这不是制作原始API的人的官方解决方案,我制作它是为了使我的工作更容易。另外,我不确定它是否会损害整体逐步搜索或其他任何东西,尽管如此,如果你不使用逐步搜索,现在它似乎确实有效:通过点击auto_arima进入auto.py文件,向下滚动到"search = solvers. _randomfitwrapper",您将需要为该函数添加以下参数:start_p=start_p,start_q=start_q, start_p=start_p,start_q=start_q,
保存它,现在进入_auto_solvers.py并搜索函数"类_RandomFitWrapper(_SolverMixin):">
将此函数替换为:
class _RandomFitWrapper(_SolverMixin):
"""Searches for the best model using a random search"""
def __init__(self, y, X, fit_partial, d, D, m, max_order,
start_p, max_p, start_q, max_q, start_P, max_P, start_Q, max_Q, # added start_p, start_q, start_P, start_Q
random, random_state,
n_fits, n_jobs, seasonal, trace, with_intercept,
sarimax_kwargs):
if seasonal:
gen = (
((p, d, q), (P, D, Q, m))
for p in range(start_p, max_p + 1) # changed from 0 to start_p
for q in range(start_q, max_q + 1) # changed from 0 to start_q
for P in range(start_P, max_P + 1) # changed from 0 to start_P
for Q in range(start_Q, max_Q + 1) # changed from 0 to start_Q
#if p + q + P + Q <= max_order
)
else:
gen = (
((p, d, q), (0, 0, 0, 0))
for p in range(start_p, max_p + 1) # changed from 0 to start_p
for q in range(start_q, max_q + 1) # changed from 0 to start_q
#if p + q <= max_order
)
if random:
random_state = check_random_state(random_state)
gen = random_state.permutation(np.array(list(gen), dtype='object'))[:n_fits]
self.gen = gen
self.n_jobs = n_jobs
self.trace = trace
self.fit_partial = functools.partial(
fit_partial,
y=y,
X=X,
with_intercept=with_intercept,
**sarimax_kwargs,
)
嘘,保存并重新启动你的内核,现在自动引擎将尊重启动参数。我也刚刚尝试了Stepwise,并确认这个业余的修复在使用Stepwise时不起作用。