This note comes from CDA-DSC Course , By Mr. Chang Guozhen . The first phase of the camp is the theme of risk control , The training content is very compact , very nice , recommend ：CDA Data scientist training camp

**——————————————————————————————————**

# One 、logit Source of value

Logistic regression generally classifies dependent variables into two categories 0-1 Turn to frequency [0,1], become odds（ The odds ratio is ,[0,+∞]）, then log To become Logit value ([-∞,+∞])

The odds ratio is ：odds=P(y=1)/P（y=0）

logit value ：logit=log(odds)

What is? sigmoid function ？

First, I defined an intuitive concept ` The odds ratio is `

p/(1-p),p yes true The probability of time ,1-p yes false The probability of time , Take advantage of log, namely t=log(p/(1-p)) Do a range conversion , Go to all real fields . Then turn around and ask p, In the end sigmoid function .

sigmoid The interesting thing about functions is , The independent variable is from negative infinity to positive infinity , The dependent variable is 0 To 1. The closer the 0 The greater the change . The derivative is p(1-p), Derivatives are interesting .（ Reference resources ： Talk about logical regression ）

——————————————————————————————————

# Two 、logit modeling

utilize logit=Y Modeling , obtain Logit Then we can calculate the probability according to it .Logit= Economic utility , Utility is a continuous variable ,logit The model is equivalent to utility modeling .

So generally speaking , The coefficient of logistic regression is logit The coefficient of the value , It needs to be converted to a probability value .

The simple understanding can be regarded as ：

Input is x, The output is y, One of the temporary variables in the middle is t.w and b Is the model parameter .h(t) Is the probability of belonging to a certain category , Greater than 0.5 I think it belongs to this category , namely y=1.

For simplicity , We can argue that b Always with a value of 1 Of w Multiply . So we put b Put in w. The model is simplified as

This is the formula of logistic regression , It's simple .

（ Reference resources ： Talk about logical regression ）

——————————————————————————————————

# 3、 ... and 、logit Function modeling threshold setting

In the risk control model summary ,logistics The threshold is set according to the business owner . Generally, high credit passes automatically , The risks in the process need to be reviewed ; The riskier refuse to borrow .

——————————————————————————————————

# Four 、R Language implementation

## 1、 Logical regression

Logistic regression generally uses glm Function binomial(link='logit') Modeling .

lg<-glm(y ~x1,family=binomial(link='logit')) summary(lg)

There are only two uses for the regression coefficient ： The sign 、 Significance . The regression coefficient represents every increase in 1 A unit of x, Will increase logit Increase in value 0.1 A unit of , And it has a positive effect . If you need to know the probability value, you need to recalculate .

## 2、 Stepwise regression was used to screen variables ——step

On top of logical regression , We can use stepwise regression , Eliminating variables .

lg_ms<-step(lg,direction = "both") summary(lg_ms)

## 3、 Validation set prediction ——predict

train$lg_p<-predict(lg_ms, train) summary(train$lg_p)

predict The same is true of the forecast for logit value , It's not probability , It needs to be recalculated

## 4、 Calculate the probability value

1/(1+exp(-1*train$lg_p))

## 5、 Methods of model validation

As a sort class model , It can be used ROC curve /AUC value 、 Cumulative lift curve 、K-S curve 、 Lorentz curve gini To verify （ note ︱ Types of risk control classification models （ Decision making 、 Sort ） Comparison and model evaluation system （ROC/gini/KS/lift））.

## note +R︱Logistics Modeling brief （logit value 、sigmoid function ） More articles about

- note +R︱ Neural network activation function and perceptron in credit risk modeling
I always think that climbing mountains is small , can . Every time I come to the starting point , Daniel , Come slowly and share with me ,please~ --------------------------- This note comes from CDA-DSC Course , By Mr. Chang Guozhen ...

- 【 turn 】Pandas Learning notes （ Four ） Handling missing values
Pandas Learning notes series : Pandas Learning notes ( One ) Basic introduction Pandas Learning notes ( Two ) Select data Pandas Learning notes ( 3、 ... and ) modify & add value Pandas Learning notes ( Four ) Handling missing values Pandas learn ...

- 【 turn 】Pandas Learning notes （ 3、 ... and ） modify & add value
Pandas Learning notes series : Pandas Learning notes ( One ) Basic introduction Pandas Learning notes ( Two ) Select data Pandas Learning notes ( 3、 ... and ) modify & add value Pandas Learning notes ( Four ) Handling missing values Pandas learn ...

- R Special values in language NA NULL NaN Inf
These are R Special values in language , All are R Reserved words , NA:Not available Indicates the missing value use is.na() To determine whether it is a missing value NULL: Indicates null value , That is, there is no content use is.null() To judge ...

- c The pointer -- note 2 Function to return pointer value
Function to return pointer value Generally, functions that bring back pointer values , The definition is in the form of : int *a (int x, int y); Look at this classic case : #include <stdio.h> int main(int arg ...

- Softmax And Sigmoid The connection of functions
translation :http://willwolf.io/2017/04/19/deriving-the-softmax-from-first-principles/ The original goal of this article is to explore softmax Function and sig ...

- Logistic Return to (sigmoid function , Mobile phone evaluation , The gradient rises , Batch gradient , Random gradient , A hernia disease predicts the death rate of a sick horse
( The color of the cell phone , size , User experience is used to weight the total value ) Maximum likelihood estimation MLE 1.Logistic Return to Logistic regression ( Logical regression ), It's a sort of classification , Used in dichotomous problems ( There are only two kinds of outputs ). Such as ...

- Little pig C++ Basic notes （ 6、 ... and ） Parameter passing 、 function overloading 、 A function pointer 、 Debugging help
Little pig C++ Basic notes ( 6、 ... and ) ———— Parameter passing . function overloading . A function pointer . Debugging help key word : Parameter passing . function overloading . A function pointer . Debugging help Because of some things and my laziness , I haven't read any more for about a week , Not anymore , hurriedly ...

- Why does logistic regression use sigmoid function
Logistic The purpose of regression is to learn one from the features 0/1 Classification model , This model takes the linear combination of characteristics as independent variables , Because the value range of independent variable is from negative infinity to positive infinity . therefore , Use logistic function ( Or called sigmoid function ) Will self ...

## Random recommendation

- Hang Dian ACM1005
Number Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...

- java Multithreading -- Realization Runnable Interface
package unit8; import java.applet.Applet; import java.awt.Label; import java.awt.TextField; public c ...

- double Type into Integer type ---DecimalFormat
hypothesis x It's what you want to convert double Type variable : No rounding : (int)x Perform rounding operations : Integer.parseInt(new java.text.DecimalFormat(" ...

- 【HDU 1009】FatMouse' Trade
topic Description FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the ware ...

- Table of Contents - Servlet & JSP
Servlet Servlet API Overview Java Web Access to resources path problem getParameter And request.getAttribute The difference between The difference between forwarding and redirection chinese ...

- The state of computer vision and artificial intelligence ： We've come a long way The state of Computer Vision and AI: we are really, really far away.
The picture above is funny. But for me it is also one of those examples that make me sad about the o ...

- Interpretation of martial arts &#183; scattered
If you defend your left . There must be a weakness on your right : If you defend your front , There must be a weakness behind you . If you guard carefully everywhere , There must be weaknesses everywhere ." Some martial arts are ahead of others . But it's like drinking water , The more you look, the more tasteless you feel : but ...

- pure CSS Create Taobao navigation menu bar
Shop decoration -PC End - Base page - home page - Decoration page : edit “ menu ” modular - Display settings , Paste as follows CSS: /* Navigation bar background color */ .skin-box-bd .menu-list{background: none rep ...

- mysql Turn on root External link permissions
mysql to root Turn on Remote Access , modify root password 1.MySql-Server For security reasons, only native computers are allowed (localhost, 127.0.0.1) To connect to access . This is for Web-Server ...

- The finger of the sword offer（9） Abnormal step
Title Description A frog can jump up at a time 1 Stepped steps , You can jump on it 2 level …… It can also jump on n level . Ask the frog to jump on one n How many jumps are there in the steps . Topic analysis According to the previous topic, we can know that , The frog only jumps 1 or 2 It's a Fibonacci problem , namely ...