Definition
DEF
Cost function (also called loss function) is a mathematical function that measures the difference between a model’s predicted output and the actual output. The goal of training is to minimize this value.
Formula for Cost Function
where:
- → the cost function
- → number of training examples (all the points)
- → the hypothesis function (model’s prediction)
- → input and actual output of the training example
This is also called the Squared Error Function (SEF) i.e. the column in SMLP.
Why ?
- Divided by → to find the average (mean) value
- Divided by → makes derivation cleaner
eg: (since ) but since it’s divided by 2, it becomes
Note
In SEF, squaring is done so we don’t get any negative values.
Warning
In linear regression, the cost function is the Mean Squared Error (MSE), or SEF divided by and not to be confused with SEF alone:
solving of cost func
minimize -> by adjusting the
Step 1 :
Calculation: So if ,
here, no since its equal to 0