22.02.2024 Views

Daniel Voigt Godoy - Deep Learning with PyTorch Step-by-Step A Beginner’s Guide-leanpub

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The odds ratio is given by the ratio between the probability of success (p) and the

probability of failure (q):

Equation 3.5 - Odds ratio

In code, our odds_ratio() function looks like this:

def odds_ratio(prob):

return prob / (1 - prob)

p = .75

q = 1 - p

odds_ratio(p), odds_ratio(q)

Output

(3.0, 0.3333333333333333)

We can also plot the resulting odds ratios for probabilities ranging from 1% to

99%. The red dots correspond to the probabilities of 25% (q), 50%, and 75% (p).

Figure 3.2 - Odds ratio

Clearly, the odds ratios (left plot) are not symmetrical. But, in a log scale (right

Model | 213

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!