Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sim, pdr bot] Calibrate model probabilities with CalibratedClassifierCV #704

Closed
2 tasks done
trentmc opened this issue Mar 1, 2024 · 0 comments · Fixed by #721
Closed
2 tasks done

[Sim, pdr bot] Calibrate model probabilities with CalibratedClassifierCV #704

trentmc opened this issue Mar 1, 2024 · 0 comments · Fixed by #721
Labels
Type: Enhancement New feature or request

Comments

@trentmc
Copy link
Member

trentmc commented Mar 1, 2024

Background / motivation

We now use classifiers' probabilities to decide on stake up/down, great.

But the probabilities themselves are overly optimistic: they often give 90%+ probability, yet their accuracy is typically 50.5-53%.

There's a solution: calibrate the probabilities based on previous errors.

We can do this with scikit-learn CalibratedClassifierCV, or with more pure conformal prediction. The former is one line of Py code that we have experience with; the former is what we're heading towards (but won't do in this issue).

TODO

  • In sim, calibrate models with CalibratedClassifierCV
  • In predictoor bot, ""

Appendix: Motivation

Berkay: "Is it normal for the model to predict >90% up or down? I anticipated the probabilities to be around 50-60%. The first prediction in the list is 98% up."

Trent: "Re 90% up or down : yes that is normal. It's overly confident. (A near term trick is to calibrate its optimism with conformal prediction.)"

Appendix: Jaime on (a) CalibratedClassifierCV vs (b) conformal prediction

(b) makes fewer assumptions but is slightly more involved (but not that much).

Jaime had done experiments comparing (a)(b). Results were similar. (a) is simpler to implement, literally a one-liner. Which is why we do it first

Appendix: Jaime experiments

These results are form a model that classify up/down on BTC/USDT since 2019. The plot shows changes in precision and accuracy as the minimum confidence increases. The green line shows the percentage of the total number of samples that result in an action, meaning that samples below the minimum confidence value are ignores and lead to no action.

The probabilities are calibrated using an isotonic curve via CalibratedClassifierCV functionality of sci-kit learn library. Interestingly the probabilities are low, around the chance level value, evidenced by the sharp decrease in the samples that result in actions (up/down) which is in line with the low accuracy observed.

For the sake os contrast, these are the results when the task is not to find if the close value is higher or lower than zero, but instead asking whether a values higher than 2times the trading fees will be seen in the next 60 mins:

@trentmc trentmc added the Type: Enhancement New feature or request label Mar 1, 2024
@trentmc trentmc changed the title [Sim, pdr bot] Calibrate model probabilities via CalibratedClassifierCV. Towards conformal prediction [Sim, pdr bot] Calibrate model probabilities Mar 1, 2024
@trentmc trentmc changed the title [Sim, pdr bot] Calibrate model probabilities [Sim, pdr bot] Calibrate model probabilities with CalibratedClassifierCV Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant