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

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay