Machine LearningRegression Fundamentals

How does linear regression work?

Linear regression works by finding the linear relationship between input features and a continuous target that best fits the training data.

It learns coefficients for the input features and then uses those coefficients to make numerical predictions.

Basic idea

With one input feature, the model has the form:

ŷ = b0 + b1x

where:

  • ŷ is the predicted value
  • b0 is the intercept
  • b1 is the coefficient or slope
  • x is the input feature

The model tries to find values for b0 and b1 that make the predicted values close to the actual targets.

How training works

During training:

  • the model starts with candidate coefficient values
  • it generates predictions for the training examples
  • it measures the difference between each prediction and the actual target
  • it adjusts the coefficients to reduce those errors

For ordinary linear regression, the coefficients are commonly chosen to minimize the sum of squared residuals.

What is a residual?

A residual is the difference between an observed target and the model's prediction:

Residual = Actual value - Predicted value

For example:

Actual price    = 50
Predicted price = 46
Residual        = 4

The model tries to find a line that keeps these residuals as small as possible overall.

With multiple features

When several input features are used, the model becomes:

ŷ = b0 + b1x1 + b2x2 + ... + bnxn

Each coefficient represents how the prediction changes with that feature while the other included features are held constant.

Making a prediction

After the coefficients have been learned, a new observation is passed into the equation.

For example:

Predicted Price = Intercept
                + Size Coefficient × Size
                + Room Coefficient × Rooms

The result is the model's numerical prediction.

Why it is called linear

Linear regression is linear in its coefficients: the prediction is a weighted sum of the input features plus an intercept.

If the underlying relationship is strongly nonlinear and the features do not represent that shape, a basic linear model may underfit the data.

In short, linear regression learns coefficients that define a best-fitting linear relationship between the inputs and target, then uses that learned equation to predict numerical values for new observations.

#how does linear regression work#linear regression working#linear regression coefficients#linear regression residuals#linear regression prediction#machine-learning#linear-regression#regression#residuals#regression-fundamentals

Learning Sequence

Machine Learning Curriculum

45% Completed
Up NextMachine Learning

What is the equation of a linear regression model?

Explore Related Questions

Deepen your understanding across related Machine Learning topics.

Machinoai Logo
Machinoai

Your edge in the AI era. Deep dives into machine learning concepts, paper explainers, verified industry jobs, and developer tools.

© 2026 Machinoai. All rights reserved.