# what is the difference between euclidean distance and RMSE?

I'm searching for a loss function that fits my Project. Actually I have two question but they are in the same direction. I take a look at the definition of the root mean squared error and the euclidean distance and they look the same to me! that's why I want to know what's the difference between the two. what would be the difference if I use rmse as a loss function or the euclidean distance??

the second question is how to search for a loss function. I mean I know it depends on the problem and commun things are MSE for Regression and Cross entropy for Classification but let's say I have a specific problem, how do I search for a loss function? I also saw that some people use a custom loss function and most of the deep learning frameworks allows us to define a custom loss function but why would I want to use a custom one? how I get the intuition that I need a custom loss function?

now to explain my problem. I'm doing a project where I need to reduce the GPS Error of a vehicle (I have some vehicle data and my neural network will try to predict the longitude and latitude so it's a regression problem) that's why I get the Idea of maybe the euclidean distance would make sense as a loss function, right? now somehow MSE also make sense to me because it is getting the difference between prediction and ground truth. does this make sense to you as a professional ML Engineer or Data scientist ? and if there would be a custom loss function that you can use, what would you suggest and why?

Let's say that RMSE and euclidean distance are not of the same type, even though their formulations are close. RMSE is a loss function, while euclidean distance is a metric. See this question on Cros Validated to better understand the difference between a loss function and a metric: a loss function is generally based on a reference metric.

Euclidean distance is a metric, so it quantifies the distance between two observations. RMSE is, as the name suggests, the root of the mean of the squared error between a true value and a predicted value, over a range of observations. RMSE is generally intended for model performance assessment.

Your confusion probably comes from the fact that, if you apply the RMSE formula to your set of coordinates (longitude and latitude), it gives the euclidean distance. But this would not be called RMSE in that case, rather euclidean distance.

In your case, you may use the RMSE of euclidean distance as loss function. The error made by your predictor is the euclidean distance, and your loss function would be the RMSE of these errors.

Defining a loss function is strongly problem-specific. First, you need to determine which metrics to use as error function. In your case, the euclidean distance between the actual position and the predicted one is an obvious metric, but it is not the only possible one. For instance, you could use the squared or cubed euclidean distance in order to give more weight to cases that are not well predicted. You could also design an ad-hoc metric to consider:

• assymmetry, e.g. to be more tolerant on errors towards the east side than the west side
• anisotropy, e.g. to be more tolerant on errors in the latitude axis than the longitude
• uncertainty tolerance, e.g. error is null if the euclidean distance is less than a tolerance, and is equal to the euclidean distance otherwise
• etc. (depending on your problem)

The subsequent metric will allow you to evaluate the performance of the trained model over a test set, and will therefore give you a disitrbution of errors. You need to shrink this distribution to a single scalar value used as global model performance: you can pretty much choose any scalar that represents something about the distribution:

• Mean squared error (MSE) or its root (RMSE) - MSE is faster computed but RMSE has the advantage or having the same dimension as the error function (a distance in your case)
• Other types of $$\mathcal{L}_p$$ norms (RMSE is the $$\mathcal{L}_2$$ norm)
• Any quantile of the distribution (median, 75%, 95%, maximum value)
• Whatever you think is relevant!

Euclidean distance simply refers to a metric of a specific type (a line between two points in a Euclidean space). Whereas RMSE is an error function for a specific purpose (the square root of the average squared distance between the actual score and the predicted score).

Where you may be getting confused is that RMSE is an example of a Euclidean distance between two regressions by averaging they specific vector errors over a whole regression, see here for a more in depth summary.

To summarise, RMSE is a type of Euclidean distance, but there are others.

The rest of your question of a specifc loss function for your problem, like you said, is very problem specific. I suggest posting a specific question with more details of your specific problem and solutions you've considered (need more details than above) to try and find a good loss function.

Hope that helps.