Solved – Can constant and time-dependent features be mixed

feature selectionfeature-engineeringmachine learningneural networkssvm

Suppose I'm trying to perform supervised classification on a list of birds into either nocturnal or diurnal. The only features I have regarding each bird are

  • its wingspan (float),
  • its colour (multi-class: white, brown, red, yellow, blue, green, black),
  • its diet (binary: carnivore or not),
  • its habitat (multi-class: ocean, river, mountain, desert), and
  • a sound recording of their call/song (time series of floats)

Let's say I want to use a neural network. A feed-forward neural network will work just fine for the first four features. (The wingspan will simply be one of the nodes in the input layer whereas colour, diet, and habitat will be decomposed into several input nodes, presumably via one-hot encoding.)

However, how shall one deal with the last feature, namely the recording of the bird sounds? If this were the only feature, the natural choice would be a recurrent neural network (RNN), but then what should one do with the first four constant features? Clearly, copying them at each recursion of the RNN is both redundant and contrary to the "spirit" of RNNs since, for example, the colour of the bird isn't expected to change from one sound bit to the next.

In other words, how does the architecture of the neural net account for such mixed features? (The same question applies to other classifiers such as support vector machines.)

Best Answer

If you want to use RNNs, just modify the architecture a bit: plug the time series into a few layers of LSTMs or whatever you'd like to use, and then concatenate the resulting hidden states and the discrete features you have into a softmax layer that produces predictions. So, your computational graph would look like this: enter image description here

Alternatively, there is no rule saying you can't include those constant features as input to the RNN.