# Encoding "histogram bins"

I am currently working on a regression problem where I have one variable (x) of the data in the form of "histogram bins". I.e. I could have value ranges 900-999, 1500-1599 etc. However the data does not tell you the specific value.

My question is: In this situation, should I treat this variable as real-valued (maybe take the median of each bin)? Or should I treat it as categorical data with each 100-wide bin representing a separate category? If I do treat it as categorical, what would be the best encoding (Label, 1-hot, etc.)?

My confusion comes from the fact that even though the data as presented is categorical, it is morally a real-valued variable. I also have prior knowledge that my target variable y should have a positive correlation with x. So if I just went with an arbitrary encoding, would it be able to capture this correlation?

• What type of model do you use? Linear regression, random forest etc.? Sep 4, 2021 at 20:31
• I'm trying all the most common models (linear regression, random forest, knn etc.) and comparing them. Sep 4, 2021 at 20:33