当前位置:网站首页>Explanation and example application of the principle of logistic regression in machine learning
Explanation and example application of the principle of logistic regression in machine learning
2022-04-23 14:46:00 【C don't laugh】
AI learning path
Chapter one The most detailed Python Introductory mind map , Collect... Decisively
Chapter two Python Desktop application development (PyQT) Introductory mind map , Collect... Decisively
The third chapter Python Data analysis (Numpy and Pandas Study ) Introductory mind map , Collect... Decisively
Chapter four Python Introduction to machine learning based on the concept of artificial intelligence , Collect... Decisively
The fifth chapter Machine learning KNN Nearest neighbor classification algorithm introduction mind map , Collect... Decisively
List of articles
Logical regression (Logistic Regression,LR) Also known as logistic regression analysis , It is one of the classification and prediction algorithms . Predict the probability of future results through the performance of historical data . for example , We can set the probability of purchase as a dependent variable , Attribute the user's characteristics , Such as gender , Age , Set the registration time as an independent variable . Predict the probability of purchase according to the characteristic attributes .
One 、 Introduction to logical regression thinking map
Two 、 Logical regression LR
Suppose there are some data points now , We use a straight line to fit these points ( This line is called the best-fitting line ), This fitting process is called regression , As shown in the figure below :
Logistic Regression is the classification method , It uses Sigmoid The function threshold is at [0,1] This feature .Logistic The main idea of regression classification is : The regression formula of classification boundary line is established according to the existing data , This is used for classification . Actually ,Logistic It is essentially a discriminant model based on conditional probability (Discriminative Model).
Sigmoid function
The picture below , It shows us Sigmoid What a function looks like
Logical regression is essentially linear regression , It just adds a layer to the feature to result mapping Sigmod Function mapping , That is, sum the characteristic lines first , then Use Sigmoid Function will be the most hypothetical function to solve the probability , And then classify .
3、 ... and 、 Logistic regression characteristics
Logical regression (Logistic Regression) Mainly solve the problem of two categories , Used to indicate the possibility of something happening .
- advantage : It is suitable for the scene that needs to get a classification probability , Simple , Fast
- shortcoming : It can only be used to deal with binary classification problems , It's not easy to deal with multi classification problems , Easy under fitting , Generally, the accuracy is not very high
- application : Are you sick 、 Financial fraud 、 Whether there is a false account number, etc
Four 、 Logical regression VS Linear regression
Linear regression and logistic regression are 2 A classic algorithm . Often used for comparison , Here are some differences between the two
Application instance – Cancer case prediction
Core code
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import classification_report
# Load data
breast = load_breast_cancer()
# Data splitting
X_train, X_test, y_train, y_test = train_test_split(
breast.data, breast.target)
# Data standardization
std = StandardScaler()
X_train = std.fit_transform(X_train)
X_test = std.transform(X_test)
# Training prediction
lg = LogisticRegression()
lg.fit(X_train, y_train)
y_predict = lg.predict(X_test)
# View training accuracy and forecast reports
print(lg.score(X_test, y_test))
print(classification_report(
y_test, y_predict, labels=[0, 1], target_names=[" Benign ", " Malignant "]))
Running results
precision It means accuracy ;recall It means the recall rate ;f1-score Indicates the comprehensive index ;support Indicates the predicted number of people . The recall rate of this model , Benign achievement 0.97, Malignant to 0.96; This example is to detect cancer , We hope to find all people with cancer , Even if he's not cancer , You can also do further inspection , Therefore, we need a model with high recall rate .
summary
Logistic regression is an extension of linear regression analysis , It maps the regression value into probability value through logic function , It realizes the processing of classification problems .
版权声明
本文为[C don't laugh]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231425225682.html
边栏推荐
- 详解TCP的三次握手
- Branch statement of process control
- I/O复用的高级应用之一:非阻塞 connect———使用 select 实现(也可以用 poll 实现)
- do(Local scope)、初始化器、内存冲突、Swift指针、inout、unsafepointer、unsafeBitCast、successor、
- [stc8g2k64s4] introduction of comparator and sample program of comparator power down detection
- [proteus simulation] automatic range (range < 10V) switching digital voltmeter
- One of the advanced applications of I / O reuse: non blocking connect -- implemented using select (or poll)
- Master in minutes --- ternary operator (ternary operator)
- 解决computed属性与input的blur事件冲突问题
- 【STC8G2K64S4】比较器介绍以及比较器掉电检测示例程序
猜你喜欢
UML project example -- UML diagram description of tiktok
Explain TCP's three handshakes in detail
1 minute to understand the execution process and permanently master the for cycle (with for cycle cases)
Matlab Simulink modeling and design of single-phase AC-AC frequency converter, with MATLAB simulation, PPT and papers
【STC8G2K64S4】比较器介绍以及比较器掉电检测示例程序
你還不知道責任鏈模式的使用場景嗎?
SHT11传感器的温度湿度监控报警系统单片机Proteus设计(附仿真+论文+程序等)
Eight way responder system 51 Single Chip Microcomputer Design [with Proteus simulation, C program, schematic diagram, PCB files, component list and papers, etc.]
在游戏世界组建一支AI团队,超参数的多智能体「大乱斗」开赛
We reference My97DatePicker to realize the use of time plug-in
随机推荐
PCIe X1 插槽的主要用途是什么?
[stc8g2k64s4] introduction of comparator and sample program of comparator power down detection
JumpServer
Matrix exchange row and column
Master in minutes --- ternary operator (ternary operator)
一个月把字节,腾讯,阿里都面了,写点面经总结……
51 Single Chip Microcomputer Design of traffic light system (with Proteus simulation, C program, schematic diagram, PCB, thesis and other complete data)
Interviewer: let's talk about the process of class loading and the mechanism of class loading (parental delegation mechanism)
Select receives both normal data and out of band data
8.4 循环神经网络从零实现
Resolve the conflict between computed attribute and input blur event
压缩映射定理
【STC8G2K64S4】比较器介绍以及比较器掉电检测示例程序
【工厂模式详解】工厂方法模式
Eight way responder system 51 Single Chip Microcomputer Design [with Proteus simulation, C program, schematic diagram, PCB files, component list and papers, etc.]
金九银十,入职字节跳动那一天,我哭了(蘑菇街被裁,奋战7个月拿下offer)
OC 转 Swift 条件编译、标记、宏、 Log、 版本检测、过期提示
Achievements in science and Technology (21)
【JZ46 把数字翻译成字符串】
Find daffodils - for loop practice