Ultimate Secret of Cost Function. 😎

the secret of model’s accuracy. 📕

OneHotCoder
2 min readDec 19, 2021
Photo by Isaac Smith on Unsplash

What is Cost Function ?

The 🔵 blue line on the left fits the data nicely for θ values 4 and 5x10⁵ compared to lines 📗green and 🔴red.

How can we know which values of theta(θ) will make our model perform best ?

In order to answer our above question we need some performance function which measures how good or bad our model is performing.

“Cost Function measures how bad our model is performing.”

💭How to find Cost Function ? 😄

📃Types of Cost Function:

Linear Regression :

Linear Regression Cost Function is given by distance between the models prediction and training samples. There are mainly two main types of regression cost function

→Mean Absolute Error (MAE) :

The sum of differences between actual and predicted values.

Mean Absolute Error

→Mean Squared Error (MSE) :

The sum of square of differences between actual and predicted values

Logistic Regression:

Logistic Regression’s Cost Function (Log Loss) tries to capture the value of θ for which the model predicts high probability for positive instances and is given by:

where p̂ → probability of instance being true

--

--