> For the complete documentation index, see [llms.txt](https://machine-learning.paperspace.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://machine-learning.paperspace.com/wiki/linear-regression.md).

# Linear Regression

![Source: Wikipedia ’Linear Regression’](/files/-Lw6knp2_7o5GuRQ3uYi)

Linear regression is an algorithm (belonging to both statistics and machine learning) that models the relationship between two or more variables by fitting a linear equation to a dataset.  Independent variables are the features (input data) and dependent variables are the target (what you are trying to predict). &#x20;

The technique is very simple and can be represented by this familiar equation:

![](/files/-Lw6reDg0_e8LuhuCJSF)

However, this is typically written slightly differently in machine learning:

![](/files/-Lw6utnYPHwHu1RxZtdz)

Or for a more advanced model with multiple features:

![](/files/-Lw6v80B-XE72FhKq2YQ)

Where:

* *y* is the predicted label
* *b* is the bias (the intercept)
* *w1* is the coefficient or weight of the first feature (weight = *m* or slope)
* *x1* is a feature (an input)<br>

Like [logistic regression](/wiki/logistic-regression.md), [gradient descent](/wiki/gradient-descent.md) is typically used to optimize the values of the coefficients (each input value or column) by iteratively minimizing the loss of the model during training. &#x20;

**Mean squared error** and **mean absolute error** are common [loss functions](/wiki/accuracy-and-loss.md#loss) for linear regression.

**Regularization** is a technique used to prevent [overfitting ](/wiki/overfitting-vs-underfitting.md)by penalizing signals that provide too much explanatory power to a single feature. &#x20;

### Linear vs Logistic Regression

**Linear regression** predictions are continuous (e.g. test scores from 0-100).

**Logistic regression** predictions classify items where only specific values or classes are allowed (e.g. binary classification or multiclass classification). The model provides a probability score (confidence) with each prediction.
