当前位置:网站首页>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
边栏推荐
- Vous ne connaissez pas encore les scénarios d'utilisation du modèle de chaîne de responsabilité?
- 8.2 文本预处理
- 面试官:说一下类加载的过程以及类加载的机制(双亲委派机制)
- ASEMI超快恢复二极管与肖特基二极管可以互换吗
- epoll 的EPOLLONESHOT 事件———实例程序
- Swift: entry of program, swift calls OC@_ silgen_ Name, OC calls swift, dynamic, string, substring
- select 同时接收普通数据 和 带外数据
- 【无标题】
- 在游戏世界组建一支AI团队,超参数的多智能体「大乱斗」开赛
- MySQL error packet out of order
猜你喜欢
Outsourcing for four years, abandoned
线程同步、生命周期
Mq-2 and DS18B20 fire temperature smoke alarm system design, 51 single chip microcomputer, with simulation, C code, schematic diagram, PCB, etc
【无标题】
你还不知道责任链模式的使用场景吗?
Matlab Simulink modeling and design of single-phase AC-AC frequency converter, with MATLAB simulation, PPT and papers
【JZ46 把数字翻译成字符串】
do(Local scope)、初始化器、内存冲突、Swift指针、inout、unsafepointer、unsafeBitCast、successor、
QT actual combat: Yunxi calendar
Swift: entry of program, swift calls OC@_ silgen_ Name, OC calls swift, dynamic, string, substring
随机推荐
Thread synchronization, life cycle
【Proteus仿真】自动量程(范围<10V)切换数字电压表
eolink 如何助力远程办公
select 同时接收普通数据 和 带外数据
【无标题】
Provided by Chengdu control panel design_ It's detailed_ Introduction to the definition, compilation and quotation of single chip microcomputer program header file
Don't you know the usage scenario of the responsibility chain model?
One of the advanced applications of I / O reuse: non blocking connect -- implemented using select (or poll)
面试官:说一下类加载的过程以及类加载的机制(双亲委派机制)
【工厂模式详解】工厂方法模式
自动化的艺术
Outsourcing for four years, abandoned
Multisim Simulation Design of DC adjustable regulated power supply of LM317 (with simulation + paper + reference)
QT actual combat: Yunxi chat room
Master in minutes --- ternary operator (ternary operator)
编程哲学——自动加载、依赖注入与控制反转
do(Local scope)、初始化器、内存冲突、Swift指针、inout、unsafepointer、unsafeBitCast、successor、
I/O复用的高级应用之一:非阻塞 connect———使用 select 实现(也可以用 poll 实现)
JumpServer
三、梯度下降求解最小θ