We have almost all the elements to turn a simple linear regression into a simple logistic regression. Let's begin with the case of only two classes or instances, for example ham/spam, safe/unsafe, cloudy/sunny, healthy/ill, or hotdog/not hotdog. First, we codify these classes by saying that the predicted variable, , can only take two values, 0 or 1, that is,
. Stated this way, the problem sounds similar to the coin-flipping example from Chapter 2, Programming Probabilistically and Chapter 3, Modeling with Linear Regression.
We may remember we used the Bernoulli distribution as the likelihood. The difference with the coin-flipping problem is that now is not going to be generated from a beta distribution; instead,
is going to be defined by a linear model with the logistic as the inverse link function. Omitting the priors we have:
![](http://images-20200215.ebookreading.net/8/4/4/9781789341652/9781789341652__bayesian-analysis-with__9781789341652__assets__c1df63ce-f9be-4e96-a2db-fd711502dade.png)