# Fitting a Line

A straight line through a scatter plot of home sales turns a home's size into a price guess, the intercept plus the slope times the size, and least squares picks the best line, the one whose squared errors add up to the least, which Python's statistics.linear_regression finds for you.

![Cheat sheet: Fitting a Line](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/f8d25a53369043f6ad8982f3e211ac34.webp)

- Category: Machine Learning
- Level: Apprentice
- Tags: ai, Intercept, Linear Regression, Ordinary Least Squares, python, Slope
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/ml-fitting-a-line-cheat-sheet
