Integrating Explainable Machine Learning and Mixed-Integer Optimization for Personalized Sleep Quality Intervention
Authors: Mahfuz Ahmed Anik, Mohsin Mahmud Topu, Azmine Toushik Wasi, Md Isfar Khan, MD Manjurul Ahsan
Organizations: Shahjalal University of Science and Technology, Sylhet, Bangladesh · Florida A&M University, Tallahassee, FL, United States · University of Oklahoma, Norman, OK, United States
Sleep quality is influenced by a complex interplay of behavioral, environmental, and psychosocial factors, yet most computational studies focus mainly on predictive risk identification rather than actionable intervention design. Although machine learning models can accurately predict subjective sleep outcomes, they rarely translate predictive insights into practical intervention strategies. To address this gap, we propose a personalized predictive-prescriptive framework that integrates interpretable machine learning with mixed-integer optimization. A supervised classifier trained on survey data predicts sleep quality, while SHAP-based feature attribution quantifies the influence of modifiable factors. These importance measures are incorporated into a mixed-integer optimization model that identifies minimal and feasible behavioral adjustments, while modelling resistance to change through a penalty mechanism. The framework achieves strong predictive performance, with a test F1-score of 0.9544 and an accuracy of 0.9366. Sensitivity and Pareto analyses reveal a clear trade-off between expected improvement and intervention intensity, with diminishing returns as additional changes are introduced. At the individual level, the model generates concise recommendations, often suggesting one or two high-impact behavioral adjustments and sometimes recommending no change when expected gains are minimal. By integrating prediction, explanation, and constrained optimization, this framework demonstrates how data-driven insights can be translated into structured and personalized decision support for sleep improvement.
Figures & tables
Figure 1: Generic sleep advice imposes high behavioral burden under real-world constraints, frequently resulting in poor follow-through and disrupted sleep. A minimal-change optimization framework instead delivers personalized, low-effort actions that promote more sustainable sleep improvement.
Figure 2: (a) Class distribution of sleep quality; (b) Sample counts for each sleep quality class after data augmentation.
Figure 3: Pearson correlation matrix of sleep quality and associated features
Table 1: Classification of variables by actionability and role in the framework
Model
Test F1
Accuracy
Precision
Recall
Val F1
Train F1
XGBoost
0.9544
0.9366
0.9468
0.9622
0.9579
0.9915
LightGBM
0.9526
0.9328
0.9282
0.9784
0.9630
0.9938
Gradient Boosting
0.9496
0.9291
0.9323
0.9676
0.9479
0.9954
Extra Trees
0.9476
0.9254
0.9188
0.9784
0.9524
0.9735
Random Forest
0.9455
0.9216
0.9100
0.9838
0.9430
0.9817
Neural Network (MLP)
0.8241
0.7388
0.7700
0.8865
0.8700
0.8458
Table 2: Performance metrics of evaluated machine learning models
Hyperparameter
Search Range
Selected Value
Number of trees ( n_estimators )
{50, 100}
100
Learning rate ( η )
{0.01, 0.05, 0.1}
0.05
Maximum depth ( max_depth )
{2, 3, 4}
3
Subsample ratio ( subsample )
{0.6, 0.8}
0.8
Column sample ratio ( colsample_bytree )
{0.6, 0.8}
0.8
Minimum child weight ( min_child_weight )
{3, 5}
3
Table 3: XGBoost hyperparameter configuration and search space
Figure 4: Mean absolute SHAP values for the XGBoost sleep quality prediction model. Higher values indicate features with greater influence on model predictions.
Figure 5: Overview of the proposed predictive–prescriptive framework. Survey data are preprocessed and used to train an XGBoost model for sleep quality prediction. SHAP-based analysis derives importance weights for actionable variables, which are incorporated into a constrained mixed-integer linear programming (MILP) model. The optimization produces personalized, feasible, and minimally disruptive sleep improvement recommendations.
Actionable Variable
Description
Mean Absolute SHAP Value ( wi )
Normalized Weight ( w~i )
Room cross-ventilation
Quality of air circulation in the sleeping environment
0.490
0.160
Nighttime quietness
Level of ambient noise during sleep
0.364
0.119
Lighting condition
Influence of lighting on sleep quality
0.354
0.116
Last caffeine intake time
Timing of last caffeine consumption before sleep
0.363
0.119
Sleeping posture
Quality of body posture during sleep
0.285
0.093
Screen use before sleep
Extent of screen exposure prior to bedtime
0.259
0.085
Table 4: SHAP-Derived Weights for Actionable Variables
λ Value
Interpretation
0.1
Low resistance to behavioral change
0.2
Moderate resistance to behavioral change
0.3
High resistance to behavioral change
Table 5: Behavioral Resistance Parameter Settings
Figure 6: Sensitivity and Pareto analysis of the optimization model. (a) Average number of recommended interventions decreases as the behavioral resistance parameter ( λ ) increases. (b) Pareto frontier between average expected benefit and intervention count, showing diminishing marginal gains as more interventions are applied.
Model Variant
Avg. Interventions
Avg. Benefit
Full Model
0.53
0.048
No Penalty ( λ=0 )
5.83
0.596
Equal Weights
5.83
5.830
Table 6: Ablation study comparison at λ=0.2
Actionable Variable
Baseline
Change
Optimized
Student 874
Screen use before sleep
0
+1
1
Consistent sleep schedule
3
0
3
Last caffeine intake time
4
0
4
Lighting condition
4
0
4
Room cross-ventilation
5
0
5
Table 7: Personalized intervention recommendations for representative students ( λ=0.2 ).
Appendix figures & tables1 asset
Supplementary material from the paper’s appendix.
Appendix
Symbol
Description
i
Index of actionable variables
n
Index of students
A
Set of actionable variables
N
Number of samples used for SHAP analysis
xi0
Baseline value of actionable variable i
Δxi
Decision variable representing change applied to i
Appendix
Table 8: List of symbols and notation used in this article
Sleep monitoring using wearable data has shown promise for personal health, yet large language model (LLM)-based summarization and question answering remain insufficient for personalized sleep guidance. Training specialized models, however, often requires costly expert annotation. Moreover, privacy and accessibility concerns motivate lightweight, local deployment for end users. We present a two-stage framework to address these challenges. Specifically, in Stage1, a multi-agent LLM pipeline reasons structured sleep guidance from unannotated wearable records, enabling scalable dataset construction. Stage2 distills guidance reasoning trajectories into small language models (SLMs) through supervised fine-tuning and integrates a training-free Best-of-N selection strategy to enhance inference. Experimental results demonstrate our method outperforms commercial general and medical LLMs and open-source models. Human evaluation further supports the quality of the generated guidance and the feasibility of personalized sleep guidance with SLMs.
Yusheng Tan, Running Zhao, Sofia Angel +14
The University of Chicago · Baylor College of Medicine · Georgetown University School of Medicine
Mobile sensing enables longitudinal monitoring of behavioral and physiological patterns in everyday settings. However, accurate prediction remains challenging in small-cohort health-sensing studies, where task-specific outcome supervision is limited relative to heterogeneous sensing data. Interpretability is also important, as model outputs should reflect meaningful behavioral and physiological patterns rather than predictive scores alone. We develop a Concept-Integrated Transformer (CIT) with LLM-guided concept supervision for explainable prediction from mobile sensing data. CIT uses a pretrained large language model to generate baseline-aware concept abnormality targets with confidence weights without manual concept annotation. Across two longitudinal datasets, CIT achieves the highest F1 score on AFFECT (0.756) and ties for the highest on a PHQ-9 dataset (0.765). The learned concept scores also reveal interpretable behavioral and physiological patterns; in AFFECT, sleep quantity and quality show the clearest difference between high and low negative affect groups. These findings support LLM-guided concept integration for accurate and interpretable prediction in small-cohort mobile sensing studies.
Yuning Wang, Iman Azimi, Amir M. Rahmani +1
University of Turku, Department of Computing, Turku, Finland · University of California, Irvine, Department of Computer Science, California, USA
We propose a scalable method for training prediction (machine learning) models in the predict-then-optimize paradigm, where model outputs serve as coefficients for a subsequent linear optimization task. Directly minimizing the empirical decision regret is intractable for linear programming and combinatorial optimization since the decision mapping is piecewise constant, and the gradients are zero almost everywhere. While existing methods address this by smoothing the differentiation process, they suffer from scalability issues, since a computationally expensive solver call is required for every gradient evaluation. To address this, we propose a decision-focused learning pipeline based on a measure transformation principle, which yields a new surrogate loss that is completely optimization-solver-free during training. We establish theoretical guarantees, including Fisher consistency and excess risk bounds. Empirically, our method achieves decision quality competitive with state-of-the-art methods while reducing training time by orders of magnitude.
Beichen Wan, Mo Liu
Department of Statistics and Operations Research, University of North Carolina at Chapel Hill, NC, USA.