Linear Regression

Linear regression is a simple machine learning model that predicts a number by fitting a straight line through the data, assuming the output changes proportionally with the inputs.

Data & AI

It finds the line (or, with multiple features, the flat surface) that best fits the points by minimizing the squared distance between predictions and actual values. The result is an equation like price = a + b * size.

It's often the first model people learn because it's easy to understand and interpret: each feature gets a weight (coefficient) showing how much it pushes the prediction up or down. Despite its simplicity, it's widely used in practice.

Examples

Python

from sklearn.linear_model import LinearRegression

model = LinearRegression().fit([[1], [2], [3]], [3, 5, 7])
print("slope:", round(model.coef_[0], 1),
      "intercept:", round(model.intercept_, 1))

Output:

slope: 2.0 intercept: 1.0

Learn it in a lesson

See also

Back to the Dictionary