# Predicting depression among men who have sex with men in Ghana using machine learning algorithms

**Authors:** Abdulzeid Yen Anafo, LaRon E. Nelson, Leo Wilton, Vincent Uwumboriyhie Gmayinaam, Selasi Ocloo, Avanti Dey, Karli Montague-Cardoso, Karli Montague-Cardoso

PMC · DOI: 10.1371/journal.pmen.0000485 · 2025-11-20

## TL;DR

This study uses machine learning to predict depression in men who have sex with men in Ghana, finding that social isolation, stress, and stigma are key factors.

## Contribution

The study introduces a novel application of tree-based machine learning models to identify depression predictors in a marginalized population in Ghana.

## Key findings

- Random Forest achieved the highest accuracy in predicting depression among MSM in Ghana.
- External social isolation, perceived stress, and stigma due to same-sex behavior were the most consistent predictors of depression.
- Variables like resilience and community belonging also significantly contributed to depression prediction.

## Abstract

Men who have sex with men (MSM) in Ghana face heightened risks of depression due to pervasive stigma, social exclusion, and legal discrimination. Despite this, depression remains underdiagnosed and undertreated in this population. This study applied seven tree-based machine learning (ML) models using tree-based classifiers: Decision Tree, Random Forest, Gradient Boosting, AdaBoost, XGBoost, LightGBM, and CatBoost to identify key psychosocial predictors of depression in a sample of 225 MSM aged 18–60 years. The dataset included sociodemographic variables, perceived stress (PSS), social isolation (internal and external), behavioural risk indicators, and stigma-related measures. After handling missing values, data were pre-processed with feature standardization and one-hot encoding. The Synthetic Minority Over-Sampling Technique was applied to address class imbalance. Model performance was evaluated using 5-fold cross-validation and metrics such as accuracy, precision, recall, F1 score, and ROC AUC. Among all models, Random Forest achieved the highest accuracy for the prediction of depression amongst MSM in Ghana. Feature importance analysis revealed that external social isolation (ExtSocialIso2), perceived stress (PSS14), and stigma due to same-sex behaviour (StigmaSSB9) were the most consistent predictors of depression. Variables related to resilience, gender non-conformity stigma, and sense of community belonging also contributed significantly. Depression among MSM in Ghana is closely linked to social isolation, stress, and identity-based stigma. Machine learning models, especially ensemble methods, can effectively identify individuals at risk. These findings underscore the need for culturally tailored mental health interventions and inclusive policies that address stigma and promote social support among MSM in Ghana.

## Linked entities

- **Diseases:** depression (MONDO:0002050)

## Full-text entities

- **Diseases:** Depression (MESH:D003866)
- **Species:** Homo sapiens (human, species) [taxon 9606]

## Figures

4 figures with captions in the complete paper: https://tomesphere.com/paper/PMC12798198/full.md

---
Source: https://tomesphere.com/paper/PMC12798198