Regression A-Z Briefly Explained
Last Updated on January 7, 2023 by Editorial Team
Author(s): Gencay I.
Originally published on Towards AI the World’s Leading AI and Technology News and Media Company. If you are building an AI-related product or service, we invite you to consider becoming an AI sponsor. At Towards AI, we help scale AI and technology startups. Let us help you unleash your technology to the masses.
Quick and Remindful Cheatsheet for refreshing
Regression is one of the famous terms in Machine Learning.
If you want to dive into machine learning, regression and its terms definitely will beΒ needed.
Quick reminder for you to catch up with machine learningΒ terms;
Machine Learning A-Z Briefly Explained
Contents
Β· Introduction
Β· Terms
β Linear Regression
β Multiple Regression
β Evaluation Metrics
β Mean Squared Error
β Root Mean Squared Error
β Cost Function
β The Normal Equation
β Polynomial Regression
β Quadratic Function
β bodycal
Β· Conclusion
Introduction
This article has been saved too many times by the medium users, so I have decided to split model types fromΒ A-Z.
Now it is time for regression, sure if your interest in that kind of article will continue, I will write Classification A-Z and Clustering A-ZΒ too.
That kind of brief explanation article may help you to find out your weak spot about thatΒ topic.
Or just a reminder before your personal or work project or even interesting, for your job interview.
Now let's skip the chit-chat and dive into linear regression terms.
Terms
Linear Regression
It is just a linear function.
Suppose you want to predict the price of a car and it only depends on the engineΒ size.
Then, the price of a car would be y and the engine size would beΒ x.
ΞΈ would define the function and predicts how much the price change according to the engineΒ size.
Suppose ΞΈ = 2, if you change the engine size 1, the price change 2, just as simple asΒ that.
Formula
Variables
y = predicted value
n = number ofΒ features
In simple linear regression, n = 1, if n > 1 it will be multiple linear regression.
ΞΈ = model parameter
Graph
Let's suppose our function isΒ ;
Then our graph will beΒ ;
Multiple Regression
This time the price of car y depends on engine size X1 and the mileageΒ X2.
Function
The same function with linear regression, however, this time n >Β 1.
Variables
y = predicted value
n = number ofΒ features
ΞΈ = model parameter
x =Β features
Graphic
Evaluation Metrics
RMSE, and MSE which will be explained now, both are evaluation metrics that give us the chance of rating the model's performance.
Mean SquaredΒ Error
It is an evaluation metric & performance measure of ourΒ model.
Suppose you predict y to be 5000, and it is actually 4000 and you got 10 of yΒ value.
Now, 5000β4000 is equal to 1000. You have to find 10 values like that, you will sum these values, take a square and sum the number of theΒ values.
It looks a little bit confusing at first, but try to understand it from the function or look it up in real-life examples.
Function
Variables
y = predicted value
n = number ofΒ features
ΞΈ = model parameter
x =Β features
Root Mean SquaredΒ Error
Same as stated above, just mathematically root the function.
Function
Variables
y = predicted value
n = number ofΒ features
ΞΈ = model parameter
x =Β features
Cost Function
The cost function is one of the functions that you chose and with that, you will evaluate your model's performance, like root mean square or mean squaredΒ error.
The NormalΒ Equation
Now, this equation is used for finding the best model parameter(ΞΈ) that minimizes your cost function in linearΒ models.
It looks like mathematically a bit complex but if you are familiar with NumPy it is easy toΒ code.
If you are not familiar with NumPy or programming language, do not worry there are plenty of courses existed on the internet, and most of them areΒ free.
Variables
y = predicted
ΞΈ = is the value, which minimizes the costΒ function
x =Β features
Polynomial Regression
If your data is more complex to show with a straight line, you can add powers to your features to explain theΒ curve.
Function
Graph
Variables
y = predicted value
n = number ofΒ features
ΞΈ = model parameter
x =Β features
Quadratic Function
That is a simply functions with powers(x**2)
Function
Variables
y = predicted value
a = intercept
ΞΈ = model parameter
x =Β features
Graph
If some of the statistical terms are a bit confusing or unfamiliar to you, actually, I have an article, another A-Z, which is about statistics, you may want to check thatΒ too.
Statistics for Machine Learning A-Z
Expressing your knowledge in different ways, with graphsβββformulas, and descriptions may help you toΒ refresh.
I try to do it in a very simple way for the people who will read thisΒ article.
On the other hand, there are too many terms as follows which I can explain to you in Chapter 2 of this article,Β such;
- Regularized LinearΒ Models
- Ridge Regression
- Lasso Regression
- Elastic Net
- Logistic Regression
- Softmax Regression
- Confidence Interval
And also here there is another article ofΒ mine.
In the following article, I tried to predict my weight according to my body measurements by using a Regression Model.
bodycal
Here also I wrote a Python library, nameΒ bodycal.
Installation
pip install bodycal
You could findΒ your
- BMI -Body MassΒ Index
- BMR- Basal Metabolic Rate
- body fat percentage
by using thatΒ library.
Sounds interesting right, let's check my linear model and myΒ library.
Regression Model in Weight Prediction
Conclusion
Yes, that'sΒ it.
Regression, is probably one of the most used models, like classification.
Classification A-Z Briefly Explained article is on theΒ way.
I will add the link after it will be finished.
Thanks for all your support, claps andΒ follows.
That really motivates me to create good educational content.
I love sharing my knowledge and also that's how, after many times pass, I could refresh my memoryΒ too.
βMachine learning is the last invention that humanity will ever need to make.β NickΒ Bostrom
Regression A-Z Briefly Explained was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.
Join thousands of data leaders on the AI newsletter. Itβs free, we donβt spam, and we never share your email address. Keep up to date with the latest work in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming aΒ sponsor.
Published via Towards AI