2

Is it OK to combine categorical and continuous features into the same vector for training deep neural networks? Say there is a categorical feature and continuous feature that I want to feed into a deep neural net at the same time. Is this the way to do it?

categorical feature (one-hot encoded) = [0,0,0,1,0]
continuous feature (number) = 8
final feature vector passed into neural network = categorical feature vector CONCATENATE continuous feature = [0,0,0,1,0,8]

Basically, the question is, is it OK to have a one-hot encoding and a continuous feature together in one feature vector?

makeorbreak
  • 113
  • 5
  • See also: https://stats.stackexchange.com/questions/306610/neural-network-mlp-for-regression-with-3-continuous-features-1-categorical – Sycorax Aug 01 '20 at 15:31
  • See also: https://stats.stackexchange.com/questions/139129/how-to-recode-categorical-variable-into-numerical-variable-when-using-svm-or-neu – Sycorax Aug 01 '20 at 15:31

2 Answers2

3

Yes, that is one typical way of doing it. But, you need to standardize your features so that gradient descent doesn't suffer, and the regularization treats your weights equally. One way is to standardize the numerical features and then concatenate the one-hot vectors, and the other way is standardizing together. As far as I see, there is no consensus over the two.

gunes
  • 49,700
  • 3
  • 39
  • 75
1

Yes, this is absolutely standard.

Sycorax
  • 76,417
  • 20
  • 189
  • 313