DEV Community

Muhammad Sahim Bhaur
Muhammad Sahim Bhaur

Posted on

Square Mean Error vs. Log Loss

Overview of cost functions

These two functions are used to calculate the loss and then the cost of our models.

Loss being the difference between our predictions and ground labels for an instance while cost being the average sum of differences from our predictions.

The following are the few over arching differences

Comparison of Square Mean Error (SME) and Log Loss functions.

Formula's of each function

Square Mean Error

loss=12(y^y)2loss = \frac{1}{2}(\hat{y}-y)^2

Log Loss

loss=((y)logy^+(1y)log(1y^)) loss = - ( (y)\log{\hat{y}} + (1-y)\log{(1-\hat{y})} )

Let's see the two functions in action:

y y_hat LOG LOSS SME
0.1 0.9 2.08 0.64
0.2 0.8 1.33 0.36
0.3 0.7 0.95 0.16
0.4 0.6 0.75 0.04
0.5 0.5 0.69 0.0
0.6 0.4 0.75 0.04
0.7 0.3 0.95 0.16
0.8 0.2 1.33 0.36
0.9 0.1 2.08 0.64

Top comments (0)