## 当前位置：网站首页>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

## 边栏推荐

## 猜你喜欢

[NLP] HMM hidden Markov + Viterbi word segmentation

PWM speed regulation control system of DC motor based on 51 single chip microcomputer (with complete set of data such as Proteus simulation + C program)

MySQL报错packet out of order

Outsourcing for four years, abandoned

外包干了四年，废了...

Arduino for esp8266串口功能简介

Swift：Entry of program、Swift调用OC、@_silgen_name 、 OC 调用Swift、dynamic、String、Substring

Do (local scope), initializer, memory conflict, swift pointer, inout, unsafepointer, unsafebitcast, success

Proteus simulation design of four storey and eight storey elevator control system, 51 single chip microcomputer, with simulation and keil c code

成都控制板设计提供_算是详细了_单片机程序头文件的定义、编写及引用介绍

## 随机推荐

剑指 Offer II 019. 最多删除一个字符得到回文（简单）

Matlab Simulink modeling and design of single-phase AC-AC frequency converter, with MATLAB simulation, PPT and papers

[untitled]

Detailed explanation of C language knowledge points -- first knowledge of C language [1]

一个月把字节，腾讯，阿里都面了，写点面经总结……

电容

Use of ansible and common modules

[jz46 translate numbers into strings]

We reference My97DatePicker to realize the use of time plug-in

八路抢答器系统51单片机设计【附Proteus仿真、C程序、原理图及PCB文件、元器件清单和论文等】

MDS55-16-ASEMI整流模块MDS55-16

Solve the problem of SSH configuration file optimization and slow connection

一款不错的工具：aardio

Design of single chip microcomputer Proteus for temperature and humidity monitoring and alarm system of SHT11 sensor (with simulation + paper + program, etc.)

Electronic perpetual calendar of DS1302_ 51 single chip microcomputer, month, day, week, hour, minute and second, lunar calendar and temperature, with alarm clock and complete set of data

What is the main purpose of PCIe X1 slot?

想要成为架构师？夯实基础最重要

QT actual combat: Yunxi chat room

JumpServer

SVN详细使用教程