ObjectiveThis study sought to explore the utility of machine learning models in predicting insomnia severity based on Traditional Chinese Medicine (TCM) constitution classifications, with an aim to discuss the potential applications of such models in the treatment and prevention of insomnia.MethodsWe analyzed a dataset of 165 insomnia patients from the Shanghai Minhang District Integrated Traditional Chinese and Western Medicine Hospital. TCM constitution was assessed using a standardized Constitution in Chinese Medicine (CCM) scale. Sleep quality, or insomnia severity, was evaluated using the Spiegel Sleep Questionnaire (SSQ). Machine learning models, including Random Forest Classifier (RFC), Support Vector Classifier (SVC), and K-Nearest Neighbors (KNN), were utilized. These models were optimized using Grid Search algorithm and were trained and tested on stratified patient data, with the TCM constitution classifications serving as primary predictors.ResultsThe RFC outperformed others, achieving a weighted average accuracy, precision, recall, and F1-score of 0.91, 0.94, 0.92, and 0.92 respectively, it also effectively classified the severity of insomnia with high area under receiver operating characteristic curve (AUC-ROC) values. Feature importance analysis demonstrated the Damp-heat constitution as the most influential predictor, followed by Yang-deficiency, Qi-depression, Qi-deficiency, and Blood-stasis constitutions.ConclusionThe results demonstrate the potent utility of machine learning, specifically RFC, coupled with TCM constitution classifications in predicting insomnia severity. Notably, the constitution classifications such as Damp-heat and Yang-deficiency emerged as crucial determinants, emphasizing its potential in guiding targeted insomnia treatments. This approach enables the development of more personalized and efficient interventions, thereby enhancing patient outcomes.