Hewa Majeed Zangana, Maryam A. Sulaiman
Early prediction of chronic diseases using longitudinal electronic health records (EHRs) is critical for enabling timely interventions and improving patient outcomes. However, existing deep learning approaches often function as black-box models, limiting their clinical adoption due to a lack of transparency and interpretability. This study proposes an explainable transformer-based framework for early chronic disease prediction that effectively models temporal dependencies in longitudinal EHR data while providing clinically meaningful explanations. The proposed approach integrates a time-aware transformer architecture with attention-based interpretability mechanisms to capture complex patient trajectories across heterogeneous clinical events, including diagnoses, laboratory results, medications, and demographic attributes. To enhance explainability, we incorporate feature-level and temporal attention visualization, enabling identification of influential clinical factors and critical time windows contributing to disease onset predictions. Extensive experiments conducted on large-scale longitudinal EHR datasets demonstrate that the proposed model consistently outperforms state-of-the-art machine learning and deep learning baselines in terms of predictive accuracy, recall, and early risk detection capability. Furthermore, qualitative evaluation with clinician-oriented explanation analyses confirms that the generated explanations align with established medical knowledge, enhancing trust and clinical usability. This work advances the integration of explainable artificial intelligence in healthcare by offering a robust and interpretable transformer-based solution for early chronic disease prediction, supporting data-driven decision-making in real-world clinical settings.