Decoding Insomnia: Machine Learning Model Predicts Sleep Disorders From Patient Records

Summary: By analyzing demographics, lifestyle data, physical exam results, and laboratory values, a new machine-learning algorithm can accurately predict whether a person is at risk of sleep disorders. Age, weight, and depression are three factors the AI technology identified as being significant predictors of insomnia.

Source: PLOS

A machine learning model can effectively predict a patient’s risk for a sleep disorder using demographic and lifestyle data, physical exam results and laboratory values, according to a new study published this week in the open-access journal PLOS ONE by Samuel Y. Huang of Virginia Commonwealth University School of Medicine, and Alexander A. Huang of Northwestern Feinberg University School of Medicine, US.

The prevalence of diagnosed sleep disorders among American patients has significantly increased over the past decade. This trend is important to better understand and reverse since sleep disorders are a significant risk factor for diabetes, heart disease, obesity, and depression.

In the new work, the researchers used the machine learning model XGBoost to analyze publicly available data on 7,929 patients in the US who completed the National Health and Nutrition Examination Survey. The data contained 684 variables for each patient, including demographic, dietary, exercise and mental health questionnaire responses, as well as laboratory and physical exam information.

This is a drawing of a woman laying in bed
The prevalence of diagnosed sleep disorders among American patients has significantly increased over the past decade. Image is in the public domain

Overall, 2,302 patients in the study had a physician diagnosis of a sleep disorder. XGBoost could predict the risk of sleep disorder diagnosis with a strong accuracy (AUROC=0.87, sensitivity=0.74, specificity=0.77), using 64 of the total variables included in the full dataset. The greatest predictors for a sleep disorder, based on the machine learning model, were depression, weight, age and waist circumference.

The authors conclude that machine learning methods may be effective first steps in screening patients for sleep disorder risk without relying on physician judgement or bias. 

Samuel Y. Huang adds: “What sets this study on the risk factors for insomnia apart from others is seeing not only that depressive symptoms, age, caffeine use, history of congestive heart failure, chest pain, coronary artery disease, liver disease, and 57 other variables are associated with insomnia, but also visualizing the contribution of each in a very predictive model.”

About this machine learning and sleep disorder research news

Author: Hanna Abdallah
Source: PLOS
Contact: Hanna Abdallah – PLOS
Image: The image is in the public domain

Original Research: Open access.
Use of machine learning to identify risk factors for insomnia” by Samuel Y. Huang et al. PLOS ONE


Use of machine learning to identify risk factors for insomnia


Sleep is critical to a person’s physical and mental health, but there are few studies systematically assessing risk factors for sleep disorders.


The objective of this study was to identify risk factors for a sleep disorder through machine-learning and assess this methodology.

Design, setting, and participants

A retrospective, cross-sectional cohort study using the publicly available National Health and Nutrition Examination Survey (NHANES) was conducted in patients who completed the demographic, dietary, exercise, and mental health questionnaire and had laboratory and physical exam data.


A physician diagnosis of insomnia was the outcome of this study. Univariate logistic models, with insomnia as the outcome, were used to identify covariates that were associated with insomnia. Covariates that had a p<0.0001 on univariate analysis were included within the final machine-learning model. The machine learning model XGBoost was used due to its prevalence within the literature as well as its increased predictive accuracy in healthcare prediction. Model covariates were ranked according to the cover statistic to identify risk factors for insomnia. Shapely Additive Explanations (SHAP) were utilized to visualize the relationship between these potential risk factors and insomnia.


Of the 7,929 patients that met the inclusion criteria in this study, 4,055 (51% were female, 3,874 (49%) were male. The mean age was 49.2 (SD = 18.4), with 2,885 (36%) White patients, 2,144 (27%) Black patients, 1,639 (21%) Hispanic patients, and 1,261 (16%) patients of another race. The machine learning model had 64 out of a total of 684 features that were found to be significant on univariate analysis (P<0.0001 used). These were fitted into the XGBoost model and an AUROC = 0.87, Sensitivity = 0.77, Specificity = 0.77 were observed. The top four highest ranked features by cover, a measure of the percentage contribution of the covariate to the overall model prediction, were the Patient Health Questionnaire depression survey (PHQ-9) (Cover = 31.1%), age (Cover = 7.54%), physician recommendation of exercise (Cover = 3.86%), weight (Cover = 2.99%), and waist circumference (Cover = 2.70%).


Machine learning models can effectively predict risk for a sleep disorder using demographic, laboratory, physical exam, and lifestyle covariates and identify key risk factors.

Join our Newsletter
I agree to have my personal information transferred to AWeber for Neuroscience Newsletter ( more information )
Sign up to receive our recent neuroscience headlines and summaries sent to your email once a day, totally free.
We hate spam and only use your email to contact you about newsletters. You can cancel your subscription any time.
  1. Regular sun exposure is also conducive to good sleep. Those who enjoy time in the sun daily sleep more soundly and are able to sleep 45 minutes per night longer. A study by Dr. Julie Gammack exposed test subjects to 30-60 minutes per day of direct sunlight. According to the Saint Louis University health web site, “Nursing home patients who were exposed to natural light had improved sleep quality, less difficulty falling asleep, fewer episodes of wakefulness during the night and greater satisfaction with the amount of sleep they got.” Other research by Dr. Ayoub and colleagues in Alexandria, Egypt demonstrated that there were several factors associated with insomnia among the elderly. Having five or more diseases was associated with a 7.5 times increased risk, anxiety was associated with a 1.9 times increased risk, and depression with a 1.74 times increased risk. Only one factor reduced risk. Sunlight exposure was associated with 43% reduced risk.
    More information:, and read the book, Embrace the Sun.

Comments are closed.