 People with diabetes who require basal insulin to achieve blood glucose control can be at risk of hypoglycemia, where blood glucose levels drop too low. In randomized clinical trials or RCTs, use of second-generation basal insulin analogs such as insulin-glargene 300 units per milliliter, known as Glargene 300, and insulin-deglidec results in similar glycated hemoglobin reduction compared with first-generation basal insulin analogs such as Glargene 100 and insulin-dedemir but with less hypoglycemia. However, it is not known whether these results translate directly to routine clinical practice as RCTs often apply strict inclusion and exclusion criteria, meaning that they may not be generalizable to real-life situations. Electronic medical records are a source of rich, real-world data, but using them to make comparisons between different treatments can be difficult because results might be biased by confounding data, something that the randomization in RCTs is designed to minimize. In order to make the most of large amounts of data, such as those from electronic medical records, computers can be programmed to model complex data relationships and can even learn from the data to make predictions. This is a process called machine learning. The Lightning Study uses advanced methods, including machine learning, to predict hypoglycemia rates in people with type 2 diabetes using first and second-generation basal insulin analogs by analyzing electronic medical records. Factors that contribute to hypoglycemia rates in patients using a particular basal insulin are first modeled using part of the dataset called the training dataset. This basal insulin-specific model is then applied to the rest of the dataset called the test dataset to see if it accurately predicts hypoglycemia rates in this subset. These are made to the model to improve prediction accuracy before the model is applied to the test dataset again, then changed again, then tested again, and so on, until prediction is optimized. At that point, the optimized model is applied to the full dataset irrespective of what treatment the patients were using, to give a prediction of what hypoglycemia rates would be if all patients were using the basal insulin being modeled. This whole process is repeated many times for a particular basal insulin to obtain estimates of variability, and each basal insulin-specific hypoglycemia prediction model is generated in the same way. Real-world data are an important adjunct to RCTs, and it is hoped that the predictive model generated from the lightning study will aid clinical decision-making.