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:
- Alpha represents the intercept point with axis y
- Beta represents the slope
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
Challenge
EasyCreate 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 hereAll lessons in Introduction to Machine Learning
6Other Models
Logistic RegressionLinear RegressionDecision TreeSupport Vector Machine (SVM)Models quiz