{"id":15176676,"url":"https://github.com/yc1909/mental_health_analysis","last_synced_at":"2026-03-09T10:31:31.532Z","repository":{"id":254589840,"uuid":"846991143","full_name":"yc1909/Mental_Health_Analysis","owner":"yc1909","description":"This is project that helps detect user's mental health based on user's description.","archived":false,"fork":false,"pushed_at":"2024-09-02T05:26:07.000Z","size":34612,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-31T19:12:24.507Z","etag":null,"topics":["bert-embeddings","chatbot","classification","exploratory-data-analysis","generative-ai","langchain","large-language-models","machine-learning","nlp","numpy","ollama","pandas","python","sentiment-analysis","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yc1909.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-24T14:36:48.000Z","updated_at":"2024-09-02T05:26:10.000Z","dependencies_parsed_at":"2024-08-24T15:49:06.496Z","dependency_job_id":null,"html_url":"https://github.com/yc1909/Mental_Health_Analysis","commit_stats":null,"previous_names":["yc1909/mental_health_analysis"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yc1909%2FMental_Health_Analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yc1909%2FMental_Health_Analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yc1909%2FMental_Health_Analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yc1909%2FMental_Health_Analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yc1909","download_url":"https://codeload.github.com/yc1909/Mental_Health_Analysis/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238337337,"owners_count":19455292,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bert-embeddings","chatbot","classification","exploratory-data-analysis","generative-ai","langchain","large-language-models","machine-learning","nlp","numpy","ollama","pandas","python","sentiment-analysis","tensorflow"],"created_at":"2024-09-27T13:40:17.888Z","updated_at":"2025-10-26T13:31:17.043Z","avatar_url":"https://github.com/yc1909.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mental Health Analysis\n\n\u003cimg src=\"assets/mental_health.png\" alt=\"Example Image\" width=\"1000\" height=\"250\"/\u003e\n\n## Overview\n\u003ca name=\"overview\"\u003e\u003c/a\u003e\n\nThis project aims to analyze and classify mental health statuses using Natural Language Processing (NLP) techniques and machine learning models. The final deliverable is a web application that predicts mental health conditions based on user inputs and also provides assistance to them based on their queries.\n\n## Table of Contents\n- [Overview](#overview)\n- [Project Structure](#project-structure)\n- [Dataset](#dataset)\n- [Installation](#installation)\n  - [Project Setup](#project-setup)\n- [Application Description](#application-description)\n  - [Web Application](#web-application)\n  - [User Interface](#user-interface)\n- [Chatbot Description](#chatbot-description)\n- [Model Description](#model-description)\n  - [Model Training](#model-training)\n  - [Model Artifacts](#model-artifacts)\n- [Results](#results)\n- [Conclusion](#conclusion)\n- [Acknowledgments](#acknowledgments)\n- [Contributions](#contributions)\n\n## Project Structure\n\u003ca name=\"project-structure\"\u003e\u003c/a\u003e\n```plaintext\nmental_health_analysis/\n│\n├── .gitignore\n├── README.md\n├── requirements.txt\n├── setup.py\n│\n├── application/\n│   ├── server.py\n│   ├── utils.py\n│   ├── chatbot.py\n│   ├── __init__.py\n│   ├── artifacts/\n│   │   └── model_mha.pkl\n│   ├── static/\n│   │   ├── home.css\n│   │   ├── index.css\n│   │   ├── assistant.css\n│   │   └── images/\n│   │       └── background3.png\n│   └── templates/\n│       ├── home.html\n│       ├── index.html\n│       └── assistant.html\n│\n├── assets/\n│   ├── classification_report.png\n│   ├── confusion_matrix.png\n│   ├── embedding_model.png\n│   ├── home.png\n│   ├── index_new.png\n│   ├── assistant.png\n│   └── analysis_demo.gif\n│   └── bot_demo.gif\n│\n└── model/\n    ├── mental-health-eda-modelling-bert-94-accuracy.ipynb\n    └── dataset/\n        └── Combined Data.csv\n```\n## Dataset\n\u003ca name=\"dataset\"\u003e\u003c/a\u003e\nThe dataset used for training and evaluating the model is sourced from https://www.kaggle.com/datasets/suchintikasarkar/sentiment-analysis-for-mental-health. It contains text labeled with various mental health conditions.\n\n## Installation\n\u003ca name=\"installation\"\u003e\u003c/a\u003e\n### Project Setup\n\u003ca name=\"project-setup\"\u003e\u003c/a\u003e\nAfter cloning the repository, navigate to the project directory and set up the project. Ensure you have Python 3.10.13 installed. Create and activate a virtual environment, then install the required dependencies:\n\n```bash\ngit clone \u003chttps://github.com/yc1909/Mental_Health_Analysis.git\u003e\ncd mental_health_analysis\nconda create -p venv python==3.10.13 -y\npip install -r requirements.txt\n```\n## Application Description\n\u003ca name=\"application-description\"\u003e\u003c/a\u003e\n\n### Web Application\n\u003ca name=\"web-application\"\u003e\u003c/a\u003e\nThe web application is built using Flask and provides an interface for users to input text and receive predictions on mental health conditions. The application structure is organized as follows:\n\n**Templates**: HTML files for the frontend `home.html`, `index.html`, `assistant.html`.\n\n**Static**: Contains CSS files `home.css`, `index.css`, `assistant.css`  and images `background3.png`.\n\n### User Interface\n\u003ca name=\"user-interface\"\u003e\u003c/a\u003e\nThe interface is designed to be intuitive and user-friendly. \n\n\u003cimg src=\"assets/index_new.png\" alt=\"index\" width=\"400\" height=\"400\"/\u003e \n\n\u003cimg src=\"assets/home.png\" alt=\"home\" width=\"300\" height=\"300\"/\u003e \u003cimg src=\"assets/assistant.png\" alt=\"assistant\" width=\"300\" height=\"300\"/\u003e \n\nBelow is a demo:\n\n\u003cimg src=\"assets/analysis_demo.gif\" alt=\"Demo GIF\" width=\"700\" height=\"700\"/\u003e\n\n## Chatbot Description\n\u003ca name=\"chatbot-description\"\u003e\u003c/a\u003e\n\nThe chatbot feature acts as a helpful assistant to answer queries related to mental health. The chatbot is implemented using FastAPI, and it leverages Langchain and Ollama models to generate responses. The interaction is managed through the following files:\n\n**assistant.html**: The HTML template for the chatbot interface.\n\n**assistant.css**: The CSS file for styling the chatbot interface.\n\n**chatbot.py**: The FastAPI server code that handles chatbot interactions.\n\nThe chatbot listens for user input through the /chat endpoint and provides responses using a predefined prompt and the Ollama language model. The responses are parsed using the StrOutputParser, ensuring clear and relevant answers. Below is a demo of the chatbot in action:\n\n\u003cimg src=\"assets/bot_demo.gif\" alt=\"Bot Demo GIF\" width=\"700\" height=\"700\"/\u003e\n\n## Model Description\n\u003ca name=\"model-description\"\u003e\u003c/a\u003e\n\n### Model Training\n\u003ca name=\"model-training\"\u003e\u003c/a\u003e\nThe model was trained using BERT, a state-of-the-art NLP model. The training process is documented in the Jupyter notebook `mental-health-eda-modelling-bert-94-accuracy.ipynb`. Given the size of the embedding model, it's recommended to run the notebook to generate embeddings. Below is an example of the code used for embedding:\n\n\u003cimg src=\"assets/embedding_model.png\" alt=\"embedding_model\" width=\"400\" height=\"400\"/\u003e\n\n### Model Artifacts\n\u003ca name=\"model-artifacts\"\u003e\u003c/a\u003e\nThe trained model is saved in the `artifacts` folder as `model_mha.pkl`. This model can be loaded to make predictions on new data.\n\n## Results\n\u003ca name=\"results\"\u003e\u003c/a\u003e\nThe model achieved 94% accuracy on the validation set. Below are the visualizations of the classification report and confusion matrix:\n\n**Classification Report:**\n\n\u003cimg src=\"assets/classification_report.png\" alt=\"classification_report\" width=\"400\" height=\"400\"/\u003e\n\n**Confusion Matrix:**\nThese figures demonstrate the model’s performance across various metrics like precision, recall, and F1-score.\n\n\u003cimg src=\"assets/confusion_matrix.png\" alt=\"confusion_matrix\" width=\"400\" height=\"400\"/\u003e\n\n## Conclusion\n\u003ca name=\"conclusion\"\u003e\u003c/a\u003e\nThis project successfully leverages NLP and machine learning to predict mental health conditions from textual data. The web application provides a practical interface for users to engage with the model and obtain predictions.\n\n## Acknowledgments\n\u003ca name=\"acknowledgments\"\u003e\u003c/a\u003e\n1. Dataset provided by `Kaggle`.\n2. BERT model from `TensorFlow Hub`.\n\n## Contributions\n\u003ca name=\"contributions\"\u003e\u003c/a\u003e\n\nContributions are welcome! Here's how you can help:\n\n1. Fork the repository on GitHub.\n2. Clone your fork to your local machine.\n3. Create a new branch for your feature or bug fix.\n4. Make your changes and commit them with descriptive messages.\n5. Push to your fork and submit a pull request.\n6. Ensure your changes pass existing tests and add new tests if necessary.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyc1909%2Fmental_health_analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyc1909%2Fmental_health_analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyc1909%2Fmental_health_analysis/lists"}