# How to convert regression into classification?

So I have a regression problem with bunch of features X, and labels in the amount (price \$). How can I convert it to classification problem? I have read about convert label from continuous to categorical possibly thesholding at some points for instance 0-50 (0 class) 51-100 (1 class) and so on till 500 maybe (here thresh-holding to 50). This approach is ineffective intuitively i.e no data lay 51-100. Is there any way to mitigate this problem or if there is any effective way to do this? Like in clustering we can use density estimation can we do that here?

• You want convert task of predicting the price into a classification task? Jul 29 '20 at 6:22
• There is no standard method, one can always turn regression into classification using a bunch of different criteria and heuristics. It depends on your data and problem at hand Jul 29 '20 at 6:54

To add to the number of methods you can use to convert your regression problem into a classification problem, you can use discretised percentiles to define categories instead of numerical values. For example, from this you can then predict if the price is in the top 10th (20th, 30th, etc.) percentile. These values you can easily find out using Python's numpy.percentile(X[i], percentile) method, for example.
The task you are converting is not actually classification per se, it's ordinal classification. I am pointing this out cause there are implementations that specialise in this matter. Moreover, the task you are asking is how to properly bin the values. For that, you can refer to binning as a pre-processing step. I am sure if you search for "binning python" for instance, you will find various implementations.