1
$\begingroup$

Let's say we want to predict house prices and have the following 3 features with their possible categorical values:

Slope of land property: 1) Gentle 2) Moderate 3) Severe

Type of utilities available: 1) All public Utilities 2) Electricity, Gas, and Water 3) Electricity and Gas

Style of dwelling: 1) 1s - One story 2) 1.5s - One and one-half story 3) 2s - Two story

Would it be acceptable/advantages to turn all those values into 1,2,3 integers (numerical data)? On the one hand it makes sense since e.g. 1s building is worse than 1.5s building which is worse than 2s building. On the other hand it's possible that the gap between 1s and 1.5s is much bigger than between 1.5s and 2s. How common/uncommon is this practice?

$\endgroup$
3
  • 1
    $\begingroup$ What is the problem with treating these as categorical regressors in your model? Do you have so few data that you might be worried about losing degrees of freedom? $\endgroup$
    – whuber
    Nov 10, 2016 at 21:12
  • $\begingroup$ I understand feature engineering as a way of helping the algorithm to capture the right trend of the data. For example if I try to model the relationship between money and happiness and I know that 1 mil more makes you less happier when you are rich than when you are poor I might take a log of wealth feature and help the accuracy of my algorithm. Similarly, explicitly giving my algorithm the order of my feature might improve it. But I don't really know.. I'm new to ML. $\endgroup$
    – Mariusz
    Nov 10, 2016 at 21:28
  • $\begingroup$ Search our site for methods of representing ordinal predictors. The point here is that you've very few distinct values in any case: in a regression model, say, even treating the predictors as continuous, you'd only use six degrees of freedom to represent each with a quadratic basis function - equivalent to treating them as categorical. $\endgroup$ Nov 10, 2016 at 22:34

1 Answer 1

1
$\begingroup$

There is no good reason to do this. The only this would be justified is if, as you say, the distances between categories are equal. Since you have only a few categories per variable, there is no reason to make this assumption. This may be an occasionally used practice, but that doesn't mean it's right. When you're dealing with scale scores on a survey of a psychological variable, taking the sum of many 3-category items to form a sum score might violate my previous advice, but in general it is robust to the violation of that assumption for each item. As independent variables, you should definitely retain the categories.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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