The gap between when a student starts struggling and when the university notices averages 4β6 weeks.
This system closes that gap β detecting behavioral distress signals in real-time and surfacing them
to counselors with AI-generated explanations, intervention plans, and personalized outreach drafts.
| Without This System | With This System |
|---|---|
| Counselors learn about struggling students after failed exams or withdrawals | Counselors are alerted 3β5 weeks earlier via behavioral pattern detection |
| No prioritization β all students treated equally | Students ranked by risk score; counselors focus limited time on highest-need cases |
| Counselors must manually dig through records before outreach | AI generates a full case packet: risk profile β intervention plan β personalized draft message |
| Institutional knowledge buried in manuals | Counselors ask questions in plain English; RAG system surfaces relevant guidance instantly |
| No historical view of how risk evolved | Week-by-week risk trajectory shows exactly when and why a student started declining |
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β OULAD Dataset (32,593 students Β· 7 modules) β
β studentInfo Β· studentVle Β· studentAssessment Β· Registrations β
ββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββ
β Feature Engineering
βΌ
βββββββββββββββββββββββ
β master_dataset β β Behavioral + academic features
β (32,593 rows) β
ββββββββββββ¬βββββββββββ
β ML Training
ββββββββββββββββΌββββββββββββββββ
βΌ βΌ βΌ
Logistic Random Forest XGBoost β
Regression AUC 0.975
β
β SHAP Explainability
βΌ
βββββββββββββββββββββββ
β scored_students β β Risk scores + tiers
β student_explanationsβ β Top-3 behavioral drivers
ββββββββββββ¬βββββββββββ
β
βββββββββββββββββββββΌβββββββββββββββββββββββββ
βΌ βΌ βΌ
AI Agent Multi-Agent RAG Knowledge
(Tool Use) Workflow Base (TF-IDF)
Counselor Chat RiskβInterventions Counseling Docs
βOutreach Draft
β
βΌ
ββββββββββββββββββββββββββββββββ
β Streamlit Dashboard β
β 7 Tabs Β· Real-time Streaming β
ββββββββββββββββββββββββββββββββ
Natural language interface powered by Claude Sonnet 4-6 with tool use. Counselors ask questions like:
"Show me the top 5 high-risk female students in module AAA"
"Why is student 30268 flagged? What should I do?"
"Which students in the 35-55 age group need immediate outreach?"
Claude dynamically calls structured data tools, retrieves live results, and responds with actionable, compassionate guidance.
For any student, a sequential multi-agent workflow generates a complete case packet via streaming output:
Agent 1: Risk Analyst β Structured behavioral risk profile
β (feeds output)
Agent 2: Intervention Advisor β 3 ranked interventions (48h / 1 week / 4 weeks)
β (feeds strategy)
Agent 3: Outreach Writer β Warm, human, non-algorithmic student message
Each agent has a specialized system context. Output streams in real-time so counselors see the analysis build live.
Quantifies exactly how many weeks earlier a tiered alert system would catch each student:
Early Signal Threshold ββββββββββββββββββββββββββββββββββββββββββββ
(risk > 0.50, 2wk run) β
βββββ 4-week intervention window ββββββΊβ
Standard Alert Threshold ββββββΌβββββββββββββββββββββββββββββββββββββ
(risk β₯ 0.66) Wk 6 Wk 10
Claude generates a publishable 3-paragraph research finding from the delay data in ACM/IEEE style.
12 institutional counseling guidance documents (crisis protocol, trauma-informed care, referral pathways, and more) made searchable via TF-IDF retrieval + Claude grounded Q&A. Every answer is cited to its source document.
Risk-aware scheduling with automatic urgency assignment:
| Risk Score | Urgency | Counselor Guidance |
|---|---|---|
| β₯ 0.80 | π΄ Immediate | Contact within 24 hours |
| 0.66β0.79 | π‘ Soon | Schedule within 48 hours |
| < 0.66 | π’ Routine | Monitor and check-in |
Every booking generates a confidential AI pre-meeting briefing tailored to the advisor type (Class Advisor / Therapist / Career Advisor / Professional Advisor).
| Model | AUC-ROC | Accuracy | F1 Score |
|---|---|---|---|
| Logistic Regression | 0.89 | 82% | 0.77 |
| Random Forest | 0.96 | 88% | 0.85 |
| XGBoost β | 0.975 | 91% | 0.88 |
These numbers are inflated by target leakage. Every behavioral feature is computed over the entire course, then used to predict an end-of-course label. For a student who withdrew in week 4,
engagement_spanandlast_activitydon't predict the withdrawal β they encode it. Sorting onlast_activityalone, with no model at all, scores AUC 0.908.Rebuilt with a hard time boundary (only data a counselor would have in week N):
Information available AUC PR-AUC % flagged @0.66 Precision Recall Full course (the table above) 0.973 0.979 47.4% 0.948 0.851 First 60 days 0.876 0.905 37.8% 0.910 0.651 First 30 days β the honest model 0.821 0.858 33.9% 0.880 0.565 First 14 days 0.750 0.782 30.6% 0.814 0.472 Reproduce with
python code/leakage_check.py. The tradeoff between lead time and accuracy is the real result of this project; the 0.975 is not.
Top behavioral predictors (SHAP-ranked):
engagement_spanβ How long the student stayed active in the courseengagement_declineβ Week-over-week engagement deterioration slopedropout_modulesβ Prior withdrawal history across modulesmean_scoreβ Average assessment scoreactive_daysβ Consistency of VLE presence
Temporal findings: Adding a 0.50 amber threshold delivers 3β5 additional weeks of intervention opportunity for ~80% of high-risk students.
Capstone_MentalHealth/
β
βββ code/
β βββ dashboard.py # Streamlit app β main entry point
β βββ ai_agent.py # Claude tool-use counselor chat agent
β βββ multi_agent.py # 3-agent streaming case analysis workflow
β βββ risk_monitor.py # Weekly trajectory simulation + crossing alerts
β βββ temporal_analysis.py # Intervention delay quantification
β βββ booking.py # Appointment booking + AI briefings
β βββ rag_kb.py # TF-IDF retrieval + grounded knowledge Q&A
β
βββ data/
β βββ scored_students.csv # ML predictions + risk tiers (32,593 students)
β βββ student_explanations.csv # SHAP top-3 behavioral drivers per student
β βββ shap_values.csv # Full SHAP value matrix
β βββ master_dataset.csv # Engineered feature matrix
β βββ [raw OULAD CSVs] # studentInfo, studentAssessment, etc.
β βββ kb/ # 12 counseling guidance documents
β
βββ models/
β βββ xgb_model.pkl # Primary XGBoost model (AUC 0.975)
β βββ rf_model.pkl # Random Forest model
β βββ lr_model.pkl # Logistic Regression baseline
β βββ scaler.pkl # StandardScaler for feature normalization
β
βββ plots/ # 14 generated visualization outputs
β βββ plot1_outcomes_demographics.png
β βββ plot5_roc_pr_curves.png
β βββ plot10_shap_summary.png
β βββ ...
β
βββ requirements.txt
βββ PROJECT_DOCUMENTATION.md # Full technical documentation (18 sections)
βββ Student_Mental_Health_EarlyWarningSystem.ipynb
git clone https://github.com/uvnikhil/student-mental-health-ews.git
cd student-mental-health-ews
pip install -r requirements.txt# Create .env file in project root
echo "ANTHROPIC_API_KEY=your_key_here" > .envGet your API key at console.anthropic.com.
The raw VLE interaction log (studentVle.csv) is too large for GitHub (433MB). Download it from the Open University OULAD page and place it in data/.
Open Student_Mental_Health_EarlyWarningSystem.ipynb and run all cells to:
- Engineer features and build
master_dataset.csv - Train and save all models
- Generate SHAP explanations
- Create all 14 visualization plots
streamlit run code/dashboard.pyOpen http://localhost:8501 in your browser.
OULAD β Open University Learning Analytics Dataset
Published by The Open University (UK) for academic research.
| Attribute | Value |
|---|---|
| Total student-module records | 32,593 |
| Modules (courses) | 7 (AAAβGGG) |
| At-risk students | ~4,100 (12.6%) |
| Behavioral features | VLE clicks Β· active days Β· engagement span Β· decline slope |
| Academic features | Assessment scores Β· submission rates Β· late submissions |
| Demographic features | Gender Β· Age band Β· IMD deprivation band |
Note: Demographic features are used for context display only β not as ML predictors β to prevent discriminatory risk scoring.
| Layer | Technology | Why |
|---|---|---|
| ML Model | XGBoost | Best AUC; tree-based = exact SHAP support |
| Explainability | SHAP TreeExplainer | Exact Shapley values per student |
| LLM | Claude Sonnet 4-6 | Tool use + streaming; ideal speed/capability balance |
| AI Framework | Anthropic Python SDK | Native tool use, streaming, multi-turn conversation |
| Dashboard | Streamlit | Python-native; handles state, chat, plots with zero HTML |
| Charts | Plotly + Matplotlib | Interactive trajectories + static SHAP visualizations |
| Retrieval | TF-IDF (scikit-learn) | Deterministic, fast, no embedding API needed |
| Environment | python-dotenv | Keeps API keys out of source code |
| Tab | What It Does |
|---|---|
| Overview | Cohort metrics, demographic breakdown, filterable student table |
| AI Counselor Chat | Multi-turn chat with Claude; tool call transparency panel |
| Multi-Agent Case | 3-agent streaming workflow: risk β interventions β outreach |
| Risk Monitor | Week-by-week trajectory playback with crossing alerts |
| Temporal Analysis | Intervention delay quantification + Plotly chart + research narrative |
| Appointment Booking | Risk-aware scheduling + AI pre-meeting briefings |
| Knowledge Base | TF-IDF RAG over 12 counseling guidance documents |
- Counselor in the loop β The system advises; humans decide. No autonomous action is taken.
- Behavioral signals only β Demographics are excluded from ML features. Risk is predicted from behavior, not identity.
- No clinical diagnoses β All output uses behavioral language. Specialist referral is always recommended for clinical concerns.
- Privacy-by-design β AI briefings for counselors never expose algorithmic language to students.
- Explainability first β Every risk flag comes with a ranked explanation of why. Black-box alerts are not acceptable in a wellbeing context.
Full technical documentation covering all 18 phases of the project β from dataset selection and feature engineering to SHAP explainability, agent architecture, and ethical design β is available in PROJECT_DOCUMENTATION.md.
| Name | Role |
|---|---|
| Nikhil Kumar Reddy | Lead Developer β ML pipeline, AI agents, dashboard |
| Nithin Sarva | Contributor β Data analysis, model evaluation |
| Jyothika Priyanka | Contributor β Research, documentation, evaluation |
- Dataset: OULAD β Kuzilek, J., Hlosta, M., & Zdrahal, Z. (2017). Open University Learning Analytics Dataset. Scientific Data, 4, 170171.
- LLM: Anthropic Claude β Claude Sonnet 4-6
- Explainability: SHAP β Lundberg & Lee (2017)
Built as a Capstone Project Β· 2026
Helping universities find struggling students before it's too late.