Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. def best_param(model, data, pdq, pdqs):
  2. """
  3. Loops through each possible combo for pdq and pdqs
  4. Runs the model for each combo
  5. Retrieves the model with lowest AIC score
  6. """
  7. ans = []
  8. for comb in tqdm(pdq):
  9. for combs in tqdm(pdqs):
  10. try:
  11. mod = model(data,
  12. order=comb,
  13. seasonal_order=combs,
  14. enforce_stationarity=False,
  15. enforce_invertibility=False,
  16. freq='D')
  17.  
  18. output = mod.fit()
  19. ans.append([comb, combs, output.aic])
  20. except:
  21. continue
  22.  
  23. ans_df = pd.DataFrame(ans, columns=['pdq', 'pdqs', 'aic'])
  24. return ans_df.loc[ans_df.aic.idxmin()]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement