> For the complete documentation index, see [llms.txt](https://julienbeaulieu.gitbook.io/wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://julienbeaulieu.gitbook.io/wiki/sciences/math/statistics/logistic-regression.md).

# Logistic Regression

![](/files/-LgmjuhnY-BZeHY0oOIT)

This is the probability of an event occuring divided by the probability of the event not occuring.&#x20;

&#x20;

![](/files/-LgmkRhGrC9a9adIE0Ke)

It's called the log ratio. And by taking the log, we control our probs to be between 0 and 1.&#x20;

With algebra the equation now looks like this:&#x20;

![](/files/-LgmkdnR4GmrecC6E8oo)

This solves the probability directly.&#x20;

![](/files/-Lgmkthy3Bzarb0A1NH6)

### Interpretation

We need to exponentiate each of the coefficients. Then, with quantitative variables we would say, for a 1 unit increase in your explanatory variable x1, we expect a multiplicative change in the odds of being in the 1 category of e^b1 holding all other variables constant.&#x20;

For categorial interpretations: when in category x1, we expect a multiplicative change in the odds of a 1 by e^b1 compared to the basedline. &#x20;

So if we have:

![](/files/-Lgn2Ahjwf05cU-23nvF)

For the weekday dummy variables we would say: on weekdays, fraud is 12.76 times as likely as on weekends holding all else constant.&#x20;

For duration: for each 1 unit increase in duration, fraud is 0.23 times as likely holding all else constant.&#x20;

With returned values less than 1, it is often beneficial to obtain the reciprocal. This changes the direction of the unit decrease to increase.&#x20;

Therefore: for each 1 unit decrease in duration, fraud is 4.32 times as likely holding all else constant.&#x20;

![](/files/-Lgn96kFZk8qCIa5wFc2)

### Accuracy

When determining how well your logistic regression model is doing at predicting the correct labels - accuray. &#x20;

![](/files/-LgnA1X29fMm1KA9SB98)

There are some cases where accuracy won't work well particularly when you have large class imbalances in your data set.&#x20;

![](/files/-LgnAB4v1hqph1D26nsW)

So we'll go over some of the other metrics to determine whether your model is performing well or not.&#x20;

### Interpreting interaction with logistic regression

<http://www.cantab.net/users/filimon/cursoFCDEF/will/logistic_interact.pdf>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://julienbeaulieu.gitbook.io/wiki/sciences/math/statistics/logistic-regression.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
