This article has participated in the activity of "New person creation Ceremony", and started the road of digging gold creation together

Before we get to the Logistic Regression problem, let’s discuss some real-world situations: determining whether an E-mail message is spam? Is a transaction fraudulent? Is a document valid? This kind of Problem is called Classication Problem **. In classification problems, we often try to predict whether the result belongs to a certain class (true or false).

We start with the binary problem of categorization, whether the problem is true or false.

The two classes that ** Dependent Variable may belong to are respectively called Negative Class and Positive Class **, so the Dependent Variable:

0 indicates the negative class and 1 indicates the positive class

We assume that Malignant or Benign tumors can be predicted. We assume that the relationship between Malignant or Benign tumors and tumor size can be determined by linear regression. A straight line suitable for data can be obtained:

According to the linear regression model, we can only predict the continuous values, and then for the classification problem, we only need to output 0 or 1. We can predict:

For the data shown above, such a linear model seems to do a good job of classifying. Let’s say we observe another malignancy of very large size, add it to our training set as a new example, and that will have some effect on our linear model, and we’ll get a new line.

At this point, using 0.5 as a threshold to predict whether a tumor is benign or malignant is not so appropriate. It can be seen that the linear regression model is not suitable for solving such problems because its predicted value can exceed the range of [0,1].

We introduce a new model, logistic regression, whose output variable range is moderate between 0 and 1.

The logistic regression model assumes that:

Among them, explain some flags:

The graph of this function is:

By combining the logical function and the hypothesis function, the hypothesis of the logistic regression model can be obtained:

The model can be understood as follows:

The function of hø(x) is to calculate the Estimated Probablity ** of the output variable =1 with a given input variable according to the selected parameters, namely:

For example, if hø(x)=0.7 is calculated from the identified parameters for a given x, then there is a 70% probability that y is a positive class and a corresponding 30% probability that y is a negative class (1-0.7=0.3).

Above, the logistic regression model. Next time we will discuss Decision boundaries and Cost functions.