timemachines
timemachines copied to clipboard
Uncaught Exception: OverflowError: math range error
xi, x_std, self.s = self.skater(y=round(yi, 6), s=self.s, k=1)
File "/usr/local/lib/python3.9/site-packages/timemachines/skaters/smdk/smdkarma.py", line 21, in smdk_p5_d0_q3_n500_aggressive
return smdk_arma_factory(y=y, n_agents=500, max_p=5, max_q=3, s=s, k=k, a=a, t=t, e=e, r=0.95)
File "/usr/local/lib/python3.9/site-packages/timemachines/skaters/smdk/smdkarmafactory.py", line 119, in smdk_arma_factory
x, x_std, s['s_pks'] = precision_weighted_skater(y=y_for_pws, s=s['s_pws'], k=k, a=a, t=t, e=e, r=r)
File "/usr/local/lib/python3.9/site-packages/timemachines/skatertools/ensembling/precisionweightedskater.py", line 30, in precision_weighted_skater
w = normalize( [ 1./math.pow(y_std,expon) for y_std in y_stds ] )
File "/usr/local/lib/python3.9/site-packages/timemachines/skatertools/ensembling/precisionweightedskater.py", line 30, in <listcomp>
w = normalize( [ 1./math.pow(y_std,expon) for y_std in y_stds ] )
=========================================================================
Uncaught Exception: OverflowError: math range error
Any idea why this happens and how to avoid that?
My code:
self.skater = local_skater_from_name('smdk_p5_d0_q3_n500_aggressive')
self.s = {}
self.x = []
This is inside a loop:
if self.index == 0:
returns = utils.prices_to_returns(self.candles[:, 2])[1:]
# warmup
for yi in returns:
xi, x_std, self.s = self.skater(y=round(yi, 6), s=self.s, k=1, e=-1)
self.x.append(xi)
else:
yi = utils.prices_to_returns(self.candles[-5:, 2])[-1]
# predict
xi, x_std, self.s = self.skater(y=round(yi, 6), s=self.s, k=1)
self.x.append(xi)
self.x = self.x[-240:]
Thank you.
Could it be the s
argument getting to big? Is there a way to limit/slice the memory of it?
The s
argument was the reason. If I reset it after a certain amount of iterations, this error doesn't happen. Would be great to not have to clear all the history, but being able to keep a certain amount. If I understood it right, the s
dict is different for each skater, so not an easy task I think. Still an incredible repository you made. I think adding a warning to the docs, that s
might have to be reset in certain cases might be enough.
Hmm.. sorry just seeing this issue now. So you think the s is growing too large?
And yes you are right the responsibility/interpretation of s is known to the skater, not the caller.
The memory should plateau though.
It might be something else. Can you try the same thing but without _aggressive? I just want to test a theory.
I should put bounds on the variances anyway. There's no good reason to risk the error you are seeing.
btw I have better reflexes in the slack
xi, x_std, self.s = self.skater(y=yi, s=self.s, k=3)
File "/usr/local/lib/python3.9/site-packages/timemachines/skaters/smdk/smdkarma.py", line 17, in smdk_p5_d0_q3_n500
return smdk_arma_factory(y=y, n_agents=500, max_p=5, max_q=3, s=s, k=k, a=a, t=t, e=e, r=0.75)
File "/usr/local/lib/python3.9/site-packages/timemachines/skaters/smdk/smdkarmafactory.py", line 119, in smdk_arma_factory
x, x_std, s['s_pks'] = precision_weighted_skater(y=y_for_pws, s=s['s_pws'], k=k, a=a, t=t, e=e, r=r)
File "/usr/local/lib/python3.9/site-packages/timemachines/skatertools/ensembling/precisionweightedskater.py", line 30, in precision_weighted_skater
w = normalize( [ 1./math.pow(y_std,expon) for y_std in y_stds ] )
File "/usr/local/lib/python3.9/site-packages/timemachines/skatertools/ensembling/precisionweightedskater.py", line 30, in <listcomp>
w = normalize( [ 1./math.pow(y_std,expon) for y_std in y_stds ] )
=========================================================================
Uncaught Exception: OverflowError: math range error
Same for smdk_p5_d0_q3_n500
Strange, as tests are passing. I made some minor changes can you try:
pip install --upgrade git+https://github.com/microprediction/timemachines.git
?
Okay to close this?