๐ง MindPulse AI โ Student Mental Health Prediction Web App
MindPulse AI is a Machine Learning-powered full-stack web application that predicts a student's Mental Health Score based on their daily habits (sleep duration, study hours, social media usage, physical activity, etc.).
๐ Live Demo & UI Preview
- Live Application: Click Here to Access MindPulse AI
๐ธ Application Interface
(Replace this placeholder with your actual UI screenshot path or link)
๐ Old Flow vs. New Flow (Project Evolution)
This project represents a major architectural upgrade in my Machine Learning engineering workflow towards production-ready standards:
| Feature / Step | ๐ด Old Flow | ๐ข New Flow (Upgraded) |
|---|---|---|
| Deployment | Streamlit UI | Render Web Service (FastAPI Backend + HTML/JS Frontend) |
| Preprocessing | Manual Ad-hoc Transformations | Scikit-learn ColumnTransformer (Automated & Leak-free) |
| Model Training | Manual Loops & Ad-hoc Scripts | Integrated ML Pipelines (Pipeline([('prep', ...), ('model', ...)])) |
| API & Validation | Raw JSON / Basic Flask | FastAPI + Pydantic Schema Validation |
| Frontend | Default Streamlit UI | Custom UI (Vanilla HTML5, Modern CSS, JavaScript Fetch API) |
๐ฎ Future Integration Plan (Upgrading Legacy Projects)
Through this project, I have mastered end-to-end production ML pipelines and modular deployment strategies. Going forward, I will retrofit and upgrade all my legacy ML and Deep Learning (DL) projects with these same features:
- โ๏ธ End-to-End Pipelines: Transitioning manual preprocessing and model fitting into unified Scikit-learn pipelines.
- โก FastAPI Migration: Replacing legacy Streamlit / Flask endpoints with fast, asynchronous, and modular FastAPI backends.
- ๐ก๏ธ Pydantic Validation & Security: Implementing strict schema validation, robust error handling, and environment-driven configurations (
.env) to securely manage API keys and backend endpoints.
๐ ๏ธ Project Architecture & Tech Stack
Machine Learning Pipeline (
notebook.ipynb):- Data cleaning, log transformations, and outlier treatment.
- Categorical feature encoding and scaling via
ColumnTransformer. - Model selection & evaluation: Linear Regression vs. Random Forest (Default & Tuned).
- Pipeline serialization using
joblib.
Backend API (
main.py):- FastAPI: Asynchronous and high-performance Web API framework.
- Pydantic: Input schema validation with field-level constraints (
age,study_hours,stress_level, etc.). - CORS Middleware: Safe cross-origin request handling.
Frontend (
index.html,script.js,style.css):- Interactive gauge dashboard for visual score representation.
- Dynamic error handling for both client-side and server-side validation.
๐ Model Performance Metrics
| Model | Test $R^2$ | Training $R^2$ | MAE | RMSE |
|---|---|---|---|---|
| Linear Regression | 0.7397 | 0.7236 | 0.5361 | 0.6760 |
| Random Forest (Default) | 0.8775 | 0.9808 | 0.3472 | 0.4636 |
| Random Forest (Tuned) | 0.8650 | 0.9547 | 0.3689 | 0.4869 |
๐ Repository Directory Structure
.
โโโ Mental_Health_Model.pkl # Trained Keras Artificial Neural Network (ANN) model
โโโ notebook.ipynb # Jupyter Notebook (EDA, Preprocessing, ANN Training)
โโโ Student_Social_Media # Dataset containing audio/speech acoustic features
โโโ main.py # FastAPI Backend
โโโ UI.png # UI Screenshot
โโโ .gitignore # Git ignore file
โโโ .gitattributes # Git attributes file
โโโ requirements.txt # Python dependencies
โโโ style.css # CSS for Streamlit frontend
โโโ script.js # JavaScript for Streamlit frontend
โโโ index.html # Streamlit frontend
git clone https://github.com/amirsohail100/MindPulse-AI-Student-Mental-Health-Prediction-Web-App.git
cd MindPulse-AI-Student-Mental-Health-Prediction-Web-App
streamlit run app.py
pip install -r requirements.txt
๐ License
This project is licensed under the MIT License.
๐ Author
๐ค Amir Sohail
MindPulse AI: A production-grade ML web app predicting student mental health scores based on daily lifestyle habits. Features an upgraded workflow: Scikit-learn Pipeline & ColumnTransformer for leak-free training, FastAPI + Pydantic for schema validation, and an interactive HTML/JS frontend live deployed on Render.
Evaluation results
- R2 Score on MindPulse AI -- Student Mental Health Prediction Modelself-reported0.860