# Linear Regression

> Guessing a number with a straight line. The line is the one that best fits the data.

**Field:** Artificial Intelligence  
**Category:** Machine Learning  
**Also known as:** Ordinary Least Squares, OLS

## Think of it like

Think of it like a page of dots. You lay a ruler down the middle of them.

## Definition

Linear regression is a method that guesses a number by drawing the straight line that best fits the data. Each feature gets a weight that says how much it pushes the answer up or down. Training finds the weights that make the line miss the dots by the least. It is simple, fast and easy to explain. It works best when the real link is close to a straight line.

## Example

Jack plots flat size against rent for 300 flats. The best line says each extra square metre adds about 15 euros a month.

## Why it matters

It is often the first model to try and the one to beat. Its weights tell you plainly what moves the answer.

## Common mistake

Using it on a curved pattern. If rent jumps sharply in the city centre, a straight line misses it badly.

## Three principles

- **A straight line.** The simplest shape to fit.
- **One weight each.** How much each feature counts.
- **Easy to explain.** You can read the weights.

## Related terms

- [Regression (Machine Learning)](https://learn.benibix.com/term/ai/regression)
- [Logistic Regression](https://learn.benibix.com/term/ai/logistic-regression)
- [Model Parameter](https://learn.benibix.com/term/ai/model-parameter)
- [Gradient Descent](https://learn.benibix.com/term/ai/gradient-descent)
- [Regression Analysis](https://learn.benibix.com/term/general/regression-analysis)
- [Correlation](https://learn.benibix.com/term/general/correlation)

## Told apart from

- [Linear Regression vs Logistic Regression](https://learn.benibix.com/compare/linear-regression-vs-logistic-regression): The names make people think both guess numbers. Only one does. Linear regression gives a number on a scale, like a rent. Logistic regression gives a chance between 0 and 1 and is used for yes or no questions. So logistic regression is a classifier, despite its name.

## Taught in

- [Classification vs Regression](https://learn.benibix.com/learn/ai-machine-learning/classification-vs-regression): Machine Learning, 8/18

![Two panels. Linear regression: a straight line through dots, giving a number. Logistic regression: an S-shaped curve from 0 to 1, giving a chance, with a cut at the middle.](https://learn.benibix.com/diagrams/ml-linear-logistic.svg)

---

Source: https://learn.benibix.com/term/ai/linear-regression
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
