Regression
Linear regression theory
Model
For linear regression, the hypothesis will be a linear equation with any amount of features. This can be univariate or multivariate linear regression:
The goal in linear regression is to minimize the squared error consisting of all the data points:
Loss functions
We have several choices of loss functions for linear regression:

Univariate linear regression
Evaluating the model
Coefficient of determination
We need some way to evaluate how well our model does and you can do that either with loss or something in statistics called the coefficient of determination, which only works in two-dimensional data (features X and output y).
- coefficient of determination: denoted via , and has bounds .
- use case: used as a measure of correlation strength between two variables
- correlation coefficient: denoted by , which is just the square root of the coefficient of determination, and has bounds .
-
use case: used as a measure of correlation strength
-
NOTE
The null model is just predicting the mean, which means that the null model has an value = 0
Null model
In linear regression, the Null Model is the simplest possible baseline. It assumes that the features () have no predictive power, so it simply predicts the mean () of the target variable () for every observation.
- Equation:
- Purpose: It serves as a benchmark. If your regression model isn't better than the null model, your features are not useful.
The null model will just predict that every point is equal to the mean, giving a straight line. Then from there, we can get the coefficient R^2, which is the coefficient of determination.
You can also think of it like this:
Logistic Regression
Problem and intuition
Model
Logistic regression is used for classification tasks, but like regression, it also outputs a single number.
The hypothesis uses the sigmoid function to make sure all probability outputs are between 0 and 1.