UIJRT » United International Journal for Research & Technology

Opinion Analysis and Machine Learning Modeling for Depression Detection

Adebisi A. Baale, Olawumi R. Olasunkanmi, Felicia E. Adelodun and Adeniyi A. Adigun
Keywords: Bag of Words, Depression, Social Media, Machine Learning.

Total Views / Downloads: 4 

Cite ➜

Baale, A.A., Olasunkanmi, O.R., Adelodun, F.E. and Adigun, A.A., 2021. Opinion Analysis and Machine Learning Modeling for Depression Detection. United International Journal for Research & Technology (UIJRT), 2(4), pp.38-43.


Many people express opinions on social media sites when they suffer from mental disorders like depression, anxiety, and tension due to pressures, external environment, and other reasons. Such posts shared via Twitter, Facebook, and Instagram are used to identify a person’s state of mind. The situation ideation, which is rarely noticed on time until after a tragic consequence, are often earlier expressed overtly or covertly in social media posts. As a result, this research aimed at implementing four (4) classifiers- Logistic Regression (LR), Naive Bayes (NB), Random Forest (RF), and Decision Tree (DT) on two text-feature extraction techniques- Term Frequency- Inverse Document Frequency (TF-IDF) and Bag of Words (BOW). We split the Sentiment140 downloaded dataset from Kaggle into 75%, 25% training, and testing data to predict mental health depression in the tweet’s dataset. TF-IDF models produced the highest accuracy with DT (99%) and RF (99%), while the BOW extends the same performance with LR (99%). However, to mitigate the challenges of erroneous classification of depressive individuals as neutral, Receiver Operating Characteristic / Area Under Curve (ROC_AUC) scores of classifiers used was obtained. At the same time, the RF and DT produced 99%, the highest ROC_AUC score. Overall performance of models revealed that tree-based models performed better on the test data used in this research to classify and predict mental health depression in the tweet’s dataset.


  1. Insel, “Digital phenotyping: technology for a new science of behaviour,” Journal of the American Medical Association, Vol. 318, Issue 13, 1215-1216, 2017.
  2. S. Jini, and P. Prabu, “Detecting the magnitude of depression in Twitter users using sentiment analysis,” International Journal of Electrical and Computer Engineering (IJECE) Vol.9, No.4, 3247-3255, 2019.
  3. https://www.merriam-webster.com/dictionary/social%20media#:~:text=Log%20In-Definition%20of%20social%20mediaother%20content%20(such%20as%20videos)
  4. Kapur, A. Phillips, and T. Insel, “Why has it taken so long for biological psychiatry to develop clinical tests and what to do about it?” Molecular Psychiatry, Vol. 17, No.12, 1174, 2012.
  5. Thorstad, and P. Wolff, Behav Res, Vol.51: 1586–1600, 2019.
  6. Jain, B. Powers, J. Hawkins and J. Brownstein, “The digital phenotype,” Nature Biotechnology, Vol.33, No.5, 462-463, 2015.
  7. Elvevag, A. Cohen, M. Wolters, H. Whalley, V. Gountouna, K. Kuznetsova, and K. Nicodemus, “An examination of the language constructs in NIMH’s research domain criteria: time for reconceptualisation,” American Journal of Medical Genetics Part B: Neuropsychiatric Genetics, Vol.171, No.6, 904-919, 2016.
  8. H. Kietzmann, and H. Kristopher, “Social media? Get serious! Understanding the functional building blocks of social media,” Business Horizons, Vol.54, No.3, 241–251, 2011.
  9. H. Shaw, and L. M. Gant, “In defence of the Internet: The relationship between Internet communication and depression, loneliness, self-esteem, and perceived social support,” CyberPsychology and Behavior, Vol.2, 157–171, 2002.
  10. A. Mesfin, “Systematic review on the wide-spreading social media use and consequences of social media: mental health perspective, “ International Journal of Development Research, Vol.09, No.10, 30712-30714, 2019.
  11. Wang, C. Zhang, Ji Y., L. Sun, L. Wu, Z. Bao A, “Depression Detection Model Based on Sentiment Analysis in Micro-blog Social Network,” In Li J. et al. (eds) Trends and Applications in Knowledge Discovery and Data Mining. PAKDD 2013, Lecture Notes in Computer Science, Vol.7867. Springer, Berlin, Heidelberg, 2013.
  12. CSA Razak., M.A. Zulkarnain, S.H.A. Hamid, N. B. Anuar, M. Z. Jali, H. Meon, “Tweep: A system development to detect depression in Twitter posts,” In Alfred R., Lim Y., Haviluddin H., On C. (eds), Computational Science and Technology. Lecture Notes in Electrical Engineering, Vol.603, 2020.
  13. Hemanthkumar A. Latha, “Depression detection with sentiment analysis of tweets,” International Research Journal of Engineering and Technology (IRJET), Vol.06, No.05, 1197, 2019.
  14. “Machine Learning Mastery,” ACN: 626 223 336. https://machinelearningmastery.com/gentle-introduction-bag-words-model/

For Conference & Paper Publication​

UIJRT Publication - International Journal