Answers.Body: <p>I would say offsets from previous N-event is necessary in this case. You can also encode their max and avg as other features in order to compress the irregular sampling times into a vector.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-18T11:02:46.297Z
Answers.Text: yes, that's what I ended up doing. Also tried some discretization into 1-day periods.
Answers.UserDisplayName: Alena Volkova
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-17T20:41:02.800Z
Answers.LastActivityDate: 2020-11-17T20:41:02.800Z
Answers.UserDisplayName: F4RZ4D
Body: <p>I want to use RNN for classifying whole sequences of events, generated by website visitors. Each event has some categorical properties and a Unix timestamp:</p>
  <pre><code>sequence1 = [{'timestamp': 1597501183, 'some_field': 'A'}, {'timestamp': 1597681183, 'some_field': 'B'}]
  sequence2 = [{'timestamp': 1596298782, 'some_field': 'B'}]
  sequence3 = [{'timestamp': 1596644362, 'some_field': 'A'}, {'timestamp': 1596647951, 'some_field': 'C'}]
  </code></pre>
  <p>Unfortunately, they can't be treated as classic time series, because they're of variable length and irregular, so timestamps contain essential information and cannot be ignored. While categorical features can be one-hot encoded or made into embeddings, I'm not sure what to do with the timestamps. It doesn't look like a good idea to use them raw. I've come up with two options so far:</p>
  <ul>
  <li>Subtract the minimum timestamp from every timestamp in the sequence, so that all sequences start at 0. But in this case the numbers can still be high, because the sequences run over a month.</li>
  <li>Use offsets from previous event instead of absolute timestamps.</li>
  </ul>
  <p>I'm wondering if there are common ways to deal with this? I haven't found much on this subject.</p>
  
Tags: <recurrent-neural-networks><data-preprocessing><time-series><feature-extraction><feature-engineering>
Title: How to deal with Unix timestamps features of sequences, which will be classified with RNNs?
UserDisplayName: Alena Volkova
ThreadText: # How to deal with Unix timestamps features of sequences, which will be classified with RNNs?
  
  (Asked by: username_0 on 2020-08-17)
  
  I want to use RNN for classifying whole sequences of events, generated by website visitors. Each event has some categorical properties and a Unix timestamp:
  sequence1 = [{'timestamp': 1597501183, 'some_field': 'A'}, {'timestamp': 1597681183, 'some_field': 'B'}]
  sequence2 = [{'timestamp': 1596298782, 'some_field': 'B'}]
  sequence3 = [{'timestamp': 1596644362, 'some_field': 'A'}, {'timestamp': 1596647951, 'some_field': 'C'}]
  
  Unfortunately, they can't be treated as classic time series, because they're of variable length and irregular, so timestamps contain essential information and cannot be ignored. While categorical features can be one-hot encoded or made into embeddings, I'm not sure what to do with the timestamps. It doesn't look like a good idea to use them raw. I've come up with two options so far:
  
  Subtract the minimum timestamp from every timestamp in the sequence, so that all sequences start at 0. But in this case the numbers can still be high, because the sequences run over a month.
  Use offsets from previous event instead of absolute timestamps.
  
  I'm wondering if there are common ways to deal with this? I haven't found much on this subject.
  
  **Tags:** recurrent-neural-networks, data-preprocessing, time-series, feature-extraction, feature-engineering
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-11-17. Score: 0 | Accepted answer
  
  I would say offsets from previous N-event is necessary in this case. You can also encode their max and avg as other features in order to compress the irregular sampling times into a vector.
  
  > **Comments:**
  > **username_0**: yes, that's what I ended up doing. Also tried some discretization into 1-day periods.  
  
  ---
  
  