TransWikia.com

How to convert regression into classification?

Data Science Asked by Nauman Akram on October 1, 2021

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?

3 Answers

Since your output is one dimensional, clustering the output is equivalent to fixing thresholds. The best you can do is use field knowledge to distinguish the different classes. You can also plot the histogram of the log of your price and see if there is a mixture of gaussians and try to seperate them into classes.

Answered by mirimo on October 1, 2021

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.

This type of labelling will place thresholds with respect to the distribution of the data.

Answered by shepan6 on October 1, 2021

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.

Answered by 20roso on October 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP