I'm trying to build an RNN in Mathematica. My window is only 2 but the variables are of different types:

{{"ch1" -> "525", "status" -> "P12", 
"Input" -> {0.005025125628140704`, 0.19`, 0.6869485330621257`, 
 9990.`, 1.`}}, {"ch1" -> "4432", "status" -> "K65", 
"Input" -> {0.01507537688442211`, 0.19375`, 0.7444255226482255`, 
 10045.`, 1.`}}} -> "Output" -> 0.

As you see, I labeled the variables, I know how to encode them, but I have no idea how to put them in an RNN model. I know that if the input was all numeric I could have just set "Input"->[2,3] but what happens when one has other type of input variables?

Any help will most appreciated.


To build an RNN model with multivariate variables to first deal with categorical variables as follows:

         enc = NetEncoder[{"Characters", {GetLevels[1], GetLevels[2], 
            GetLevels[3], GetLevels[4], pays, pays, pays, GetLevels[8], 
            GetLevels[9], GetLevels[10]}}]

Getlevels function just gets the levels (classes)

Than I combined the results of the encoding with my numerical variables

      Map[Flatten[List[enc[#[[1 ;; 10]]], #[[11 ;; 15]]]] &, dataTrain]

Finally, I partitioned the dataset into a window of size N (which can be chosen by you)

Note, I made sure to scale, or center my numerical variables. I use "Characters" because my categorical variables levels change through time, so I cannot use "Class". Furthermore, the levels are a concatenation of codes (which I don't know)

|improve this answer|||||

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.