Skip to content

Commit

Permalink
update warning handling for build_model
Browse files Browse the repository at this point in the history
  • Loading branch information
annacprice committed Dec 13, 2021
1 parent d075cc7 commit 560ccec
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions covate/build_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import matplotlib.pyplot as plt
from .utils import appendline, pairwise, getenddate
import warnings
warnings.simplefilter("ignore", UserWarning)
warnings.simplefilter("ignore", RuntimeWarning)


def buildmodel(timeseries, lineagelist, regionlist, enddate, output, maxlag,
Expand Down Expand Up @@ -60,22 +62,16 @@ def buildmodel(timeseries, lineagelist, regionlist, enddate, output, maxlag,
# get basic information on timeseries
checkdistribution(X_train, lineage, filename, errorlog)

# plot the autocorrelation, ignore warnings
with warnings.catch_warnings():

warnings.simplefilter("ignore", UserWarning)

warnings.simplefilter("ignore", RuntimeWarning)

if validate:
# plot the autocorrelation
if validate:

plotautocorr(X_train, lineage, maxlag, output, enddate,
'additional-plots/validation')
plotautocorr(X_train, lineage, maxlag, output, enddate,
'additional-plots/validation')

else:
else:

plotautocorr(X_train, lineage, maxlag, output, enddate,
'additional-plots/prediction')
plotautocorr(X_train, lineage, maxlag, output, enddate,
'additional-plots/prediction')

# check for granger causality
try:
Expand Down Expand Up @@ -168,15 +164,16 @@ def buildmodel(timeseries, lineagelist, regionlist, enddate, output, maxlag,

if not validate:

vecerrcorr(X_train, lineage, VECMdeterm, lag, coint_count,
regionlist, nsteps, alpha, filename, output,
errorlog, enddate)
vecerrcorr(X_train, lineage, VECMdeterm, lag,
coint_count, regionlist, nsteps, alpha,
filename, output, errorlog, enddate)

else:

vecerrcorrvalid(X_train, X_test, lineage, VECMdeterm, lag,
coint_count, regionlist, nsteps, alpha,
filename, output, errorlog, enddate)
vecerrcorrvalid(X_train, X_test, lineage, VECMdeterm,
lag, coint_count, regionlist, nsteps,
alpha, filename, output, errorlog,
enddate)

# else check for stationarity and difference then run VAR
else:
Expand All @@ -186,8 +183,9 @@ def buildmodel(timeseries, lineagelist, regionlist, enddate, output, maxlag,

if not validate:

vecautoreg(X_train, lineage, maxlag, regionlist, nsteps,
alpha, filename, output, errorlog, enddate)
vecautoreg(X_train, lineage, maxlag, regionlist,
nsteps, alpha, filename, output, errorlog,
enddate)

else:

Expand Down

0 comments on commit 560ccec

Please sign in to comment.