2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
The Sigmoid function is an important activation function for building a logistic regression model, as shown in the figure below.
Logistic regression is used to solveBinary classification problemThe output of the model is limited to a certain number of classification problems (infinite for regression problems).A binary classification problem means that the model has only two output results.
In the classic example of regression problem "tumor prediction case", the tumor size feature is used to predict whether the tumor is malignant. There are only two output results: yes (1) or no (0).
At this time, it is difficult to fit the training set using a linear regression model(Linear regression solves a regression problem, while the tumor prediction case is a classification problem, or more precisely, a binary classification problem), so the idea of logistic regression was proposed.
Logistic regression model (solving classification problems): input feature or feature set X and output a number between 0 and 1, where the fitting curve is constructed by the Sogmoid function. The specific construction process is as follows:
It is not difficult to see from the above that when the input z of the Sigmoid function is greater than or equal to 0, that is, the mapping z=wx+b of the feature set X to z is greater than or equal to 0, the output result of the model is 1; when the input z of the Sigmoid function is less than 0, that is, the mapping z=wx+b of the feature set X to z is less than 0, the output result of the model is 0.
This is how we can come up with the concept of a decision boundary:The equation that makes the mapping from the model input X to the Sigmoid function input z equal to 0 is called the decision boundary.
Taking the above tumor prediction model as an example, the mapping from model input X to Sigmoid function input z is z=wx+b, so the decision boundary is wx+b=0.
Let's use a graphic to illustrate the meaning of the decision boundary:
example 1:Mapping to a linear function
The figure above shows the true value of the label when the features x1 and x2 in the training set take different values. The circle represents that the classification result of the sample is 0, and the cross represents that the classification result of the sample is 1.
The logistic regression model is shown in the figure above, where the mapping from the model input X to the Sigmoid function input z is z=w1x1+w2x2+b, and the decision boundary is w1x1+w2x2+b=0. If the model training result is w1=1, w2=1, b=-3, the decision boundary is x1+x2-3=0, and the function graph of the decision boundary is shown in the figure above.It can be seen that if the feature of the sample is on the left side of the decision boundary, the logistic regression prediction is 0, otherwise it is 1. This is the graphic meaning of the decision boundary.
Example 2:Mapping to polynomial function
The mapping from the model input X to the Sigmoid function input z is a polynomial function. The decision boundary is shown in the figure. It can be seen that after the model training is completed, the parameter values are determined and the decision boundary is immediately determined.The position of the features of a sample relative to the decision boundary determines the prediction result of the sample.
In fact, it is the same as the linear regression training process, except that the model (function) to be trained is different.