Breaking Linear Regression

CodeEmporium · Advanced ·🔢 Mathematical Foundations ·3y ago

Key Takeaways

The video 'Breaking Linear Regression' by CodeEmporium explores the consequences of violating the assumptions of linear regression in machine learning, covering topics such as linear regression parameters, residual distribution, and the implications of non-normal residuals. It provides resources and references to external materials, including data science and statistics forums, Wikipedia, and online courses.

Full Transcript

hello everyone in this video we're going to look at the assumptions of linear regression and see what happens if we break them at least its effects in the context of machine learning so here I have four assumptions that I'm breaking down with linear regression that's the linearity with parameters independent residuals normality of residuals and the equal variance of residuals so let's get to it now the goal in machine learning and regression specifically is to draw some curve that fits into a cloud of data points now with linear regression this is going to take a very specific form probably like one of the forms it can take is Theta 1 x i plus Theta zero it's just a linear equation right here both linear in terms of its parameters as well as the predictors and if we were to actually plot out this curve it might look something that looks like this just a straight line over here now another form that this potentially could take is of the form of theta 2 x i squared plus Theta 1 x i plus Theta 0. now this is an equation that is still linear in the parameters even though it is a quadratic in terms of the predictors and what you'll get if you plot this out it might be something that looks like a little curved line that looks like this now both of these are still acceptable forms for linear regression and do not violate the linearity Assumption of linearity with respect to parameters but one example that does violate the linearity with respect to parameters is let's say that if this was Theta 1 squared x i plus Theta 0. now this equation is now quadratic with respect to the parameters and it's not something that we can handle here now what happens actually if this case arises so let's talk about that so in a normal case of typical linear regression let's just assume that we took the simplest and linear form of regression that is linear in terms of both parameters and the predictor now the goal of linear regression is just to find the estimated parameters of theta 0 and Theta 1 which we typically find with maximum likelihood estimation and doing some math which I'll probably talk about later you'll see that it you can find it very easily just by minimizing the residual sum of squares so that's a sum of every single parameters actual value minus its predicted value and squaring it now in order to deal with Maximas and minimas we typically take derivatives with respect to each parameter now if you take the derivative with respect to Theta 0 you're going to get just some linear equation in terms of theta 0 and Theta 1. and if you also do the partial derivative with respect to Theta one you're also going to end up with another linear equation and when you have two linear equations and two unknowns it's really easy to solve with linear algebra and you can get closed form Solutions however in our case that we want to break linear regression we have now a Theta 1 square turn up here what will happen is now we need to do an argument of theta 1 square over here an argument of this entire expression and now if you try to take the partial derivatives you're going to say if you take it with respect to Theta zero you'll probably get a quadratic equation and if you take it with respect to Theta 1 the derivative with respect to Theta 1 you're going to get even a cubic equation and because you get non-linear terms with respect to the parameters that you want to solve you cannot solve this with simple linear algebra and there won't be a closed form solution that you would typically want to see in linear regression that said you can still technically put this data into a linear regressor and get some solution using some estimation techniques like gradient descent but basically this rule of linearity exists for the Simplicity of kind of determining the terms Theta 0 and Theta 1 with linear algebra now let's talk about the other three assumptions I put it as the i n and E assumptions but all of these are related to residuals so what are residuals so let's say that you have a data point that's up here and this line over here this green line is essentially going to be the prediction of what your linear regression would predict at a certain point of x and for this certain point of X you can see that this here is the difference between the predicted value and the actual value and it will be your residual which is Epsilon I now let's talk about each of these assumptions individually so first we'll start with I so the I here is independence and it basically says that these Theta these Epsilon terms are independent of each other and what this actually means in the context of looking at this graph is that well this here is a constant when the value of x is given and so it means that all the Y's over here are also independent of each other and so for a given X if the Y's are independent of each other that means all of the points on this one line all the data points that we would potentially see are all going to be independent of each other that's the first assumption next assumption is going to be our normality assumption and this basically says that this residual over here is going to be distributed normally with a mean of zero and some value of Sigma I squared which is going to be the variance and if you bubble this up this kind of leads to a fact that well y i given x i is essentially going to be sampled from also a normal distribution and if you add a constant because we're given x i so this entire term is a constant if you add it to a normal distribution it's technically going to be added to its mean so this plus 0 is which going to be Theta 1 x i plus 0 Theta 0 and this variance is going to remain the same essentially what this is saying visually is that all of the actual terms of Y are going to be normally distributed for given value of x so again along this straight line over here we can kind of write a little bell curve that kind of looks like this and for this given value of X1 we can also say that these points are going to be distributed like this the peak of the curve is going to be on the green line it's on the estimation because that's exactly what our mean is and so the mean should kind of coincide with the Peaks over here and Visually that would mean that there's like a lot of points that are concentrated here and a fewer points that are concentrated on the sides same for every single point of x a lot towards the center little of these y's towards the side so that's the second assumption now the third assumption is going to be equal variances so what this essentially means is that you see this I over here we're not going to write all this same over here we're not going to write this because the variance of well how that bubbles out visually is that the variance or the spread of this normal distribution is going to be the same as the spread of this normal distribution and is going to be the same as a spread of well any kind of normal distribution that you might add even if it was here for example so those are effectively the three assumptions that we need to follow during linear regression but like why do we need to solve this and what happens if we break this so the goal of linear regression like I mentioned before is going to be to find the parameters Theta 0 and Theta 1 which we find with a technique called a maximum likelihood estimation and here we want to maximize typically the likelihood of the curve fitting the data which is proportional to the probability of seeing the data itself and so it's the problem the product of the probability of seeing all the N data points and because P here is a probability density function that we've assumed to be normally distributed we get this equation over here which is the probability density function for a normal distribution and we want to maximize this or rather we want to find the values of theta 0 and Theta 1 that maximize this equation and what you can do is just take logarithms to convert this product into a sum term and you'll get a negative sign if you do logarithms so the max here just becomes Min and then we ultimately get the fact that we need to minimize the residual sum of squares in order to find the maximum likelihood estimates of theta 0 and Theta 1. and from here we we already know that this is a super popular equation that we always see when we're looking at linear regression so what happens if our assumptions now are broken well for one we already know this line assumption the L in line is linearity and we know that without the linearity Assumption we wouldn't be able to write this equation like we mentioned before because this would probably be a quadratic equation that might look like this and it just becomes more difficult to solve and you cannot solve it with linear algebra now we have this term I over here I is the independence assumption independence of residuals specifically but this bubbles up actually in this case such that we would not be able to write this form because here this probability should be the joint probability of seeing all of your data however you cannot represent a joint probability as a product of the individual probability distribution functions if they are not independent of each other and so without this Independence assumption you can't write this product and thus the computation just becomes so much more complex now moving on let's see what happens if we violate the normality assumption well we talked about before how this equation over here was the probability density function for a normal distribution and we wouldn't be able to now write this equation so explicitly and so cleanly because if there are multiple normal distributions going on or if one distribution is say some other uniform distribution another is normal then this equation also becomes far more complex and then finally we have this this e term over here which is equal variances and well with equal variances well we wouldn't be able to write this Sigma term on its own and we would need to write something like Sigma I same over here or rather Sigma n in this case and if you have a sigma n over here that means you can't really take it out of this product term notation and so the computation of this also becomes more expensive so I hope you can see now that in order to get this equation of residual sum of squares that we want to minimize the one that we know and love there are so many pieces that are required in order to actually get this more simplistic equation so I hope you can keep this in mind of like what are the assumptions now that linear regression is making and also why it is important that we need them for this specific derivation so thank you all so much for watching I'm gonna make some more videos on linear regression in the future with respect to math I love math so thank you for supporting and I will see you in the next one bye-bye foreign

Original Description

What happens if we break the assumptions of linear regression for machine learning? RESOURCES [1] What do linear regression parameters mean: https://datascience.stackexchange.com/questions/12274/what-does-linear-in-parameters-mean [2] This has some good intuition that distinguishes applications of linear regression: https://stats.stackexchange.com/questions/486672/why-dont-linear-regression-assumptions-matter-in-machine-learning [3] Why should residuals be normally distributed? https://qr.ae/pvl91W [4] Penn State's notes on the assumptions of linear regression: https://online.stat.psu.edu/stat501/lesson/4/4.1 [5]What do normal residuals tell you about your data: https://stats.stackexchange.com/questions/54533/what-do-normal-residuals-mean-and-what-does-this-tell-me-about-my-data [6] Wikipedia on linear regression (it's actually pretty good): https://en.wikipedia.org/wiki/Linear_regression#Assumptions [7] Better understanding of "Linear in parameters": https://datascience.stackexchange.com/questions/12274/what-does-linear-in-parameters-mean MATH COURSES (7 day free trial) 📕 Mathematics for Machine Learning: https://imp.i384100.net/MathML 📕 Calculus: https://imp.i384100.net/Calculus 📕 Statistics for Data Science: https://imp.i384100.net/AdvancedStatistics 📕 Bayesian Statistics: https://imp.i384100.net/BayesianStatistics 📕 Linear Algebra: https://imp.i384100.net/LinearAlgebra 📕 Probability: https://imp.i384100.net/Probability OTHER RELATED COURSES (7 day free trial) 📕 ⭐ Deep Learning Specialization: https://imp.i384100.net/Deep-Learning 📕 Python for Everybody: https://imp.i384100.net/python 📕 MLOps Course: https://imp.i384100.net/MLOps 📕 Natural Language Processing (NLP): https://imp.i384100.net/NLP 📕 Machine Learning in Production: https://imp.i384100.net/MLProduction 📕 Data Science Specialization: https://imp.i384100.net/DataScience 📕 Tensorflow: https://imp.i384100.net/Tensorflow
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from CodeEmporium · CodeEmporium · 0 of 60

← Previous Next →
1 Linear Regression and Multiple Regression
Linear Regression and Multiple Regression
CodeEmporium
2 Logistic Regression - THE MATH YOU SHOULD KNOW!
Logistic Regression - THE MATH YOU SHOULD KNOW!
CodeEmporium
3 Generative Adversarial Networks - FUTURISTIC & FUN AI !
Generative Adversarial Networks - FUTURISTIC & FUN AI !
CodeEmporium
4 Deep Learning on the Cloud - GPU TO LEARN FASTER
Deep Learning on the Cloud - GPU TO LEARN FASTER
CodeEmporium
5 Deep Mind's AlphaGo Zero - EXPLAINED
Deep Mind's AlphaGo Zero - EXPLAINED
CodeEmporium
6 Mask Region based Convolution Neural Networks - EXPLAINED!
Mask Region based Convolution Neural Networks - EXPLAINED!
CodeEmporium
7 Attention in Neural Networks
Attention in Neural Networks
CodeEmporium
8 Depthwise Separable Convolution - A FASTER CONVOLUTION!
Depthwise Separable Convolution - A FASTER CONVOLUTION!
CodeEmporium
9 One Neural network learns EVERYTHING ?!
One Neural network learns EVERYTHING ?!
CodeEmporium
10 Neural Voice Cloning
Neural Voice Cloning
CodeEmporium
11 AI creates Image Classifiers…by DRAWING?
AI creates Image Classifiers…by DRAWING?
CodeEmporium
12 Unpaired Image-Image Translation using CycleGANs
Unpaired Image-Image Translation using CycleGANs
CodeEmporium
13 K-Means Clustering - EXPLAINED!
K-Means Clustering - EXPLAINED!
CodeEmporium
14 Random Forest Classification
Random Forest Classification
CodeEmporium
15 Data Science in Finance
Data Science in Finance
CodeEmporium
16 Hypothesis testing with Applications in Data Science
Hypothesis testing with Applications in Data Science
CodeEmporium
17 A/B Testing - Simply Explained
A/B Testing - Simply Explained
CodeEmporium
18 The Kernel Trick - THE MATH YOU SHOULD KNOW!
The Kernel Trick - THE MATH YOU SHOULD KNOW!
CodeEmporium
19 Support Vector Machines - THE MATH YOU  SHOULD KNOW
Support Vector Machines - THE MATH YOU SHOULD KNOW
CodeEmporium
20 Principal Component Analysis (PCA) - THE MATH YOU SHOULD KNOW!
Principal Component Analysis (PCA) - THE MATH YOU SHOULD KNOW!
CodeEmporium
21 History of Calculus - Animated
History of Calculus - Animated
CodeEmporium
22 Curiosity in AI
Curiosity in AI
CodeEmporium
23 DropBlock - A BETTER DROPOUT for Neural Networks
DropBlock - A BETTER DROPOUT for Neural Networks
CodeEmporium
24 Autoencoders - EXPLAINED
Autoencoders - EXPLAINED
CodeEmporium
25 Recurrent Neural Networks - EXPLAINED!
Recurrent Neural Networks - EXPLAINED!
CodeEmporium
26 LSTM Networks - EXPLAINED!
LSTM Networks - EXPLAINED!
CodeEmporium
27 Building an Image Captioner with Neural Networks
Building an Image Captioner with Neural Networks
CodeEmporium
28 10 Machine Learning Questions - ANSWERED!
10 Machine Learning Questions - ANSWERED!
CodeEmporium
29 How do neural networks work?
How do neural networks work?
CodeEmporium
30 Evolution of Face Generation |  Evolution of GANs
Evolution of Face Generation | Evolution of GANs
CodeEmporium
31 How does Google Translate's AI work?
How does Google Translate's AI work?
CodeEmporium
32 How to keep up with AI research?
How to keep up with AI research?
CodeEmporium
33 How does YouTube recommend videos? - AI EXPLAINED!
How does YouTube recommend videos? - AI EXPLAINED!
CodeEmporium
34 Variational Autoencoders - EXPLAINED!
Variational Autoencoders - EXPLAINED!
CodeEmporium
35 Logistic Regression - VISUALIZED!
Logistic Regression - VISUALIZED!
CodeEmporium
36 Gradient Descent - THE MATH YOU SHOULD KNOW
Gradient Descent - THE MATH YOU SHOULD KNOW
CodeEmporium
37 Boosting - EXPLAINED!
Boosting - EXPLAINED!
CodeEmporium
38 Transformer Neural Networks - EXPLAINED! (Attention is all you need)
Transformer Neural Networks - EXPLAINED! (Attention is all you need)
CodeEmporium
39 Loss Functions - EXPLAINED!
Loss Functions - EXPLAINED!
CodeEmporium
40 Optimizers - EXPLAINED!
Optimizers - EXPLAINED!
CodeEmporium
41 NLP with Neural Networks & Transformers
NLP with Neural Networks & Transformers
CodeEmporium
42 Batch Normalization - EXPLAINED!
Batch Normalization - EXPLAINED!
CodeEmporium
43 Activation Functions - EXPLAINED!
Activation Functions - EXPLAINED!
CodeEmporium
44 Data Scientist Answers Interview Questions
Data Scientist Answers Interview Questions
CodeEmporium
45 Why use GPU with Neural Networks?
Why use GPU with Neural Networks?
CodeEmporium
46 How do GPUs speed up Neural Network training?
How do GPUs speed up Neural Network training?
CodeEmporium
47 BERT Neural Network - EXPLAINED!
BERT Neural Network - EXPLAINED!
CodeEmporium
48 ConvNets Scaled Efficiently
ConvNets Scaled Efficiently
CodeEmporium
49 Transformer Neural Net makes music! (JukeboxAI)
Transformer Neural Net makes music! (JukeboxAI)
CodeEmporium
50 What do filters of Convolution Neural Network learn?
What do filters of Convolution Neural Network learn?
CodeEmporium
51 We're hosting a Machine Learning Conference!
We're hosting a Machine Learning Conference!
CodeEmporium
52 MLconfEU 2020: Machine Learning Conference for Software Engineers
MLconfEU 2020: Machine Learning Conference for Software Engineers
CodeEmporium
53 Are Neural Networks Intelligent?
Are Neural Networks Intelligent?
CodeEmporium
54 Time Series Forecasting with Machine Learning
Time Series Forecasting with Machine Learning
CodeEmporium
55 Few Shot Learning - EXPLAINED!
Few Shot Learning - EXPLAINED!
CodeEmporium
56 How does a Data Scientist Fight FRAUD?
How does a Data Scientist Fight FRAUD?
CodeEmporium
57 How would a Data Scientist analyze Customer Churn?
How would a Data Scientist analyze Customer Churn?
CodeEmporium
58 Expectations with Machine Learning
Expectations with Machine Learning
CodeEmporium
59 Why Logistic Regression DOESN'T return probabilities?!
Why Logistic Regression DOESN'T return probabilities?!
CodeEmporium
60 How you SHOULD code Machine Learning
How you SHOULD code Machine Learning
CodeEmporium

The video 'Breaking Linear Regression' explores the consequences of violating linear regression assumptions, providing resources and references for further learning. It covers key concepts such as linear regression parameters, residual distribution, and the implications of non-normal residuals. By watching this video, viewers can gain a deeper understanding of linear regression and its applications in machine learning.

Key Takeaways
  1. Understand the assumptions of linear regression
  2. Analyze residual distribution
  3. Evaluate the implications of non-normal residuals
  4. Apply statistical modeling techniques
  5. Implement linear regression models
💡 Violating the assumptions of linear regression can have significant consequences for model performance and interpretation, highlighting the importance of careful data analysis and model evaluation.

Related Reads

Up next
Solve Any Math Problem Step by Step — Free (Type or Snap a Photo)
Zariga Tongy
Watch →