Skip to content

Instantly share code, notes, and snippets.

@lmassaron
Created December 1, 2018 23:52
Show Gist options
  • Select an option

  • Save lmassaron/de243e5f852140391f378b66b153e7ff to your computer and use it in GitHub Desktop.

Select an option

Save lmassaron/de243e5f852140391f378b66b153e7ff to your computer and use it in GitHub Desktop.
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