当前位置:网站首页>Normal equation
Normal equation
2022-06-24 10:18:00 【Wanderer001】
Reference resources Normal equation - cloud + Community - Tencent cloud
Catalog
One 、 What is a normal equation
3、 ... and 、 Irreversible case
Four 、 Comparison between normal equation and gradient descent method
One 、 What is a normal equation
The gradient descent method is used to calculate the optimal solution of parameters , The process is to find the partial derivative of each parameter of the cost function , Update step by step through iterative algorithm , Until it converges to the global minimum , The optimal parameters are obtained .
The normal equation is to find the optimal solution at one time .
thought : For a simple function , Derivation of parameters , Set the value to 0, You get the value of the parameter . Like this :

Real world examples have many parameters , We're going to find the partial derivatives for all these parameters , Get the optimal solution of each parameter , That is, the global optimal solution . But the difficulty is , This is a waste of time .
Two 、 Use of normal equations
Examples are as follows :

here 4 Samples , as well as 4 Characteristic variables x1,x2,x3,x4, The observation is y, When listing cost functions , You need to add an end parameter x0, as follows :

Then save the characteristic parameters in X Matrix , Do the same for the observations and save them in the vector y in , Pictured :

Then we get the parameters by the following formula θ Optimal solution .
![]()
About this formula :

For all the characteristic parameters of a training sample, we can use x(i) Vector to represent ( Be careful x0(i) To add ) , The design matrix can be expressed as X, Is the transpose of all sample vectors ,y Is the vector of observations , After this expression, you can use the above formula to directly calculate Θ The best solution .
3、 ... and 、 Irreversible case
Notice that the normal equation has a
The process of finding the inverse matrix , When the matrix is irreversible , There are generally two reasons :
- Superfluous features ( Linear correlation )
- Too many features ( for example :m≤n), terms of settlement : Delete some features , Or regularization
Actually , The essential reason is linear knowledge :
First , These are two necessary conditions ,
According to the nature :r(ATA) = r(A),ATA Reversibility can be transformed into A Reversibility of .
The first one is : It's actually a linearly related column vector , The rank of a matrix < The dimensions of the matrix , Irreversible ;
The second kind :
- m < n when , That is, the dimension is less than the number of vectors , Here, that is, the number of samples is less than the characteristic number , Linear correlation
- m = n when , When |A| = 0 Time is irreversible ,|A| != 0 Time reversible
Four 、 Comparison between normal equation and gradient descent method
Gradient descent method :
shortcoming :
- We need to choose the learning rate α
- It takes several iterations
advantage :
- When the characteristic parameter is large , Gradient descent also works well
Normal equation :
shortcoming :
- Need to compute
, The amount of calculation is about the third power of the matrix dimension , High complexity . - When the characteristic parameter is large , The calculation is slow
advantage :
- No need for learning rate α
- No more iterations are required
summary : Depends on the number of eigenvectors , Quantity less than 10000 when , Choose the normal equation ; Greater than 10000, Consider gradient descent or other algorithms .
边栏推荐
- numpy.logical_and()
- 包装类型的缓存机制
- Uniapp implementation forbids video drag fast forward
- Detailed explanation of PHP singleton mode
- 6. package management business development
- Leetcode-1089: replication zero
- 6.套餐管理业务开发
- Mise en œuvre du rendu de liste et du rendu conditionnel pour l'apprentissage des applets Wechat.
- leetCode-1089: 复写零
- 利用pandas读取SQL Sever数据表
猜你喜欢

Development of anti fleeing marketing software for health products

简单的价格表样式代码

整理接口性能优化技巧,干掉慢代码

Yolov6: the fast and accurate target detection framework is open source

线程的六种状态

411 stack and queue (20. valid parentheses, 1047. delete all adjacent duplicates in the string, 150. inverse Polish expression evaluation, 239. sliding window maximum, 347. the first k high-frequency

3.员工的增删改查

SQL Server AVG函数取整问题

3. addition, deletion, modification and query of employees

Indexeddb local storage, homepage optimization
随机推荐
使用swiper左右轮播切换时,Swiper Animate的动画失效,怎么解决?
Error reading CSV (TSV) file
How does home office manage the data center network infrastructure?
Leetcode - 498: traversée diagonale
2022-06-23: given a nonnegative array, select any number to make the maximum cumulative sum a multiple of 7, and return the maximum cumulative sum. N is larger, to the 5th power of 10. From meituan. 3
Desktop software development framework reward
Machine learning - principal component analysis (PCA)
Geogebra instance clock
numpy.linspace()
Dragging El table sortablejs
uniapp实现禁止video拖拽快进
leetCode-1051: 高度检查器
PHP uses recursive and non recursive methods to create multi-level folders
简单的价格表样式代码
引擎国产化适配&重构笔记
leetCode-929: 独特的电子邮件地址
MYSQL数据高级
Development of anti fleeing marketing software for health products
利用pandas读取SQL Sever数据表
SQL sever试题求最晚入职日期