Skip to content

ML Models & Algorithms

Linear Regression

In shortLinear regression is a supervised model that predicts a number by fitting a straight line through your data, such as clicks against average position.

Updated 25 Oct 2026· 3 min read

Linear regression is a supervised learning model that predicts a number by fitting a straight line (or, with several inputs, a flat plane) through your data. It is the simplest member of the regression family: given inputs such as month or average position, it estimates an output such as sessions or click-through rate. Because every input gets one readable weight, it is usually the first model to try and the baseline that more complex models have to beat.

How it works

With one input, the model learns an equation of the form y = b + w × x. The intercept b is the predicted value when x is zero, and the slope w is how much y changes for each one-unit increase in x. With several inputs, called features, each one gets its own weight. Training finds the weights that minimise the squared differences between predicted and actual values, a method called ordinary least squares, which is what scikit-learn’s LinearRegression implements.

MLforSEO’s introductory course places it inside the regression task: supervised learning with a continuous target, such as forecasting website traffic or sales trends. Its close relative, logistic regression, uses the same weighted sum but passes it through a sigmoid function to output a class probability, so it is a classification model despite its name.

Fit is usually reported with R squared (the share of variation the model explains) and an error measure such as mean absolute error, checked on data the model did not see during training (see train/test split).

How it’s used in SEO and marketing

  • Trend estimation: fitting clicks or sessions against time to see the underlying direction, the regression-based forecasting our ML data characteristics lesson mentions for traffic and rank-tracking data.
  • CTR curves: modelling how click-through rate changes with average position in your own Search Console data. The relationship flattens lower down the page, so position is usually transformed first (for example onto a log scale).
  • Spend and conversions: a first estimate of how conversions move with budget across channels.
  • Content analysis: checking whether a page attribute, such as word count or internal links, is associated with performance, with the weight showing direction and size.
  • Baselines: a random forest or gradient boosting model should beat a linear model on held-out data before you adopt it.

Example

You export twelve months of Search Console data for one site section, with average position and CTR for each query. Plotting CTR against the log of position gives a roughly straight downward line, so you fit a linear regression to it. The slope tells you how much expected CTR falls per step down that scale, and the fitted line gives an expected CTR for every query. Queries sitting well below the line, earning fewer clicks than their position predicts, go on the shortlist for title and snippet rewrites.

Limitations and things to watch

  • It assumes a straight-line relationship. Curved patterns need transformed features or a different model.
  • Traffic has seasonality, trend breaks and algorithm updates. A single line through dates ignores all of them, so use time series forecasting methods for real forecasts.
  • Outliers, such as one viral day, pull the line hard because errors are squared.
  • Strongly correlated inputs, such as impressions and clicks, make individual weights unstable. Regularised versions (ridge and lasso) help.
  • Weights describe association in your data. A link between word count and rankings does not mean adding words will lift rankings.

Learn it on MLforSEO

Where Linear Regression shows up on MLforSEO

Sources and further reading

Other terms from ML Models & Algorithms

See all 55 ML Models & Algorithms terms →