Created
December 1, 2018 23:52
-
-
Save lmassaron/de243e5f852140391f378b66b153e7ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def from_p_to_logit(prob): | |
| return prob / (1 - prob) | |
| def from_logit_to_p(logit): | |
| return logit / (1 + logit) | |
| def recalibrate_prob(prob, old_baseline, new_baseline): | |
| """ | |
| Recalibrates the probability | |
| from a logistic regression | |
| replacing the base probability | |
| """ | |
| new_logit = from_p_to_logit(prob) / from_p_to_logit(old_baseline) * from_p_to_logit(new_baseline) | |
| return from_logit_to_p(new_logit) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment