I am using Keras to do a machine learning task:

Let's say I want to predict the time that a user spends on a product page. Each training case is a partial user visit session. One single user may have multiple sessions. The lengths of sessions are variable.

The figure shows a user session. Xn is the feature vector of the nth product page, while yn is the user's reading time on the product page. Given the previous time steps, I want to predict the time that the user will spend on the current page.

For example, in the test dataset, given X1, X2, and y1, I want to predict y2. Then after observing actual y2, given X1, X2, X3, and y1, y2, I then predict y3. The key here is that this is like an online prediction: At t=3, the actual y1 and y2 is already observed. So the observed values, not the predicted ones, are used to predict y3

enter image description here![figure

My question:

Given this tutorial, I am not sure whether my case should be 'many to one' or 'many to many'.

enter image description here

If 'many to one', there is nowhere to put y1 and y2. I think y1 and y2 should be able to partially determine y3. It is possible to add y1 and y2 as one input feature in X1 and X2. But there is no way to build X3 because y3 is the prediction.

Onthe other hand, for 'many to many', I do not need the prediction of y1 and y2 because they should be known when predicting y3.

  • $\begingroup$ Your setup sounds like you want to look at recurrent neural networks. $\endgroup$ – Stephan Kolassa Feb 23 '18 at 7:04
  • $\begingroup$ You should combine a recurrent neural architecture (e.g. LSTM) with CRFs, here is one example: github.com/UKPLab/emnlp2017-bilstm-cnn-crf $\endgroup$ – pedrobisp May 4 '18 at 10:54