NSDC Data Science Project – Data-Driven Digital Twin Simulation for Sleep Quality Prediction


Data-Driven Digital Twin Simulation for Sleep Quality Prediction

Project Description

A hands-on Colab project that builds a digital twin of a person’s sleep behavior. A digital twin is a virtual representation of a real-world system used to simulate scenarios and predict outcomes, and here each person’s lifestyle profile becomes their twin. Students clean a messy real-world health dataset, explore what actually drives sleep quality, train two prediction models inside a scikit-learn pipeline, and then build the payoff: a simulate() function that answers counterfactual, what-if questions such as “if this person lowered their stress by 2 points, how would their predicted sleep quality change?”

The project moves students from prediction to simulation. A standard model tells you what will happen. A digital twin lets you change one habit at a time, re-predict, and compare, which is a fundamentally different and more useful kind of tool. Along the way students sweep a single lever across its full range to see its whole effect curve, and compare two different twins to discover that the same intervention does not help everyone equally. The recurring lesson is interpretive discipline: the twin captures associations within this dataset, not proven causation.


Dataset

This project uses a Sleep Health and Lifestyle Dataset (Kaggle), provided as a selected-columns CSV that students upload to Colab. Each row is one lifestyle profile, and the target is Quality of Sleep on a 1 to 10 scale. Features cover demographics (gender, age, occupation), lifestyle (sleep duration, physical activity level, stress level), and health (BMI category, blood pressure). The dataset includes three data-quality issues students diagnose and fix themselves: a duplicated BMI Category label, blood pressure stored as text like "120/80" rather than as numbers, and a large number of identical rows that reveal the data represents grouped profiles rather than unique individuals.


Relevant Skills You May Apply

Python, pandas, and NumPy. Basic statistics and the idea of correlation. Data visualization with matplotlib and seaborn. Comfort running Colab notebooks. Prior exposure to scikit-learn is helpful but not required.


Skills You May Gain

End-to-end data science workflow: diagnosing and repairing real data-quality problems, forming hypotheses before looking at the plots, exploratory data analysis and correlation analysis, building scikit-learn Pipelines and ColumnTransformers for one-hot encoding and scaling, training and comparing interpretable versus high-accuracy models (Linear Regression and Random Forest), reading feature importances, evaluating with R² and MAE, recognizing when a strong score is inflated by duplicate rows, and building counterfactual what-if simulations with sensitivity sweeps. Students also practice distinguishing correlation from causation and stating the limits of their own model.


Total Time

Approximately 8 to 10 hours, self-paced. No cells are computationally heavy, so most of the time goes to the seven fill-in-the-blank exercises and the six written discussion questions.


Milestones

  1. Setup & Data Loading
    Set up Colab, import the toolkit, load the dataset, and take a first look at its structure
  2. Data Cleaning
    Merge the duplicate BMI category, split blood pressure into Systolic and Diastolic, drop the ID column, and investigate duplicate profiles
  3. Hypotheses
    State expectations about what drives sleep quality before seeing any plots, which keeps the analysis honest
  4. Exploratory Data Analysis
    Examine the target distribution, numeric and categorical features, and sleep quality broken out by group
  5. Correlation Analysis
    Build a correlation heatmap and rank every feature against sleep quality to identify the twin’s main levers
  6. Preprocessing & Model Training
    Build a leakage-free pipeline, split the data, and train Linear Regression and Random Forest models side by side
  7. Building the Digital Twin
    Write predict_quality() and simulate(), then run single and combined what-if scenarios on one person
  8. Sensitivity Analysis & Comparison
    Sweep individual levers across their full range, and compare how the same intervention affects two different twins

Deliverables

A completed notebook with all seven exercises filled in and all six discussion questions answered, containing the cleaned dataset, the EDA and correlation visualizations, both trained models with their R² and MAE scores, the feature importance chart, a working simulate() function, at least one original what-if scenario of the student’s own design, and the two sensitivity sweep curves. Save a copy of the Colab notebook to your personal Drive before starting.