Simple and crude understand and implement logic machine learning regression: logistic regression presentation, application scenarios, principles, losses and optimization ...

Author | Wang Wenqi

Zebian | Carol

Source | CSDN blog

Produced | AI technology base camp (ID: rgznai100)

learning target

  • We know the logistic regression function loss

  • Optimization of logistic regression to know

  • We know sigmoid function

  • You know the scenario logistic regression

  • Application LogisticRegression realize logistic regression forecast

  • We know the difference between precision, recall indicators

  • We know how to solve assess imbalances in the sample

  • ROC curve to understand the meaning of instructions AUC index size

  • Classification_report precise application, recall calculated

  • Indicators for computing applications roc_auc_score

Logistic regression Introduction

Logistic Regression (Logistic Regression) is a machine learning classification model, logistic regression is a classification algorithm, although the name with the return, but there is some connection between it and return. Due to the simple and efficient algorithm is widely used in practice.

Logistic regression application scenarios:

  • CTR

  • It is spam

  • Whether sick

  • Financial Fraud

  • False account

See the example above, we can see the characteristics of them, that is all part of the judgment between the two categories. Logistic regression weapon is to solve binary classification problem.


Logistic regression principle

To master the logistic regression, we must grasp two things:

  • Logistic regression, what is the input value

  • How to determine the output logic regression

1, input

Input logic is the result of a regression linear regression.

2, activation function

  • sigmoid function

  • Criteria

  • The regression results are input to the sigmoid function among

  • Output Results: [0, 1] value of a probability interval, the default threshold value is 0.5

The final classification by logistic regression determines a probability value is belonging to a category belong to a category, and the category default flag is 1 (positive patients), another category are labeled 0 (counterexample). (Loss calculation convenience)

Interpretation of results output (important): Suppose there are two categories of A, B, and we assumed probability value belonging to A (1) the probability value of this category. Now there is a sample of the input to the output of the logistic regression 0.6, then the probability value exceeds 0.5, means that we train or predict the result is A (1) category. Conversely then, then 0.3, or training if the outcome is predicted to result of B (0) category.

So linear regression to predict the results before then we remember we use to measure the mean square error, that if for logistic regression, we predict that the results do not how to measure the losses? We look at such a picture.

So predictions of how to measure the results of logistic regression of the real difference?

Losses and optimization

1 loss

Loss of logistic regression, called log likelihood loss , the following formula:

  • Separate categories:

How to understand a single equation it? This should be understood in terms of image log function

  • Integrated complete loss of function

See this formula, in fact, similar to tell us information entropy.

Then we bring the example above is calculated again, will be able to understand the meaning.

We already know, log§, the larger the P value, the smaller the result, so we can look at this formula to analyze loss

2, optimization

Also using a gradient descent optimization algorithm to reduce the value of the loss function. Such logic to update the previous corresponding weight regression algorithm parameters of weight, enhance the probability that originally belonged to a category, reducing the probability of 0 was originally categories.

【end】

Force plans

"Force plan [the second quarter] - learning ability Challenge" started! From now until March 21, must flow to support the original author! Exclusive [more] medal waiting for you to challenge

Recommended Reading

    Your point of each "look", I seriously as the AI

Released 1350 original articles · won praise 10000 + · views 6.19 million +

Guess you like

Origin blog.csdn.net/dQCFKyQDXYm3F8rB0/article/details/104787347