# Which loss function could I use to solve a regression problem as a classification problem (where we discretize the labels into buckets)?

I am considering a rather typical regression problem, but, for practice, I am trying to implement this as a classification problem.

The setup is as follows. I have $$\mathbb{R}$$-valued labels $$y_i \in [-1,1]$$, which I then discretize to $$N$$ buckets -- my classification problem is to then predict the labels to the nearest bucket.

This is rather straightforward and easy to implement with a cross-entropy loss function. However, I do not believe that this is the best option, as I would ideally like my predictions to be close to their correct bucket, even if I do not predict them correctly (which will be more difficult as if I take $$N$$ larger).

My current approach involves using a mean-squared error loss function. My network outputs logits for each bucket, I apply a softargmax (so the network remains differentiable) and then convert the output of the network into the $$\mathbb{R}$$-valued prediction.

My (very premature) results are nothing to write home about. So, I ask, is there a more natural loss function that I could consider for this exercise?

• What code are you using ? share what you have tried May 27 '21 at 9:47
• This is called ordinal regression, which could be a term to search, but binning tends to be discouraged.
– Dave
Aug 17 '21 at 18:57