Self-paced

Explore our extensive collection of courses designed to help you master various subjects and skills. Whether you're a beginner or an advanced learner, there's something here for everyone.

Bootcamp

Learn live

Join us for our free workshops, webinars, and other events to learn more about our programs and get started on your journey to becoming a developer.

Upcoming live events

Learning library

For all the self-taught geeks out there, here is our content library with most of the learning materials we have produced throughout the years.

It makes sense to start learning by reading and watching videos about fundamentals and how things work.

Search from all Lessons


LoginGet Started

Learn Linear regression

Lessons, exercises, and projects about Linear regression

To better understand what a **linear regression** is, imagine you have a group of points on a graph. These points represent some relationship between two things. For example, they could be the hours you study and the grades you get on an exam. Linear regression tries to find a straight line that passes as close as possible to all those points. This line is called the "regression line." ## Why represent regression as a line? We use a line because it is the simplest way to show a relationship between two things. If study hours and grades are related, a line can give us a general idea of how one thing changes when the other changes. ## Basic components of linear regression 1. **Variables**: - **Independent variable (X)**: This is what you control. In our example, it would be the hours of study. - **Dependent variable (Y)**: This is what you want to predict or explain. In our example, it would be the exam grade. 2. **Line of best fit**: This line is drawn in such a way that the sum of the vertical distances from all the points to the line is as small as possible. ## Simple example Suppose you have this data: - 1 hour of study -> 60 points on the exam - 2 hours of study -> 70 points on the exam - 3 hours of study -> 80 points on the exam - 4 hours of study -> 90 points on the exam If you plot these on a graph, the points would be almost in a straight line. Linear regression would find that line that passes through these points. ## The formula of the line The regression line can be described with a simple mathematical formula: \[ Y = a + bX \] Where: - **Y** is the grade we want to predict. - **a** is the point where the line crosses the Y-axis (when X is 0). - **b** is the slope of the line, which tells us how much Y changes when X changes. ## What is it for? Linear regression is used to predict values. For example, if you want to know what grade you might get if you study for 5 hours, you can use the formula of the line. It is also used to understand the relationship between two variables.

What is a Linear Regression and how to use it in machine learning models

Discover the power of linear regression, a model that predicts outcomes based on one or more variables. Learn about its five key assumptions and how it can help you understand relationships between data points. Dive into simple and multiple linear regression to enhance your data analysis skills.

2hrs average

Learn how to build a linear regression model from scratch: understand a new dataset, perform exploratory data analysis (EDA), model the data, and optimize your model. Discover how the $R^2$ evolves by adjusting the Lasso model's hyperparameter up to a value of 20.