josejimenezluna / nnet-ts

Neural network architecture for time series forecasting.
Other
108 stars 27 forks source link

Extending the class to handle multivariate time-series #2

Closed dandxy89 closed 6 years ago

dandxy89 commented 9 years ago

Can this module be extended to handle for multi-variate time series?

dandxy89 commented 9 years ago

I've managed to amended the first part of the fit function to allow for mulit-variate time series however it wasn't till I got to the predict function that I am restricted to only forecasting one period ahead. Any suggestions how I might get around this?

Adjusted lines have been numbered below.

1 - self.shape_width = self.timeseries[1].size
2 - self.X = np.zeros((self.n - self.lag, self.lag*self.shape_width), dtype = "float64")
3 - self.y = np.log(self.timeseries[self.lag:, response_var])

print "Building regressor matrix"
# Building X matrix
for i in range(0, len(self.timeseries) - self.lag):
4-      for j in range(0, self.shape_width):
5-              self.X[i, range(0 + j*self.lag, self.lag + j*self.lag)] = self.timeseries[range(i, i + self.lag),j]
josejimenezluna commented 9 years ago

Multivariate series extension is planned for nnet-ts 0.8 (a month from now or so). The idea is to consider a regressor matrix with unequal lags for each covariate and then fitting p deep neural nets. The plan for this is to write a separate class 'MTimeSeriesNnet' or similar for efficiency issues.

Another approach I'm currently testing (so far without luck) is to consider a neural net that outputs the dimension of the multivariate time series, but this raises the issue of having to consider some type of multivariate loss function.

In the meantime, you could construct the regressor matrix by yourself, using the lags you want to consider for each covariate (you could nnet-ts code for guidance) and then using standalone keras to fit your model. Then you'd have to include the predictions for each univariate time series in their respective lags.

Also, the predict method will be deprecated in nnet-ts 0.7 in favour of predict_ahead.

vinayakumarr commented 8 years ago

hi, has anbody able to do do multivariate timer series successfully?

dandxy89 commented 6 years ago

Please close this issue.