Menu
CoddyTech

Linear Regression

Lesson 16 of 19 in Coddy's Introduction to Machine Learning course.

Linear Regression is one of the most fundamental algorithms in machine learning for predicting a continuous variable. It's the go-to method for estimating the relationships between variables and forecasting. Whether you're predicting house prices, stock market trends, or temperatures, linear regression can provide insight into how these variables correlate.
 

Source: wikipedia

Linear regression attempts to model the relationship between two or more variables by fitting a linear equation to observed data. One variable is considered to be an explanatory variable (independent), and the other is considered to be a dependent variable.
The simplest form of the linear regression equation with one dependent and one independent variable is defined as follows:

y=\alpha+ \beta x
  • Alpha represents the intercept point with axis y
  • Beta represents the slope
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

challenge icon

Challenge

Easy

Create a function named linear_equation that takes a list that represents a data point and a list that represents the coefficients of the linear equation. 

the function returns the output of the linear equation.

 

For example

  • if n = 2, then the number of coefficients is two: y = b[0] + b[1]*x[1]
  • if n = 3, then the number of coefficients is three: y = b[0] + b[1]*x[1] + b[2]*x[2]

 

Try it yourself

def linear_equation(coef, x):
    # Write code here

All lessons in Introduction to Machine Learning

Practice on your own: Online Python compiler