What Are L1 and L2 Loss Functions?

Authors
  • Amit Shekhar
    Name
    Amit Shekhar
    Published on
What Are L1 and L2 Loss Functions?

I am Amit Shekhar, Co-Founder @ Outcome School, I have taught and mentored many developers, and their efforts landed them high-paying tech jobs, helped many tech companies in solving their unique problems, and created many open-source libraries being used by top companies. I am passionate about sharing knowledge through open-source, blogs, and videos.

Join Outcome School and get high paying tech job: Outcome School

Before we start, I would like to mention that, I have released a video playlist to help you crack the Android Interview: Check out Android Interview Questions and Answers.

In this blog, we will learn about the L1 and L2 Loss functions.

L1 vs L2 Loss Function

L1and L2 are two loss functions in machine learning which are used to minimize the error.

L1 Loss function stands for Least Absolute Deviations. Also known as LAD.

L2 Loss function stands for Least Square Errors. Also known as LS.

L1 Loss Function

L1 Loss Function is used to minimize the error which is the sum of the all the absolute differences between the true value and the predicted value.

l1 loss function

L2 Loss Function

L2 Loss Function is used to minimize the error which is the sum of the all the squared differences between the true value and the predicted value.

l2 loss function

How to decide between L1 and L2 Loss Function?

Generally, L2 Loss Function is preferred in most of the cases. But when the outliers are present in the dataset, then the L2 Loss Function does not perform well. The reason behind this bad performance is that if the dataset is having outliers, then because of the consideration of the squared differences, it leads to the much larger error. Hence, L2 Loss Function is not useful here. Prefer L1 Loss Function as it is not affected by the outliers or remove the outliers and then use L2 Loss Function.

Watch the video format: L1 and L2 Loss Functions in Machine Learning

That's it for now.

Thanks

Amit Shekhar
Co-Founder @ Outcome School

You can connect with me on:

Follow Outcome School on:

Read all of our high-quality blogs here.