# Binary target prediction using LSTM with sparse events in time

I have a data of patients that have multiple events happening in there medical history, I'd like to predict a target of having a specific targeted-event in the next 30 days.

The data is timestamped but the time frequency is irregular and the events happens once in a while. For each patient I have:

|Date       | event_1    | test_lab_1 | event_2 | ... |Target_event_in_next_month |
-----------------------------------------------------------------------------------
|2017-01-01 | NaN        |  0.89      |  NaN    | ... |  0                        |
-----------------------------------------------------------------------------------
|2017-01-10 | 1          |  NaN       |  NaN    | ... |  0.                       |
-----------------------------------------------------------------------------------
|2017-03-01 | NaN        |  1.5       |  NaN    | ... |  1                        |
-----------------------------------------------------------------------------------
|2017-07-21 | NaN        |  NaN       |  1      | ... |  0                        |


What I would like to know is: Knowing that I've aggregated the data per month, is this kind of data (sparse and mix of binary and float features) suitable/compatible with LSTMs ? What would be the right strategy to solve this kind of problem ?

There is some work using 'marked temporal point processes' which addresses a related problem. Marked temporal point processes model 'marked' discrete events localized in time. The key idea is to model the conditional density that some event $$y$$ will occur at time $$t$$ given a history of events with their corresponding past times.

Some references:

is this kind of data (sparse and mix of binary and float features) suitable/compatible with LSTMs?

I don't see any reason why that kind of data would be not suitable with LSTM. I think you can just add some default values(just symbols different from other values) for those days when no event appears.

What would be the right strategy to solve this kind of problem ?

I thought you would train it like a labelling task or language model task. If you obtain the latter. You can try adding a transformer before the RNN to better encode the interrelations of the data in the day and the sequence relation between continuous days. If you try the former maybe you can employ the CRF.

First try to train the model with some good data and if data are limited you can try semi-supervised learning.

You could consider interpolating, padding, or forward-filling the data over "missing" observations, before aggregating per-month targets, as a simple first approach. For example, you could input (speaking very roughly) <EVENT> <PAD> <PAD> <PAD> <EVENT> <PAD> <PAD> ... and output a binary value for whether the target event does/not occur in the month following the input sequence.

If you have a smallish set of low-dimensional input features, though, an RNN might be overkill - you may be able to get a lot out of a simpler logistic regression first instead.