Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def best_param(model, data, pdq, pdqs):
- """
- Loops through each possible combo for pdq and pdqs
- Runs the model for each combo
- Retrieves the model with lowest AIC score
- """
- ans = []
- for comb in tqdm(pdq):
- for combs in tqdm(pdqs):
- try:
- mod = model(data,
- order=comb,
- seasonal_order=combs,
- enforce_stationarity=False,
- enforce_invertibility=False,
- freq='D')
- output = mod.fit()
- ans.append([comb, combs, output.aic])
- except:
- continue
- ans_df = pd.DataFrame(ans, columns=['pdq', 'pdqs', 'aic'])
- return ans_df.loc[ans_df.aic.idxmin()]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement