TL;DR
This paper introduces Time Embeddings (TEs), a parameter-free method to represent irregular timestamps as dense vectors using sinusoidal functions. By adapting the "positional encoding" trick from Transformers to continuous time, the authors enable standard machine learning models to better understand the temporal gaps in messy, real-world data like electronic health records.
What Problem Does This Paper Address?
Most machine learning models—including standard Recurrent Neural Networks (RNNs)—assume that data arrives in a neat, evenly spaced sequence (e.g., every hour). However, real-world data is often irregularly sampled.
Take a hospital setting: a patient’s heart rate might be recorded at 9:00 AM, 9:15 AM, and then not again until 4:00 PM. A standard model usually only sees the order of these events, ignoring the massive seven-hour gap between the second and third readings. While researchers have tried to fix this using complex "gated" architectures or by "filling in" missing data (imputation), these methods often add significant computational overhead or introduce noise. The authors sought a simpler, "model-agnostic" way to bake time awareness directly into the data representation.
Methods
The core innovation is the Time Embedding (TE). The authors took inspiration from the Positional Embeddings used in the Transformer architecture but made a critical tweak:
- From Discrete to Continuous: Instead of using an integer "position" (1st word, 2nd word), they use the actual timestamp (e.g., 11.5 hours) as the input variable.
- Sinusoidal Functions: They use a set of sine and cosine functions at different frequencies to create a dense vector. Because these functions are continuous, the model can theoretically learn the "distance" between any two points in time through simple linear operations.
- Zero Parameters: Unlike many deep learning components, TEs require no training. You simply calculate the vector based on the timestamp and feed it into the model.
The authors tested two ways to use these embeddings:
- Concatenation: Appending the Time Embedding vector to the input features.
- Addition: Adding the Time Embedding to the hidden state of an RNN.
Datasets
The researchers evaluated their method using the MIMIC-III dataset, a massive, publicly available collection of de-identified electronic health records. They focused on two specific benchmark tasks:
- In-hospital Mortality Prediction: A classification task to predict if a patient will survive their stay.
- Length of Stay (LOS) Prediction: A regression task to estimate how many days a patient will remain in the hospital.
To push the limits of their method, they also created "artificially irregular" versions of the data by randomly removing observations to see how the models handled increasingly large time gaps.
Key Insights and Ideas
- Time as a First-Class Citizen: By representing time as a dense vector rather than just a single number (like "delta-t"), the model gains a much richer "vocabulary" for understanding temporal context.
- Model Agnosticism: One of the most surprising findings was that TEs didn't just help complex LSTMs; they also improved the performance of "shallow" models like Linear Regression and Multi-Layer Perceptrons (MLPs). This suggests that the bottleneck in irregular time series isn't always the model architecture, but how we represent time itself.
- Handling Sparsity: TEs proved particularly effective when data was very sparse. While "Binary Masking" (simply telling the model which data is missing) is a strong baseline, TEs provide a smoother, continuous alternative that avoids the "sparsity" issues of high-dimensional masks.
Key Results
- Mortality Prediction: The "Self-Attentive LSTM" combined with Time Embeddings achieved an AUC-ROC of 0.856, outperforming the vanilla LSTM (0.855) and the version using standard binary masking (0.854).
- Length of Stay: While Binary Masking performed slightly better on Mean Absolute Error (61.6 vs 62.3 for TEs), the Time Embeddings significantly improved the performance of the base LSTM and provided more stable results across different levels of data irregularity.
- Efficiency: Because TEs add zero trainable parameters, they provide these performance boosts without increasing the risk of overfitting or the time required for training.
Limitations and Future Work
The authors acknowledge that while TEs are a powerful tool, they are sometimes outperformed by Binary Masking in specific scenarios. Binary masks explicitly tell a model "this data point is missing," whereas TEs focus on "this is exactly when this happened."
Future directions include: * Extending TEs to handle other types of continuous, non-temporal data. * Integrating TEs with more specialized architectures like GRU-D or Phased-LSTMs to see if the benefits compound. * Testing the method on non-medical datasets, such as climate science or astronomy, where irregular sampling is also a major hurdle.
Summary updated