# Logistic regression in machine learning: computational probability

Time：2021-10-22

Many problems require probabilistic estimates as outputs. Logistic regression is an extremely efficient probabilistic computer system. In fact, you can use the return probability in one of two ways:

• “As is”
• Convert to binary category.

Let’s learn how to use probability “as is”. Suppose we create a logistic regression model to predict the probability of dogs barking in the middle of the night. We call this probability:
``p ( bark | night )``

If the logistic regression model predicts that the value of P (bark | night) is 0.05, the dog owner should be awakened about 18 times in a year:

``````startled = p( bark | night ) *nights
18 ~= 0.05 * 365``````

In many cases, you will map the logistic regression output to the solution of the binary classification problem whose goal is to correctly predict one of the two possible tags (for example, “spam” or “non spam”).

You might want to know how the logistic regression problem model ensures that the output value always falls between 0 and 1. Coincidentally,S-type functionThe generated output value has these characteristics, which are defined as follows:

y = \dfrac{1}{1 + e^{-z}}

S-type functions produce the following graphs: #### Figure 1: S-type function

If Z represents the output of the linear layer of the model trained with logistic regression, the S-type (z) function generates a value (probability) between 0 and 1. Expressed mathematically as

y’ = \dfrac{1}{1 + e^{-(z)}}

Of which:

• Y ‘is the output of the logistic regression model for a specific sample.
• Z is

b + w_1x_1 + w_1x_2 + …w_Nx_N

• The value of W is the weight of model learning, and B is the deviation
• The value of X is the characteristic value of a specific sample

Note that z is also called logarithmic probability because the inverse function of the S-type function shows that z can be defined as the logarithm of the value obtained by dividing the probability of label “1” (e.g. “dog barking”) by the probability of label “0” (e.g. “dog not barking”):

z = log_{10}(\dfrac{y}{1-y})

The following are S-type functions with machine learning Tags: 