XTSFormer: Cross-Temporal-Scale Transformer for Irregular-Time Event Prediction in Clinical Applications

Tingsong Xiao, Zelin Xu, Wenchong He, Zhengkun Xiao, Yupu Zhang, Zibo Liu, Shigang Chen, My T. Thai, Jiang Bian, Parisa Rashidi, Zhe Jiang

Introduction

Predicting the next clinical event—such as medication administration or provider interaction—is a cornerstone of modern healthcare, enabling improved patient safety and optimized care pathways. However, Electronic Health Record (EHR) data is characterized by irregular timing and complex multi-scale dynamics. For instance, a patient's clinical state may change rapidly during surgery but stabilize during recovery, leading to varying event densities. Standard Neural Temporal Point Processes (TPPs) and vanilla Transformers often struggle with these irregularities or face prohibitive $O(L^2)$ computational costs when processing long patient histories.

To address these challenges, we propose XTSFormer, a novel Transformer architecture that incorporates feature-aware temporal encoding and a hierarchical attention mechanism to capture multi-scale clinical rhythms efficiently.

Methodology

The XTSFormer architecture consists of a specialized encoder-decoder structure designed to handle the nuances of irregular clinical time series. The encoder integrates a novel positional encoding scheme and a hierarchical tree structure to manage temporal scales, while the decoder predicts both the type and timing of the subsequent event.

The XTSFormer architecture, featuring an encoder with Feature-based Cycle-aware Time Positional Encoding (FCPE) and a hierarchical multi-scale module, and a decoder for joint event type and time prediction.

Feature-based Cycle-aware Time Positional Encoding (FCPE)

Standard positional encodings typically assume fixed time steps, which is unsuitable for irregular EHR data. FCPE addresses this by utilizing a series of sine and cosine functions to capture periodicity. A key innovation of FCPE is its feature-awareness: it learns the "intensity" of specific frequencies based on the event type. This allows the model to automatically recognize that different clinical events, such as specific medications, may follow distinct cycles (e.g., 12-hour vs. 48-hour intervals).

Hierarchical Multi-scale Module

Clinical events often interact across different temporal scales. XTSFormer captures these dynamics by constructing a hierarchical tree through bottom-up agglomerative clustering. Events that occur in close temporal proximity are merged into clusters at finer scales, which are then further aggregated into coarser scales.

The hierarchical multi-scale structure generated via agglomerative clustering, enabling the model to capture interactions across different temporal scales.

This hierarchical approach enables Cross-scale Attention, where the model performs attention within these clusters. This strategy reduces the computational complexity from $O(L^2)$ to $O(L \log L)$, facilitating the processing of significantly longer event sequences without the memory overhead associated with standard self-attention.

Experimental Results

XTSFormer was evaluated on two large-scale EHR datasets spanning the perioperative period: a Medications dataset (355,490 records) and a Providers dataset (704,496 records).

Predictive Performance

XTSFormer consistently outperformed state-of-the-art baselines, including RNN-based TPPs (RMTPP), Neural ODEs, and other Transformer variants (SAHP, THP). On the Medications dataset, XTSFormer achieved an accuracy of 33.5%, a significant improvement over the next best model, A-NHP (30.2%). Furthermore, it demonstrated superior temporal precision, achieving the lowest Root Mean Square Error (RMSE) for time prediction (1.12 vs. 1.40+ for baselines).

Scalability

In synthetic scalability tests, XTSFormer remained computationally efficient for sequences up to 100,000 events. In contrast, vanilla Transformers either ran out of memory or exhibited exponential increases in processing time, highlighting XTSFormer's suitability for long-term chronic care monitoring.

Discussion

XTSFormer represents a significant step forward in modeling irregular clinical events by effectively combining semantic feature information with multi-scale temporal structures. While the current model focuses on one-step-ahead prediction, future work will explore multi-step forecasting and end-to-end dynamic hierarchy learning. Enhancing the interpretability of the learned temporal intensities also remains a priority to ensure these models can be effectively utilized by clinicians at the bedside.

Summary updated

BibTeX
@inproceedings{xiao2025xtsformer,
  author = {Tingsong Xiao and Zelin Xu and Wenchong He and Zhengkun Xiao and Yupu Zhang and Zibo Liu and Shigang Chen and My T. Thai and Jiang Bian and Parisa Rashidi and Zhe Jiang},
  title = {{XTSFormer: Cross-Temporal-Scale Transformer for Irregular-Time Event Prediction in Clinical Applications}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i27.35073},
}
Figure