Background: Patients with Sleep Apnea (SA) and Coronary Artery Disease (CAD) are at higher risk of Atrial fibrillation (AF) than the general population. Our objectives were: to evaluate the role of CAD and SA in determining AF risk through cluster and survival analysis and to develop a risk model for predicting AF.Methods: Electronic medical record (EMR) database from 22,302 individuals including 10,202 individuals with AF, CAD, and SA, and 12,100 individuals without these diseases were analyzed using K-means clustering technique; k-Nearest Neighbor (kNN) algorithm and Survival analysis. Age, sex, and diseases developed for each individual during nine years were used for cluster and survival analysis.Results: The risk models for AF, CAD and SA were identified with high accuracy and sensitivity (0.98). Cluster analysis showed that CAD and high blood pressure (HBP) are the most prevalent diseases in the AF group. Survival analysis demonstrated that individuals with HBP, CAD, and SA had a 1.5-fold increased risk of developing AF (HR:1.49, 95%CI:1.18-1.87, p=0.0041; HR:1.46, 95%CI: 1.09-1.96, p=0.01; HR: 1.54, 95%CI:1.22-1.94, p=0.0039, respectively) and individuals with chronic kidney disease (CKD) developed AF approximately 50% earlier than patients without these comorbidities in a period of 7 years (HR:3.36, 95%CI: 1.46-7.73, p=0.0023). Comorbidities that contributed to develop AF earlier in females compared to males were HBP (HR:3.75 95%CI:1.08-13, p=0.04;), CAD (HR:2.4 95%CI:1.18-4.86, p=0.02) and SA (HR: 2.51, 95%CI:1.14-5.52, p=0.02).Conclusions: Machine learning based algorithms demonstrated that CAD, SA, HBP and CKD are significant risk factors for developing AF in a Latin-American population.