Abstract
Electronic health records (EHRs) offer significant potential for precision health but present analytical challenges due to irregular timing and mixed data types. This study evaluates the application of Natural Language Processing (NLP) word embedding techniques—including Word2Vec, BERT, FastText, ELMo, and GloVe—to structured medical codes. By treating a patient's medical history as a "sentence," we developed prediction models for six high-prevalence diseases using the MIMIC-III database. Our findings indicate that while contextual embeddings like ELMo offer marginal improvements, static models like Word2Vec and GloVe provide comparable accuracy with significantly higher computational efficiency.
Introduction
The digital transformation of healthcare has resulted in vast repositories of Electronic Health Records (EHRs). These records, containing longitudinal data on diagnoses, prescriptions, and lab results, are invaluable for predictive modeling and personalized medicine. However, EHR data is inherently "messy"—it consists of irregular sequences of events that vary in length and frequency across patients.
Traditional statistical approaches, such as Principal Component Analysis (PCA), often struggle to capture the sequential nature of these records. While NLP has been widely used to analyze unstructured clinical notes, its application to structured billing and diagnostic codes remains an emerging field. This research systematically compares various embedding algorithms to determine their efficacy in predicting future disease diagnoses based on structured patient histories.
Methodology: Medical Codes as Language
The core innovation of this approach is treating a patient’s chronological sequence of medical codes as a "sentence." This allows researchers to leverage powerful embedding algorithms developed for linguistics:
- Static Embeddings (Word2Vec, FastText, GloVe): These models assign a fixed vector to each medical code, capturing its general relationship with other codes across the entire dataset.
- Contextual Embeddings (ELMo, BERT): These models generate dynamic vectors where the representation of a code changes based on the specific codes surrounding it in a patient's history.
Temporal Weighting and Disease Modeling
Recognizing that recent medical events are typically more predictive of current health than distant ones, the authors implemented a temporal weighting mechanism. An exponential decay function was applied to give greater weight to recent codes when aggregating a patient's history into a single vector.
The study focused on six high-prevalence conditions: Diabetes, Chronic Kidney Disorder, Heart Failure, Lipid Metabolism Disorder, Fluid/Electrolyte Disorder, and Cardiac Dysrhythmia. Prediction models were built using Lasso regression and Deep Learning architectures tailored to these specific diseases.
Experimental Results
The models were evaluated using the MIMIC-III (Medical Information Mart for Intensive Care) database, comprising approximately 5,600 patients and 1.2 million tokens.
Performance vs. Efficiency
The results revealed a notable trade-off between model complexity and performance:
- Predictive Accuracy: Static models (Word2Vec, FastText, GloVe) achieved high Area Under the Curve (AUC) scores, typically between 0.70 and 0.79. While ELMo provided marginal gains in specific contexts, the improvement was not transformative.
- Computational Cost: GloVe emerged as the clear winner for efficiency, completing training in just 11 seconds on a CPU. In contrast, BERT required 1,830 seconds, representing a massive increase in overhead for negligible performance gains.
The "Data Hunger" of Transformers
One of the most significant findings was that BERT—the current state-of-the-art in many NLP tasks—performed the worst in several tests. This is likely due to the dataset size. Transformers generally require billions of tokens to learn effectively; the 1.2 million tokens in the MIMIC-III subset were insufficient for BERT to outperform simpler, more robust static models.
Discussion and Clinical Implications
The study demonstrates that incorporating temporal decay consistently improves accuracy, confirming that the timing of medical events is a critical feature. Furthermore, the disease-specific models developed here outperformed the previous state-of-the-art baseline (the PDPS method), suggesting that tailored embedding-based models are superior for individual risk assessment.
Contextual embeddings like ELMo showed some utility in resolving "ambiguous" codes—where a generic ICD-9 code might imply different severities depending on the surrounding clinical context. However, for most practical applications with limited datasets, static embeddings remain the most viable option.
Conclusion
This research provides a roadmap for practitioners looking to apply NLP techniques to structured EHR data. While advanced models like BERT offer immense power, their data requirements may make them unsuitable for smaller clinical datasets. Static embeddings like Word2Vec and GloVe offer a "sweet spot" of high accuracy and low computational cost, especially when combined with temporal weighting to account for the recency of medical events. Future work will explore larger datasets and the integration of exact timestamps to further refine these predictive capabilities.
Summary updated