Linear regression
Linear regression is a statistical and machine learning method that predicts a number by fitting a straight-line relationship between one or more inputs and an outcome.
Linear regression draws the best straight line through data. With one input, the model is prediction = bias + weight × input: the weight is the slope and the bias is where the line crosses the axis. With several inputs, each gets its own weight. Training finds the weights and bias that fit the examples best, most often by least squares, which picks the line that makes the sum of squared errors as small as possible.
Google's Machine Learning Crash Course uses cars. Plotting fuel efficiency against weight gives points sloping downwards, and the fitted line has a bias of 34 and a weight of minus 4.6, with weight measured in thousands of pounds. For a 4,000 pound car the model predicts 34 minus 18.4, or 15.6 miles per gallon. Adding engine size, horsepower and other features gives each one its own weight.
The method is old. Adrien-Marie Legendre published least squares in 1805 and Carl Friedrich Gauss in 1809, both using it to work out orbits from astronomical observations. The name comes from Francis Galton's 1886 study of parents' and children's heights, which found children's heights sat closer to the average than their parents', a pattern he called regression towards mediocrity.
Linear regression remains a standard first model because it is fast and easy to read: each weight says how much the prediction changes for one unit of that input, with the others held fixed. Its limits are equally clear. It only captures straight-line relationships unless the inputs are transformed first. When inputs are strongly correlated with each other, individual weights become unreliable. And on observational data it cannot prove cause and effect, because a confounding factor may have been left out.
The same calculation sits inside far larger systems. A single artificial neuron in a neural network computes a weighted sum of its inputs plus a bias, exactly what linear regression computes, before applying an activation function. Stacking millions of these, with activation functions between them, is what lets neural networks fit curves that a single straight line cannot.
It is used to predict a number, such as a price, a demand figure or fuel efficiency, from one or more inputs, and to measure how strongly each input relates to the outcome. It is common in economics, science, business forecasting and as a baseline in machine learning. Yes. It began in statistics, but it is also a supervised machine learning model: it learns its weights and bias from labelled examples and then predicts outcomes for new inputs. Linear regression predicts a continuous number. Logistic regression predicts the probability of a yes-or-no outcome by passing a linear combination of inputs through a sigmoid function, which keeps the output between 0 and 1. It is the standard way to fit a regression line. It chooses the weights that make the sum of the squared differences between predicted and actual values as small as possible. Squaring the errors punishes large misses more than small ones.Common questions
What is linear regression used for?
Is linear regression machine learning?
What is the difference between linear and logistic regression?
What is least squares?
Search for "simple linear regression", "ordinary least squares" or "regression assumptions" for the method and its limits. Reliable sources include university statistics courses, the documentation of libraries such as scikit-learn and statsmodels, and introductory courses such as Google's Machine Learning Crash Course. Be careful with any analysis that treats a regression weight as proof of cause and effect without an experiment or a careful design behind it.Finding more
Working out what this means for your business?
Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.