Hi Elemeo!



 elemeo:

I figured that it would be almost impossible to get exact numbers with 2 decimals so accuracy will always be 0%.


Just to be clear, in your above code you’re not checking whether the
floating-point numbers agree to 2 decimal digits of accuracy, but rather
whether they agree exactly, which is to say to about 7 decimal digits of
accuracy.


Do you have any suggestions as to what I would use to measure accuracy ?


A very reasonable measure of accuracy could be the mean-squared-error
between your predictions and your targets.  (This could also be a good
choice for the loss function you use for training.)
If your data are market prices given in, say, dollars, the units of the
mean-squared-error will be dollars-squared.  So it might be more intuitive
to repackage the same information as the root-mean-squared-error.
Thus, using the variables from the code you posted:
(pred - y).mean().sqrt()

This will have units of dollars, which might be a little easier to think about.
Note, however, that your time series starts of very small and grows over
time.  This means that errors in your predictions will likely be much smaller
and count much less early on rather than later.  For this reason you may
prefer to use fractional errors, e.g., something like (pred - y) / y.
If it’s important that your use case involve predicting tradable market
prices, then bear in mind that is it is relatively easy, but uninteresting,
to predict the price itself – just use yesterday’s price as your prediction.
Much more interesting – and also much harder – is to predict the
change in price.
I would suggest that you try to predict fractional price changes (“returns”),
or, perhaps more elegantly, logarithmic returns:
r_t  =  log (p_t / p_(t - 1))

where p_t is the price at time t, and so on.
The mean-squared-error, ((r_pred - r_targ)**2).mean() would be
both a sensible loss function for training and accuracy metric for
evaluation.
If you want to get fancy, you could even use the results of a (differentiable)
profit-and-loss trading “simulation” as your training loss and/or evaluation
metric.  That is, you take a “position” based on how large your predicted
return is.  If your prediction is in the right direction, you make a “profit”
on that position, and if it’s wrong, you take a “loss.”
Best.
K. Frank