GithubHelp home page GithubHelp logo

shubhamsaras / depression-analyzer-using-ml- Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 18.71 MB

Depression as a disorder has always been a focus of attention of researchers in India. Over the last 50-60 years, large number of studies has been published from India addressing various aspects of this commonly prevalent disorder. Here, we review data on various aspects of depression, originating from India. Depression is also often accompanied by anxiety. Research indicates that not only do the two conditions co-occur but that they overlap in vulnerability patterns. Depression is highly treatable. The condition is often cyclical, and early treatment may prevent or forestall recurrent episodes. Chrome browser is developed in a way where a person can surf through the internet in order to look for photos, videos, music, web series and many more websites reflecting their moods, feelings and sentiments. This creates an opportunity to analyze browser history data for user’s feelings and sentiments to investigate their moods and attitudes when they are surfing through the internet. Machine learning techniques identify high quality solutions of mental health problems among social media users. Therefore, here machine learning techniques are used to classify a person’s mental health based on Browser History (Chrome).

Python 100.00%

depression-analyzer-using-ml-'s Introduction

depression-analyzer

Monitor Chrome Browsing to detect levels of Depression Overview Google receives 63000 searches per second on any given day. An average person conducts 3-4 searches every day. According to a report 322 million people worldwide live with depression. Depression is the leading cause of disability worldwide. Almost 75% of people with mental disorders remain untreated in developing countries with almost 1 million people taking their lives each year.

Detecting earlier depression can be a huge step to address the mental illness and offer support to the people suffering from this terrible mental illness.

This depression can be easily detected in the first stages using the pattern seen in search queries. Text analysis, owner analysis (behavior patterns like searches-per-day), temporal analysis (time of day when people search), and visual analysis of pictures searched could be the parameters of detecting depression.

Women experience depression at roughly twice the rate of men. Fewer than half of the women who experience clinical depression will ever seek care. Interactive quizzes and chatbots could help them overcome this depression by providing information about a good doctor.

Thus, our application aims to reduce depression and instil mental peace and serenity.

alt text

Approach:

UI

  • The user interface is a chrome extension, i.e., a web-based UI
  • When the extension is enabled, it gives the depression levels of the person browsing on a scale of 1 to 10. A rating of 1 would indicate high levels of depression, while a rating of 10 will indicate low levels of depression.
  • This add-on additionally suggests measures and therapies to deal with depression. For example, depression relieving music, an appointment with a doctor or psychiatrist, etc.
  • There is also therapy chatbot or survey which helps to relieve depression and anxiety of the person. For now, it is just a simple chatbot created from Landbot.io. In the upcoming versions, we are planning to make it even more intelligent so as to tend to user needs as efficiently as possible.

Backend

  • The backend consists of Machine Learning algorithms and AI models to detect/predict depression levels.
  • Chrome browsing of the user is monitored. It retrieves data based on google search results of the person.For this purpose, we are working with the browser history of the user.
  • The textual data retrieved from chrome is analyzed using NLP algorithms, and predictions are made on the same

ML Algorithm in detail

There are two python files for predicting depression. In dep1.py, python code is written for creating model and save a moel. In the second file dep2.py, it takes saved model from first file and use it for prediction.

dep1.py - Creating Model

  • For model creation, NLP is used to extract depressive words by training a classifier to predict a rating (from 1 to 10) based on the text of the search History.
  • The dataset data.csv contains positive and depressive sentences collected from social media. In the dataset, Label for depressive sentences is “1” and for positive sentences, it is “0”.
  • The data is passed to a classifier which classifies the positive and the depressive sentences.
  • It preprocess the data before training. In processing, first it will break the text apart into separate tokens. Sentences are often separated (tokenized) wherever there is a period.
  • After that it removes most obvious non alphanumeric characters, (stop words) and any unnecessary punctuation.
  • The Algorithm uses the concept of TF(Term Frequency) and IDF(Inverse Document Frequency). Term Frequency is a count of how many times a word occurs in a given document. The Inverse Document Frequency is the the number of times a word occurs in a corpus of documents.
  • Tf-Idf is used to weight words according to how important they are. Words that are used frequently in many documents will have a lower weighting while infrequent ones will have a higher weighting. Below is the formula: w(i,j) = TF(i,j) * log(N / IDF(i)) Here, N = total sentences
  • For training it calculates the tf_idf score by summing tf-idf values and the total is then divided by the summation of all the document tf-idf values.
  • This tf-idf weighting scheme is used to score sentence’s relevance given a user query.
  • After creating a model, it saved the model in a file for further prediction.

dep2.py - Prediction based on Model

  • It loads the model that is created in dep1.py
  • Then it takes user’s chrome history as an input text (in csv format) and pass the each row to the model to predic
  • The predict function of model predicts the output on each row. The output is true if the sentence is depressive otherwise the output is false.
  • Rating is done based on the number of depressive sentences.

Dependencies

Make sure you have these installed on your system before running the application

Prediction using Machine Learning (dep1.py, dep2.py)

  • $ sudo apt-get install python3.6
  • $ sudo apt-get install pip3
  • $ sudo pip3 install -U nltk
  • $ sudo pip3 install pandas
  • $ sudo pip3 install numpy

For extracting Chrome History (browserhistory.py, gethistory.py, setup.py) Libraries used

  • import csv
  • import os
  • import sqlite3
  • import sys
  • from datetime import datetime
  • import copy
  • import shutil

Connection of Python Backend to Front end:

  • Install Flask - $ sudo pip3 install Flask
  • File structure: app.py
  • Templates(dir) - index.html - response.html
  • Running the Application Extract the compressed zip file Serenera.tar.xz or clone this repository.

Start the backend server

_ Open the terminal _ Type the command _ sudo python3 app.py _ Wait for some time for the server to be completely up and running _ Loading the Chrome Extension

Open Google Chrome browser

  • Click on the 3 dots on top right corner of the browser window
  • Choose More tools > Extensions
  • In the extensions browser tab, switch-on the Developer mode on the top right side
  • Choose Load unpacked
  • Locate and choose the extension folder from extracted file
  • The extension icon appears. You can navigate through the extension and view its features!

depression-analyzer-using-ml-'s People

Contributors

shubhamsaras avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.