当前位置:网站首页>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
边栏推荐
- DVWA之暴力破解(Brute Force)Low-->high
- 基于单片机的DS18B20的数字温度监控报警系统设计【LCD1602显示+Proteus仿真+C程序+论文+按键设置等】
- I thought I could lie down and enter Huawei, but I was confused when I received JD / didi / iqiyi offers one after another
- Progress in the treatment of depression
- pnpm安装使用
- Four ways of SSH restricting login
- Set up an AI team in the game world and start the super parametric multi-agent "chaos fight"
- 8.5 循环神经网络简洁实现
- 【STC8G2K64S4】比较器介绍以及比较器掉电检测示例程序
- Swift protocol Association object resource name management multithreading GCD delay once
猜你喜欢
qt之.pro文件详解
线程同步、生命周期
The art of automation
Arduino for esp8266串口功能简介
eolink 如何助力远程办公
【工厂模式详解】工厂方法模式
Multisim Simulation Design of DC adjustable regulated power supply of LM317 (with simulation + paper + reference)
51 MCU + LCD12864 LCD Tetris game, proteus simulation, ad schematic diagram, code, thesis, etc
8.4 循环神经网络从零实现
外包幹了四年,廢了...
随机推荐
[proteus simulation] automatic range (range < 10V) switching digital voltmeter
Arduino for esp8266串口功能简介
Four ways of SSH restricting login
编程哲学——自动加载、依赖注入与控制反转
Design of single chip microcomputer Proteus for temperature and humidity monitoring and alarm system of SHT11 sensor (with simulation + paper + program, etc.)
【Proteus仿真】自动量程(范围<10V)切换数字电压表
Use of ansible and common modules
ASEMI整流模块MDQ100-16在智能开关电源中的作用
Realization of four data flow modes of grpc based on Multilingual Communication
Select receives both normal data and out of band data
QT actual combat: Yunxi calendar
Eight way responder system 51 Single Chip Microcomputer Design [with Proteus simulation, C program, schematic diagram, PCB files, component list and papers, etc.]
raised exception class EAccexxViolation with ‘Access violation at address 45EFD5 in module 出错
Detailed explanation of C language P2 selection branch statement
LotusDB 设计与实现—1 基本概念
基于单片机的DS18B20的数字温度监控报警系统设计【LCD1602显示+Proteus仿真+C程序+论文+按键设置等】
Mq-2 and DS18B20 fire temperature smoke alarm system design, 51 single chip microcomputer, with simulation, C code, schematic diagram, PCB, etc
OpenFaaS实战之四:模板操作(template)
QT actual combat: Yunxi chat room
一款不错的工具:aardio