It seemed to me your data are organized as follows, each line you have the record of a single variable in 4 sequential moments of time, the Q_t is the value you want to predict based on the sequence of the last 3 values of it Q_t_1, Q_t_2, Q_t_3.
Therefore, you have such a configuration:
n_samples <- nrow(data)
timesteps <- 3
n_variables <- 1
To adjust the data properly for training, you have to create a three-dimensional array. Then, you can iterate over the original dataset and allocate the values within the sample array by sample.
data_X <- array(NA, dim=c(n_samples, timesteps, n_variables))
data_Y <- array(NA, dim=c(n_samples, 1, 1))
for(i in 1:n_samples){
data_X[i,,1] <- unlist(data[i, c("Q_t_1", "Q_t_2", "Q_t_3")])
data_Y[i,,1] <- unlist(data[i, "Q_t"])
}
If you had one more variable, say R_t_*, it would be in `data_X[i,,2] and so on.
To perform the training, follow the same tutorial you mentioned, except that now seq_to_seq_unsync
must be TRUE
, due to the model having to return a single value from the input sequence. Different from the tutorial where the template returns a sequence of same size as the input.
model <- trainr(Y=data_Y, X=data_X, hidden_dim=100,
learningrate=0.1, batch_size=1, numepochs=100,
seq_to_seq_unsync=T)
plot(colMeans(model$error), type="l")
# predita sobre o conjunto de treinamento
data_H <- predictr(model, data_X)
# compara o valor com real com a hipótese
head(cbind(data_Y, data_H))
If that’s what I’m thinking of your question, it’s about how to get the data for training. You have variables that keep the time record, 10 days, so the dimensions of your input is X=(n_samples, 10, 3) , and Y=(n_samples, 10, 1). You need to organize the instantiated dataset array and configuring the dimensions in dim.
– Rafael Toledo
can make an example code?
– Artur_Indio
share your data that after I exemplifco for you, can use the
dput
for that, put them in your question.– Rafael Toledo
OK, I put my data with hyperlink.
– Artur_Indio
The values of your data came all zero, I created some random, for example should serve.
– Rafael Toledo
@Rafaeltoledo ok, I’ll test and give you a feedback.
– Artur_Indio