Skip to content
dilliram-codePublic

About

An end-to-end machine learning project for predicting student mental health scores and generating actionable insights.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

MindMetrics AI – Mental Health Score Prediction API

Research Prototype for Academic Use
Developed by Dilli Ram Chaudhary

test: https://mentis-3-j3vn.onrender.com/

MindMetrics AI is a FastAPI-based machine learning REST API that predicts a student's Mental Health Score based on demographic information, academic lifestyle, social media usage, and daily habits.

The project is designed as an academic research prototype to demonstrate the deployment of a trained machine learning model using FastAPI, Pydantic, and Joblib.

Disclaimer: Predictions generated by this model are statistical estimates and must not be considered medical, psychological, or clinical advice.


Features

  • FastAPI REST API
  • Machine Learning Model Prediction
  • Input Validation using Pydantic
  • Country Grouping for unseen countries
  • Type-safe API
  • Ready for deployment
  • Automatic Swagger Documentation
  • High-performance inference

Tech Stack

  • Python
  • FastAPI
  • Pydantic
  • Pandas
  • NumPy
  • Joblib
  • Uvicorn
  • HTML
  • CSS
  • JS

Project Structure

MindMetrics-AI/
│
├── data/
|   └── Student Social Media And Mental Health Impact.csv
├── model/
│   └── Mental_Health_model.pkl
├── index.html
├── main.py
├── requirements.txt
├── README.md
└── .gitignore

Installation

1. Clone the repository

git clone https://github.com/dilliram-code/mentis.git
cd mentis

2. Create Virtual Environment

Windows

python -m venv venv
venv\Scripts\activate

Linux / macOS

python3 -m venv venv
source venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

4. Run the API

uvicorn main:app --reload

If your file has another name, replace main with your filename.

Example:

uvicorn app:app --reload

API Documentation

After starting the server:

Swagger UI

http://127.0.0.1:8000/docs

ReDoc

http://127.0.0.1:8000/redoc

API Endpoints

GET /

Returns a welcome message.

Response

{
  "Hello to mental score checker"
}

POST /predict

Predicts the Mental Health Score.

Request Body

{
  "age": 21,
  "gender": "Male",
  "country": "India",
  "academic_level": "Undergraduate",
  "most_used_platform": "Instagram",
  "purpose_of_use": "Entertainment",
  "average_daily_usage_hours": 5.4,
  "daily_unlocks": 120,
  "study_hours": 3,
  "physical_activity_hours": 1.5,
  "sleep_hours_per_night": 7,
  "stress_level": "Medium"
}

Successful Response

{
  "predicted_mental_health_score": 4.82
}

Run with Docker

Pull the image

docker pull dilliramchaudhary/mental-health-api:latest

Run the container

docker run -p 8000:8000 dilliramchaudhary/mental-health-api:latest

Open the API

http://localhost:8000/docs

Push updates

docker build -t mental-health-api .
docker tag mental-health-api:latest dilliramchaudhary/mental-health-api:latest
docker push dilliramchaudhary/mental-health-api:latest

📥 Input Features

Feature Type Description
age Float Student's age
gender String Male or Female
country String Country name
academic_level String Undergraduate, Graduate, High School
most_used_platform String Primary social media platform
purpose_of_use String Education, Entertainment, Networking, News
average_daily_usage_hours Float Average hours spent daily
daily_unlocks Integer Number of phone unlocks per day
study_hours Float Study hours per day
physical_activity_hours Float Physical activity hours per day
sleep_hours_per_night Float Average sleep duration
stress_level String Low, Medium, High, Very High

Country Handling

The model groups countries into predefined categories.

Supported countries include:

  • India
  • USA
  • Canada
  • Australia
  • UK
  • Germany
  • Mexico
  • Turkey
  • France

Any country outside this list is automatically categorized as Other.


Response

The API returns a predicted mental health score.

{
    "predicted_mental_health_score": 4.82
}

Validation Rules

Age

10 - 100

Daily Usage Hours

0 - 24

Study Hours

0 - 24

Physical Activity Hours

0 - 24

Sleep Hours

0 - 24

Daily Unlocks

0+

Example Using cURL

curl -X POST "http://127.0.0.1:8000/predict" \
-H "Content-Type: application/json" \
-d '{
    "age":21,
    "gender":"Male",
    "country":"India",
    "academic_level":"Undergraduate",
    "most_used_platform":"Instagram",
    "purpose_of_use":"Entertainment",
    "average_daily_usage_hours":5.5,
    "daily_unlocks":130,
    "study_hours":4,
    "physical_activity_hours":1,
    "sleep_hours_per_night":7,
    "stress_level":"Medium"
}'

Machine Learning Model

The API loads a pre-trained machine learning model using Joblib.

model = joblib.load("model/Mental_Health_model.pkl")

The model predicts a continuous Mental Health Score from the supplied input features.


Disclaimer

This project is intended solely for:

  • Academic research
  • Educational purposes
  • Machine learning demonstrations
  • API deployment practice

The predicted score does not represent a medical diagnosis and should never replace professional mental health evaluation or treatment.


Author

Dilli Ram Chaudhary

AI Research scholar | Aspiring Learning Engineer | Data Science Enthusiast


⭐ Support

If you found this project useful, consider giving it a ⭐ on GitHub to support the project.

About

An end-to-end machine learning project for predicting student mental health scores and generating actionable insights.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages