Working code so far, need to fix issue with value prediction for rare event, since the length of the error changes