Abstract Background Studies using AI assessment of 10-second 12-lead ECG suggest that it provides incremental identification of AF risk compared with clinical scores. However, it is not clear what preventive treatment should be given as the exact time of AF onset remains unknown. The use of machine learning (ML) with 2-lead Holter ECG allows the development of predictive models for paroxysmal AF within a short time window, potentially allowing an optimised pill-in-the-pocket (PITP)-like strategy. Aim To identify patients who are still in sinus rhythm but will develop an episode of AF in the next few hours using 24-hour Holter recordings and ML. Materials and methods We created a new database of 95871 Holter recordings that were manually analysed. We identified 1319 paroxysmal AF episodes from 872 patients. A total of 835 AF episodes from 506 recordings had more than 60 minutes of normal sinus rhythm (NSR) before AF onset and more than 10 minutes of AF after onset, and a total of 964 AF episodes had 30 minutes or more of NSR before AF onset. Patients were divided into five groups: all patients, patients younger than 60 years, 60-70 years, 70-80 years, and older than 80 years. A total of 365 recordings from 347 patients without rhythm abnormalities were identified and classified in our database, from which we took two ECG windows. We used a gradient-boosted decision tree model with heart rate variability (HRV) parameters as input. Results The most significant results were obtained from recordings with more than 5 minutes of AF with an AUROC of 0.919 (95% CI: 0.879-0.958) and an AUPRC of 0.919 (0.879-0.958) 15H08 ± 13H05 hours before the onset of AF (Figures 1 - 2). Using a threshold of 0.5, the accuracy was 84.5% (81.2-87.8), the sensitivity was 83.0% (79.5-86.4), the specificity was 86.6% (79.3-93.9), the PPV was 90.2% (85.5-94.9), the NPV was 78.4% (74.7-82.1) and the F1 score was 86.2% (83.5-89.0) for all patients. Conclusion These results suggest that the most important information for short-term prediction of AF onset is contained in HRV, allowing a preventive strategy. This could be exploited by wearables in mHealth allowing the use of a PITP-like preventive strategy to reduce the burden of AF. Prospective studies are needed to confirm the encouraging potential of these findings.AUROC of the XGBoost modelPrecision-recall curves