Search code examples
deep-learningneural-network

Feature engineering: Best way to feed a 360° orientation variable into a neural network


A predictor (X) variable could be an orientation variable on a 360° scale.

Obviously, it is a continuum, the value 360 being very close to 1. Inputing a continuous variable from 1 to 360 into the neural network would thus introduce bias.

What would be the best way to handle this ?

  • One way could be to categorizing the values (1 to 360) into categories: North - NorthEast - East - EastSouth - South - SouthWest - West - WestNorth.

Any other suggestions or comments?


Solution

  • By expressing your feature as 2 dimensions, instead of one you can easily avoid this problem - simply push it through cosine and sine, this way you change your angle into a point on a unit circle.

    f(a) := [cos(a), sin(a)]
    

    Note that we now have f(0) = f(2*pi) = f(4 * pi) and so on. Note that this is in radians, if you are using degrees you want to do instead

    g(d) := f(d/180 * pi)