Gestational diabetes (GDM) is associated with adverse pregnancy and neonatal outcomes, increased risk for type 2 diabetes (T2D) and other long-term consequences for both the mother and the offspring. GDM is usually diagnosed around 24-28 weeks of gestation via a complicated sequence of glucose challenge tests (GCT) and repeated blood-work, contributing to increased costs and patient/provider burden. In this study we design a stochastic learning algorithm for GDM prediction with dirty, unprocessed raw data comprising only the records of diagnostic codes generated during past medical encounters from a national US insurance claims database. In computing the Gestational-diabetes Comorbid Risk (GCoR) score, we use no laboratory test results, no medications, demographic, or familial information, and yet achieve a sensitivity greater than 83% at 95% specificity with the corresponding area under the receiver operating characteristic curve (AUC) of 96.87% and a positive predictive value (PPV) >53% at the first prenatal visit for low-risk patients (n=648,784). The AUCs when evaluated one, two and four months before the first prenatal visit is respectively 92.75%, 91.82% and 89.97% for the same cohort. For a general cohort with potentially high risk patients included (n=670,417) we achieve AUCs of 95.42% at the first prenatal visit, degrading to 89.24%, 88.06% and 86.08% at the subsequent time points. And for a high-risk cohort (n=104,946), we achieve AUCs of 94.83%, 89.31%, 87.51%, and 85.80% respectively. We significantly outperform reported tools, achieving a over 200% improvement in sensitivity at 95% specificity for the low risk cohort. Additionally, accurate GDM risk assessment months before pregnancy opens new intervention possibilities, including risk management through lifestyle changes, as well as delaying pregnancy briefly to reduce GDM risk. Additionally, subtle differences in comorbidity patterns suggest the possibility of reducing misdiagnosis of disorders that mimic GDM symptomology such as Cushing's disease, and tumors of the adrenal gland. Funding Statement: This work is funded in part by the Defense Advanced Research Projects Agency (DARPA) project #FP070943- 01-PR. The claims made in this study do not reflect the position or the policy of the US Government. DARPA had no role in the authors’ decision to pursue this specific research problem, or authoring this specific article. Declaration of Interests: Authors have no known conflict of interest. Ethics Approval Statement: The de-identified insurance claims used in this study was deemed exempt by the relevant Institutional Review Board.