Screening-grade prediction of past-year Major Depressive Episode (MDE) in adults using the NSDUH 2023 survey, with a focus on:
Can we build a compact, interpretable, survey-weighted model that predicts past-year MDE (IRAMDEYR) in adults, using NSDUH variables, while maximizing recall and negative predictive value (NPV) for triage?
The long-term goal is a brief feature set that could be embedded into:
We use the 2023 National Survey on Drug Use and Health (NSDUH):
Note: NSDUH data cannot be redistributed in this repo.
You must obtain it directly from the official source and place it in thedata/directory.
The project is structured into three main phases:
NaN.QUESTID2, CASEID-like variables)VESTR_C, VEREP)FILEDATE, YEAR, QUARTER)../data/cleaned/NSDUH_2023_clean.pkl , This cleaned file serves as the input to a subsequent feature preparation step, which performs final column alignment and prepares model-ready inputs.../data/cleaned/NSDUH_2023_clean.pklA single train/test split (with random_state=42) is used consistently in the feature-selection notebooks to avoid leaking information from the test set into the feature selection stage.
We apply four feature-selection approaches, each optimized twice:
Each method is run in two modes:
Total: 8 ranked feature lists (each typically exporting the top 100 features to CSV).
These notebooks:
NSDUH_2023_clean.pkl).IRAMDEYR from X and keep it as y.ANALWT2_C from X for feature selection (weights are not used to rank features).train_test_split, random_state=42, stratify=y)SimpleImputer + StandardScaler or pre-processing steps)Outputs:
../results/lasso_auc_top100.csv../results/lasso_recall_top100.csv../results/elasticnet_auc_top100.csv../results/elasticnet_recall_top100.csv../results/rfe_auc_top100.csv../results/rfe_recall_top100.csv../results/rfecv_auc_top100.csv../results/rfecv_recall_top100.csvThese files are used to build the agreement table.
Agreement Table (Data-Driven)
A central notebook loads all 8 top-100 CSVs and builds a unified Feature Agreement Table:
SUM column = how many methods selected this featureExport:
../results/feature_agreement_table.csv
Intuition-Based Tiering (Clinical / Triage Perspective)
Using:
we assign features into three practical tiers:
The finalized tier definitions are formalized using a dedicated preparation script (tier_preparation.py), which exports each tier as a reusable feature list. These tier-specific feature sets are then passed directly to the predictive modeling notebooks for evaluation and comparison.
The tier assignment is stored in a combined CSV (e.g., combined_feature_translation.csv), which includes:
This CSV is used later when we build and evaluate final predictive models.
project-root/
├─ data/
│ ├─ raw/
│ │ └─ NSDUH_2023_Tab.txt (or similar NSDUH raw file) [not in repo]
│ ├─ cleaned/
│ │ └─ NSDUH_2023_clean.pkl
|
├── models
│ ├── lightgbm_tier_2_clinical_recall.joblib
│ └── lightgbm_tier_3_personalized_recall.joblib
|
├── notebooks
│ ├── Baseline_Characteristics_General_EDA.ipynb
│ ├── create_metric_tables.ipynb
│ ├── create_model_comparison_table.ipynb
│ ├── data_cleaning.ipynb
│ ├── feature_preparation.ipynb
│ ├── feature_selection_agreement.ipynb
│ ├── feature_selection_EDA.ipynb
│ ├── feature_selection_elasticnet.ipynb
│ ├── feature_selection_lasso.ipynb
│ ├── feature_selection_RFECV.ipynb
│ ├── feature_selection_RFE.ipynb
│ ├── predictive_model_lightGBM.ipynb
│ ├── predictive_model_logistics_regression.ipynb
│ ├── predictive_model_random_forest.ipynb
│ ├── predictive_model_support_vector_machine.ipynb
│ ├── predictive_model_xgboost.ipynb
│ ├── shap_lightgbm_interpretability.ipynb
│ └── tiering_preparation.py
|
├── README.md
├── requirements.txt
|
├── results
│ ├── all_models_by_fold.csv
│ ├── all_models_comparison.csv
│ ├── elasticnet_auc_top100.csv
│ ├── elasticnet_recall_top100.csv
│ ├── feature_agreement_table.csv
│ ├── figures
│ │ ├── rf_grid_pr_curve.png
│ │ ├── rf_grid_roc_curve.png
│ │ ├── rf_random_pr_curve.png
│ │ ├── rf_random_roc_curve.png
│ │ ├── xgb_grid_pr_curve.png
│ │ ├── xgb_grid_roc_curve.png
│ │ ├── xgb_random_pr_curve.png
│ │ └── xgb_random_roc_curve.png
│ ├── lasso_auc_top100.csv
│ ├── lasso_recall_top100.csv
│ ├── lightgbm_5fold_threshold0.50_by_tier.csv
│ ├── lightgbm_all_tiers_results.csv
│ ├── lightgbm_testset_metrics_by_tier.csv
│ ├── lightgbm_two_rows_per_tier.csv
│ ├── logreg_5fold_threshold0.50_by_tier.csv
│ ├── model_comparison_table_means.csv
│ ├── rf_5fold_threshold0.50_by_tier.csv
│ ├── rfe_auc_top100.csv
│ ├── rfecv_auc_top100.csv
│ ├── rfecv_recall_top100.csv
│ ├── rfe_recall_top100.csv
│ ├── rf_grid_tier_performance.csv
│ ├── rf_random_tier_performance.csv
│ ├── rf_two_rows_per_tier.csv
│ ├── table1_Baseline_Characteristics.csv
│ ├── xgb_5fold_threshold0.50_by_tier.csv
│ ├── xgb_comprehensive_results.csv
│ ├── xgb_grid_tier_performance.csv
│ ├── xgb_random_tier_performance.csv
│ ├── xgb_shap_importance_by_tier.csv
│ ├── xgb_shap_values_Tier_1_Basic.csv
│ ├── xgb_shap_values_Tier_2_Clinical.csv
│ ├── xgb_shap_values_Tier_3_Personalized.csv
│ └── xgb_two_rows_per_tier.csv
|
└── tiers
├── tier_1_basic_features.csv
├── tier_2_clinical_features.csv
└── tier_3_personalized_features.csv
pipeline_publication5.py — publication-ready end-to-end pipeline for final modeling, threshold selection, weighted evaluation, and SHAP analysis used in the manuscript.
This repository is organized as a research-oriented data science project, with a strong emphasis on reproducibility, transparency, and auditability.
Please follow the steps below in order.
This project uses the 2023 National Survey on Drug Use and Health (NSDUH) public-use data.
You must download the data directly from the official SAMHSA site:
👉 https://www.samhsa.gov/data/data-we-collect/nsduh-national-survey-drug-use-and-health
Use the public-use data file (tab-delimited format).
Note:
NSDUH data cannot be redistributed. The raw dataset is not included in this repository.
After downloading the NSDUH file, place it here:
data/raw/
└── NSDUH_2023_Tab.txt
⚠️ Do not rename the file unless you also update the corresponding path in the data cleaning notebook.
To ensure identical results across machines, all users must install the exact dependencies listed in requirements.txt.
Create and activate a virtual environment:
python -m venv venv
Activate it:
Windows (PowerShell)
venv\Scripts\activate
macOS / Linux
source venv/bin/activate
Install dependencies:
pip install -r requirements.txt
This step is mandatory and must be completed before running any feature selection or modeling notebooks. The notebooks must be executed in the order shown below.
notebooks/data_cleaning.ipynb
This notebook performs the core data cleaning and leakage control steps:
notebooks/feature_preparation.ipynb
This notebook performs additional feature preparation, including:
The prepared dataset is saved to the pickle file:
data/cleaned/NSDUH_2023_clean.pkl
🔑 This pickle file is the single source of truth All feature selection and modeling notebooks depend on it.
After data cleaning and feature preparation, the cleaned pickle file is used for data-driven feature selection and tier construction.
feature_selection_lasso.ipynb
feature_selection_elasticnet.ipynb
feature_selection_RFE.ipynb
feature_selection_RFECV.ipynb
All feature selection notebooks follow the same high-level pattern:
df = pd.read_pickle("../data/cleaned/NSDUH_2023_clean.pkl")
Four data-driven feature selection methods are applied, each in two optimization modes:
For each method and objective:
results/ directoryThe ranked feature lists from all methods are combined to create a unified Feature Agreement Table:
1 if selected in that method’s top-1000 otherwiseThe resulting agreement table is saved as:
results/feature_agreement_table.csv
The agreement table is then used, together with:
The finalized tier definitions are formalized in tiering_preparation.py, which exports tier-specific feature lists. These tier feature lists are subsequently used by all predictive modeling notebooks to evaluate model performance across tiers.
Using the finalized tier-specific feature sets, multiple predictive models are trained and evaluated to assess screening performance across tiers.
The following algorithms are implemented, each serving a distinct purpose:
predictive_model_logistics_regression.ipynbpredictive_model_random_forest.ipynbpredictive_model_xgboost.ipynbpredictive_model_lightGBM.ipynbThese models provide a balance between interpretability, non-linearity, and predictive performance.
A consistent data-splitting and validation strategy is used across all models and tiers:
The test set is completely held out and is never used during feature selection or hyperparameter tuning.
Model hyperparameters are optimized using stratified 5-fold cross-validation on the training data:
Results are aggregated as mean ± standard deviation across the 5 folds
Hyperparameter tuning is primarily optimized for recall, reflecting the screening objective of minimizing false negatives.
Model performance is evaluated using both threshold-independent and threshold-based metrics, with emphasis on screening utility.
AUC
Sensitivity (Recall)
Specificity
PPV (Precision)
NPV
Accuracy
F1 and F2 Scores
Unless otherwise stated, threshold-based metrics are computed at a fixed decision threshold of 0.50 on the held-out test set.
Model evaluation outputs include:
All results are written to the results/ directory.
To ensure clinical transparency and interpretability, SHAP was used to explain predictions from the best-performing LightGBM model.
shap_lightgbm_interpretability.ipynb
SHAP analysis was conducted on:
SHAP values were computed separately for the training and test sets to assess stability and generalization of feature contributions.
For both Tier 2 and Tier 3 models, the following were generated:
SHAP Summary (Beeswarm) Plots
SHAP Bar Plots
SHAP Dependence Plots (Top Features)
Tier 2 (Clinical Features):
Train and test SHAP patterns were highly consistent for Tier 2, indicating stable model behavior.
Tier 3 (Personalized Features):
Overall, SHAP analysis confirmed that the model relies on clinically intuitive, interpretable signals, with consistent feature effects across training and test sets.