I am using a custom algorithm based on Gradient descent which computes the best fit on a training dataset. In this data set I have outliers i.e. data points that I do not want to fit. The algorithm is doing a good job in itself not fitting this data. However I want to quantify this 'goodness' with a statistical measuring technique.

I know that R squared is the most popular for regression, however I think that it is not the right approach for me. After trying r squared I am getting very low values because my algorithm is not fitting outliers which r squared does not take into account. rsquared does not know that I have outliers which the algorithm is on purpose not fitting with the rest of the data.

Is there another approach to this? maybe a different algorithm, or some changes I can make to r squared?

  • 1
    $\begingroup$ Maybe mean square error? $\endgroup$ Jul 19, 2018 at 16:16
  • $\begingroup$ still gets a very high value for that. I would say mean absolute error is better. what so you think about that? @AdrianKeister $\endgroup$ Jul 19, 2018 at 16:30
  • $\begingroup$ When you say it has a high value: do you have a baseline? Mean absolute error might be great; no harm in trying it. $\endgroup$ Jul 19, 2018 at 16:38
  • $\begingroup$ @AdrianKeister I cannot really get a baseline right? having a baseline suggests that I already know what a good fit is. $\endgroup$ Jul 19, 2018 at 16:45
  • $\begingroup$ Do you have a different data set where you have a good fit? $\endgroup$ Jul 19, 2018 at 17:11

1 Answer 1


When you mention that your model does a good job in fitting the data (and not the outliers), I am assuming you are taking a look directly into actual vs predicted (or fitted) values. While doing this, you do not look for comparisons for outlier observations.

Similarly, you could still calculate the R squared by removing the outlier observations from the calculation, and it could still serve as a measure for goodness of fit. There is sufficient documentation available on how to do this manually (by hand) so you can write a function to do this by yourself.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.