我尝试了 bayes_opt 来进行lightgbm和xgboost超参数优化,以进行贝叶斯优化方法。
现在,我正在尝试用于SARIMAX超参数优化的相同方法:(p,d,q)x(P,D,Q,12)。
对于lightgbm和xgboost,此过程太快了。但是,对于SARIMAX,它花费的时间太长。我已经等待了大约45分钟。我找不到任何东西。
这些是我的代码:
def sarimax_bayesian(p, d, q, P, D, Q):
# params
p = int(p)
d = int(q)
q = int(q)
# seasonal params
P = int(P)
D = int(Q)
Q = int(Q)
# assert param types as integer
assert type(p) == int
assert type(d) == int
assert type(q) == int
assert type(P) == int
assert type(D) == int
assert type(Q) == int
params = (p, d, q)
seasonal_params = (P,D,Q,12)
# model
model = sm.tsa.statespace.SARIMAX(y,
order=params,
seasonal_order=seasonal_params,
enforce_stationarity=False,
enforce_invertibility=False)
# results
results = model.fit()
# get aic score
aic = results.aic
return np.negative(aic)
bounds_sarimax = {
'p': (0, 12),
'd': (0, 12),
'q': (0, 12),
'P': (0, 12),
'D': (0, 12),
'Q': (0, 12)}
sarimax_bo = BayesianOptimization(sarimax_bayesian, bounds_sarimax, random_state=42)
print(sarimax_bo.space.keys)
init_points = 0
n_iter = 1
print('-' * 130)
with warnings.catch_warnings():
warnings.filterwarnings('ignore')
sarimax_bo.maximize(init_points=init_points, n_iter=n_iter, acq='ucb', xi=0.0, alpha=1e-6)
如何解决此问题?我可以更改代码中的内容吗?