当前位置:网站首页>Popular understanding of linear regression (I)
Popular understanding of linear regression (I)
2022-07-03 15:16:00 【alw_ one hundred and twenty-three】
I have planned to present this series of blog posts in the form of animated interesting popular science , If you're interested Click here .
#0 What is return ?
Suppose linear regression is a black box , According to the programmer's thinking , This black box is a function , so what , We just need to pass some parameters to this function as input , You can get a result as output . What does return mean ? In fact, it's plain , The result of this black box output is a continuous value . If the output is not a continuous value but a discrete value, it is called classification . What is continuous value ? It's simple , Take a chestnut : For example, I tell you I have a house here , This house has 40 flat , At the subway entrance , Then guess how much my house is worth in total ? This is the continuous value , Because the house may be worth 80 ten thousand , It may also be worth 80.2 ten thousand , It may also be worth 80.111 ten thousand . Another example , I tell you I have a house ,120 flat , At the subway entrance , Total value 180 ten thousand , Then guess how many bedrooms my house will have ? Then this is the discrete value . Because the number of bedrooms can only be 1, 2, 3,4, At best 5 It's capped , And the number of bedrooms can't be anything 1.1, 2.9 individual . So , about ML Mengxin says , As long as you know that my task is to predict a continuous value , Then the task is to return . If it is a discrete value, it is classification .(PS: At present, only supervised learning is discussed )
#1 Linear regression
OK, Now that we know what regression is , Now let's talk about linear . In fact, this thing is also very simple , We all learned the linear equation in junior high school, didn't we ? Come on, come on , Let's recall what the linear equation is ?
y = k x + b y=kx+b y=kx+b
here , This is the straight-line equation that our junior high school math teacher taught us . All the students who went to junior high school know , This expression expresses , When I know k( Parameters ) and b( Parameters ) Under the circumstances , I'll just give one x I can calculate through this equation y Come on . And , This formula is linear , Why? ? Because intuitively , You all know , The function image of this formula is a straight line .... In theory , This formula satisfies the properties of linear system .( As for what a linear system is , I'll stop talking , Or it will be endless ) Some students may feel confused , This section is about linear regression , I pull this low Why force the linear equation ? Actually , To put it bluntly , Linear regression is nothing more than N Finding a function in dimensional space in the form of a linear equation to fit the data . for instance , I have this picture now , The abscissa represents the area of the house , The ordinate represents the house price .
so what , Linear regression is to find a straight line , And let this line fit the data points in the graph as much as possible .
So if you let 1000 If an old iron comes to find this straight line, he may find 1000 A straight line , Such as this
such
Or so
here , In fact, the process of finding a straight line is doing linear regression , It's just that this name is more powerful ...
#2 Loss function
Since it's looking for a straight line , There must be a standard for judging , To judge which line is the best .OK, We all know the truth , How to judge ? In fact, simple yuppies ... Just calculate the difference between the actual house price and the house price predicted by the straight line based on the size of the house I found . To put it bluntly, it's the distance between two points . When we compare all the actual house prices with the predicted house prices ( distance ) Calculate it and add it , We can quantify the error between our predicted house prices and actual house prices . For example, in the figure below, I draw many decimal lines , Each decimal line is the difference between the actual house price and the predicted house price ( distance )
Then add up the length of each small vertical line, which is equal to the gap between the predicted house price and the actual house price . What is the sum of the length of each small vertical line ? It's actually European distance plus , The formula is as follows .( among y(i) It means the real house price ,y^(i) It means predicting house prices )
This Euclidean distance summation is actually a function used to quantify the error between the predicted result and the real result . stay ML It is called the loss function ( To put it bluntly, it is a function of the calculation error ). So with this function , We have a criterion , When the value of this function is smaller , The more it shows that the straight line we find can better fit our house price data . So say , Linear regression is nothing more than to find a straight line by using this loss function as the evaluation standard .
The example I just gave is a one-dimensional example ( The feature is only the size of the house ), Now let's assume that another feature of my data is the floor spacing , The image may be mauve .
We can see from the picture , Even in two-dimensional space , Or find a straight line to fit our data . So! , The soup does not change the dressing , The loss function is still the sum of Euclidean distances .
Let's start with this , Because if the space is too long , It's not very friendly for Mengxin , And later I want to talk about the normal equation solution of linear regression , So gather strength first .
边栏推荐
- 【云原生训练营】模块八 Kubernetes 生命周期管理和服务发现
- 【pytorch学习笔记】Datasets and Dataloaders
- 百度智能云助力石嘴山市升级“互联网+养老服务”智慧康养新模式
- Concurrency-01-create thread, sleep, yield, wait, join, interrupt, thread state, synchronized, park, reentrantlock
- Basic SQL tutorial
- SQL server installation location cannot be changed
- 视觉上位系统设计开发(halcon-winform)-5.相机
- Global and Chinese market of marketing automation 2022-2028: Research Report on technology, participants, trends, market size and share
- Dataframe returns the whole row according to the value
- 视觉上位系统设计开发(halcon-winform)-6.节点与宫格
猜你喜欢
Kubernetes vous emmène du début à la fin
What are the composite types of Blackhorse Clickhouse, an OLAP database recognized in the industry
视觉上位系统设计开发(halcon-winform)
[set theory] inclusion exclusion principle (complex example)
5.2-5.3
Troubleshooting method of CPU surge
What is embedding (encoding an object into a low dimensional dense vector), NN in pytorch Principle and application of embedding
Halcon与Winform学习第一节
Jvm-03-runtime data area PC, stack, local method stack
【Transformer】入门篇-哈佛Harvard NLP的原作者在2018年初以逐行实现的形式呈现了论文The Annotated Transformer
随机推荐
Leasing cases of the implementation of the new regulations on the rental of jointly owned houses in Beijing
Global and Chinese market of Bus HVAC systems 2022-2028: Research Report on technology, participants, trends, market size and share
Jvm-03-runtime data area PC, stack, local method stack
Redis cache penetration, cache breakdown, cache avalanche solution
Halcon与Winform学习第一节
Construction of operation and maintenance system
Concurrency-02-visibility, atomicity, orderliness, volatile, CAS, atomic class, unsafe
Global and Chinese market of transfer case 2022-2028: Research Report on technology, participants, trends, market size and share
【注意力机制】【首篇ViT】DETR,End-to-End Object Detection with Transformers网络的主要组成是CNN和Transformer
[attention mechanism] [first vit] Detr, end to end object detection with transformers the main components of the network are CNN and transformer
Byte practice surface longitude
Redis single thread problem forced sorting layman literacy
Summary of concurrent full knowledge points
Mysql报错:[ERROR] mysqld: File ‘./mysql-bin.010228‘ not found (Errcode: 2 “No such file or directory“)
[pytorch learning notes] transforms
App global exception capture
Neon global and Chinese markets 2022-2028: Research Report on technology, participants, trends, market size and share
Center and drag linked global and Chinese markets 2022-2028: Research Report on technology, participants, trends, market size and share
Redis主从、哨兵、集群模式介绍
Global and Chinese market of optical fiber connectors 2022-2028: Research Report on technology, participants, trends, market size and share