Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Read by thought-leaders and decision-makers around the world. Phone Number: +1-650-246-9381 Email: [email protected]
228 Park Avenue South New York, NY 10003 United States
Website: Publisher: https://towardsai.net/#publisher Diversity Policy: https://towardsai.net/about Ethics Policy: https://towardsai.net/about Masthead: https://towardsai.net/about
Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Founders: Roberto Iriondo, , Job Title: Co-founder and Advisor Works for: Towards AI, Inc. Follow Roberto: X, LinkedIn, GitHub, Google Scholar, Towards AI Profile, Medium, ML@CMU, FreeCodeCamp, Crunchbase, Bloomberg, Roberto Iriondo, Generative AI Lab, Generative AI Lab Denis Piffaretti, Job Title: Co-founder Works for: Towards AI, Inc. Louie Peters, Job Title: Co-founder Works for: Towards AI, Inc. Louis-François Bouchard, Job Title: Co-founder Works for: Towards AI, Inc. Cover:
Towards AI Cover
Logo:
Towards AI Logo
Areas Served: Worldwide Alternate Name: Towards AI, Inc. Alternate Name: Towards AI Co. Alternate Name: towards ai Alternate Name: towardsai Alternate Name: towards.ai Alternate Name: tai Alternate Name: toward ai Alternate Name: toward.ai Alternate Name: Towards AI, Inc. Alternate Name: towardsai.net Alternate Name: pub.towardsai.net
5 stars – based on 497 reviews

Frequently Used, Contextual References

TODO: Remember to copy unique IDs whenever it needs used. i.e., URL: 304b2e42315e

Resources

Unlock the full potential of AI with Building LLMs for Productionβ€”our 470+ page guide to mastering LLMs with practical projects and expert insights!

Publication

Regression A-Z Briefly Explained
Latest

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

Photo by charlesdeluvio onΒ Unsplash

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

Image byΒ Author

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

Image byΒ Author

Let's suppose our function isΒ ;

Image byΒ Author

Then our graph will beΒ ;

Image byΒ Author

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.

Image byΒ Author

Variables

y = predicted value

n = number ofΒ features

ΞΈ = model parameter

x =Β features

Graphic

Image byΒ Author

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

Image byΒ Author

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

Image byΒ Author

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.

Image byΒ Author

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

Image byΒ author

Graph

Image byΒ Author

Variables

y = predicted value

n = number ofΒ features

ΞΈ = model parameter

x =Β features

Quadratic Function

That is a simply functions with powers(x**2)

Function

Image byΒ Author

Variables

y = predicted value

a = intercept

ΞΈ = model parameter

x =Β features

Graph

Image byΒ Author

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.

Image byΒ author

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

Feedback ↓