4
$\begingroup$

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.

$\endgroup$
1
  • 1
    $\begingroup$ RNN ? Recurrent neural network? Answering your own question is a good way of documenting and sharing solutions you have found, but I would put more effort into making the question and answer more understandable for the average reader. $\endgroup$
    – rhermans
    Commented Sep 1, 2021 at 8:55

1 Answer 1

1
$\begingroup$

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)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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