Next Article in Journal
Regularization Total Least Squares and Randomized Algorithms
Next Article in Special Issue
Fuzzy Logic Prediction of Hypertensive Disorders in Pregnancy Using the Takagi–Sugeno and C-Means Algorithms
Previous Article in Journal
Propagation Computation for Mixed Bayesian Networks Using Minimal Strong Triangulation
Previous Article in Special Issue
Age-Related Macular Degeneration Detection in Retinal Fundus Images by a Deep Convolutional Neural Network
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Mental-Health: An NLP-Based System for Detecting Depression Levels through User Comments on Twitter (X)

by
Rafael Salas-Zárate
1,2,
Giner Alor-Hernández
2,*,
Mario Andrés Paredes-Valverde
3,
María del Pilar Salas-Zárate
3,
Maritza Bustos-López
2 and
José Luis Sánchez-Cervantes
2
1
Tecnológico Nacional de México/I. T. Zitácuaro, Av. Tecnológico No. 186, Zitácuaro 61534, Michoacán, Mexico
2
Tecnológico Nacional de México/I. T. Orizaba, Av. Oriente 9 No. 852, Col. E. Zapata, Orizaba 94320, Veracruz, Mexico
3
Tecnológico Nacional de México/I.T.S. Teziutlán, Fracción I y II S/N, Aire Libre, Teziutlán 73960, Puebla, Mexico
*
Author to whom correspondence should be addressed.
Mathematics 2024, 12(13), 1926; https://doi.org/10.3390/math12131926
Submission received: 12 May 2024 / Revised: 17 June 2024 / Accepted: 18 June 2024 / Published: 21 June 2024

Abstract

:
The early detection of depression in a person is of great help to medical specialists since it allows for better treatment of the condition. Social networks are a promising data source for identifying individuals who are at risk for this mental disease, facilitating timely intervention and thereby improving public health. In this frame of reference, we propose an NLP-based system called Mental-Health for detecting users’ depression levels through comments on X. Mental-Health is supported by a model comprising four stages: data extraction, preprocessing, emotion detection, and depression diagnosis. Using a natural language processing tool, the system correlates emotions detected in users’ posts on X with the symptoms of depression and provides specialists with the depression levels of the patients. By using Mental-Health, we described a case study involving real patients, and the evaluation process was carried out by comparing the results obtained using Mental-Health with those obtained through the application of the PHQ-9 questionnaire. The system identifies moderately severe and moderate depression levels with good precision and recall, allowing us to infer the model’s good performance and confirm that it is a promising option for mental health support.

Graphical Abstract

1. Introduction

According to the World Health Organization (WHO), mental health is a state of well-being in which a person is aware of their capabilities, works productively, faces everyday stress, and can contribute to their community. Unfortunately, there are currently several factors, such as economic stress, urbanization, chronic stress, adverse experiences, and the excessive use of social media, that have contributed to the rise in mental health issues, affecting around 450 million people worldwide [1], with depression being one of the leading causes of disability in the world [2].
Emotions are an essential part of people. Emotions express the most intimate aspect of a person and reflect their behavior. Some works have attempted to determine the relationship between emotions and symptoms of depression [3,4,5]; for example, in [6], the authors assessed the emotional states that occur across the clinical disorders of depression, anxiety, and mixed anxiety and depression. The emotion states were evaluated using the Basic Emotions Scale, which includes a set of simple and complex emotions rationally derived from the basic emotions of sadness, anger, fear, disgust, and happiness. According to Stets [7], emotions and sentiments are defined by their interactions.
Natural language processing techniques can detect emotions from the texts that users post on social networks. Social networks provide a space where individuals can share their experiences, thoughts, moods, ideas, and feelings and discuss their daily struggles with mental health. Some studies that combine social networks and mental illnesses have already been carried out [8,9,10]. As a result, social networks hold great potential as a data source for identifying individuals at high risk for developing mental illness and can help in providing timely intervention and improving public health [11]. Integrating computational approaches to understand mental health status could have a significant impact, allowing new data to support clinical care, identify risky behaviors, provide timely interventions, assess developing conditions, or reach populations that are difficult to access through traditional clinical methods [12].
Based on this understanding, this work establishes the relationship between six of Plutchik’s eight emotions and the 20 symptoms related to depression proposed by Ahmed et al. [13] and Chan [14]. Regarding depression diagnosis, most works carry out a binary classification, that is, they only provide a diagnosis regarding whether a patient has depression. In this case, a multiclass classification is proposed that allows for the five levels of depression to be diagnosed (through the PHQ-9 questionnaire). It is essential to mention that this work represents an attempt to determine the level of depression from the comments made by patients through their social networks (in this case, through X). This process is carried out by combining NLP techniques, specifically emotion detection from text and the correlation between emotions and depression symptoms. We developed an NLP-based system called Mental-Health as proof of concept for this model. The model has four stages: the post stage, preprocessing stage, emotion detection stage, and forecasting stage. Mental-Health identifies moderately severe and moderate depression levels with good precision and recall, allowing us to infer the model’s good performance and confirm that it is a promising option for mental health support. It is expected that Mental-Health could be used by medical professionals focused on mental illness as a support tool for detecting their patients’ depression levels and aiming to improve their mental situation.
The rest of this paper is defined as follows: Section 2 discusses related work, and Section 3 presents the materials and methods. The results, including a case study and evaluation, are described in Section 4. The discussion is presented in Section 5. Finally, Section 6 describes the conclusions and future work.

2. Related Work

Several studies that have employed social media and artificial intelligence to detect and assess depression have recently automatically received increased attention [15]. This section describes relevant works grouped into two main areas according to their focus: models and methods and applications and frameworks.

2.1. Models and Methods for Depression Detection

Some authors have proposed models for detecting depression. For example, Li et al. [16] designed a computational model for detecting depression expressions in Chinese social media posts (Sina Weibo). Specifically, 15,879 posts were obtained and analyzed. Skaik and Inkpen [17] designed a model for detecting depression in X users that is representative of the people in Canada. Using classical machine learning techniques, they achieved a 0.961 F1 score using 10-fold cross-validation. Shah et al. [18] proposed a deep learning-based model to detect depression by analyzing users’ textual posts. This model was evaluated using a Reddit dataset. Nusrat et al. [19] proposed a model for predicting depression using tweets from the Twitter database based on lexicon labeling. Explainable Artificial Intelligence was used to provide reasoning by highlighting the parts of tweets that represent type of depression.
Biradar and Totad [20] proposed a model to classify comments on Twitter as having depression or without depression. Rao et al. [21] proposed a model named Multi-Gated LeakyReLU for identifying depression in social media. The model worked on a post level and a user level to obtain users’ emotional moods. Malviya et al. [22] implemented baseline models, such as the Transformers model, Linear Classifiers Support Vector Machines, and the Reddit dataset, to achieve a better method of detecting users with depression. Yang et al. [23] designed a model to identify the degree of depression. They determined the levels of depression in users, and the way the scores are defined and can be related to the data. Wang et al. [24] proposed a node-and-linkage-feature-based model to detect a user with depression. Several psychologists supported them. The model used psychological criteria to detect depression. Stephen and Prabu [25] proposed a method to determine Twitter users’ levels of depression by combining emotions and sentiment scores. Angskun et al. [26] introduced a model to obtain users’ depressive moods from Twitter comments by applying demographic characteristics and a sentiment analysis. Leis et al. [27] conducted a study to identify the behavioral patterns of users and the linguistic features of tweets in Spanish to determine who generates them, which could indicate signs of depression. Nadeem [28] employed a crowdsourced method to compile a list of Twitter users to being diagnosed with depression. Alsagri and Ykhlef [29] presented a study that detected a depressed user by applying machine learning techniques based on tweets and network behavior.

2.2. Applications and Frameworks for Depression Detection

Some authors have developed systems to identify depression, such as Arora and Arora [30], who created a system that analyzes tweets for anxiety and depression using Support Vector Regression (SVR) and the Multinomial Naive Bayes algorithm as a classifier. Narynov et al. [31] created a system named VKontakte that collects data from a social network, applying keywords to detect depressive moods. Lin et al. [32] designed a system dubbed SenseMood, a deep approach to detect the psychological states of users on social media. The system classifies users with or without depression through a neural network. Ricard et al. [33] created a web-based application for detecting depression based on Instagram profiles. Linguistic features were extracted from Instagram comments to build a predictive model.
Regarding frameworks for depression detection, Hussain et al. [8] proposed a framework to identify depression. They developed an application to detect depression-related markers in Facebook users using machine learning classification techniques with a data-driven approach. They identified the dominant features to identify individuals with or without depression. Martínez-Castaño et al. [34] proposed a modular platform to obtain social media data with crawlers to extract relevant content. They built a classifier that follows the thread of posts sent by users and predicts the occurrence of depressive signs. Safa et al. [35] created an approach to obtain and analyze user comments on X sustained by mentions and used a framework to predict depression symptoms.
Chiong et al. [36] created an approach using social media texts for depression detection. The experimental results indicate that the proposed approach can detect depression even when the texts do not contain specific keywords. Tlatelpa et al. [37] designed an approach that analyzes sentiments defined in the comments through a new text representation that obtains their polarity, specializing in the classification framework for profiles of users with depression. Yang et al. [38] proposed a machine learning-based framework to detect depression in users of social networks. The framework is based on syntactic and semantic features and pragmatic features. The framework outperforms similar methods.
Various classifications of works enable the identification of depression through the texts that users post on social networks. When comparing these works, we can note that the primary distinctions between them and our work are as follows: Firstly, we identified the symptoms (20) experienced by individuals suffering from depression, which has not been addressed in any of the works we have analyzed. This identification is based on research about the symptoms of people suffering from depression. Once these symptoms were identified, specialists in psychology provided support to determine the relative impact of each symptom on individuals’ behavior, assigning them a scale from highest to lowest depending on their influence. Secondly, we related the symptoms and the weights obtained with the values of the emotions (8) that were extracted from the comments written on the social network X through the MeaningCloud tool. (It should be noted that several of the works analyzed used the eight emotions and polarity that were extracted with NLP tools, and from them, we determined depressive states. In our case, the research goes further since we not only used emotions and polarity to assess depression, but the extracted emotions were correlated with the weights of the symptoms already determined.) Once the correlation of symptoms with emotions was made and had the corresponding value, we evaluated it based on another study carried out in the way that psychologists typically evaluate patients with the PHQ-9 questionnaire to determine degrees of depression. This questionnaire has five levels, so we carried out an analysis supported by medical specialists so that these levels were equal to those used in our study (so we can identify our model as multiclass). Finally, the levels were determined, and the values obtained in the application of our model are presented as a depression prognosis, which is what a specialist uses to assess a patient’s condition.
The model proposed in this work differs from the existing ones because it is not based on machine learning algorithms, but on a correlation between depression symptoms and emotions detected on social network posts through NLP techniques. Mental health specialists supported this correlation. This model is described in the section below.

3. Materials and Methods

3.1. Model Description

To carry out detection based on the existing literature related to mental disorders, as an alternative solution to the process for identifying levels of depression, Mental-Health is based on a four-stage model that would be able to identify a set of emotions related to symptoms and, with the application of NLP, obtain levels of depression detected in an individual based on what was written in their comments on social networks. The model begins with the study of the psychological emotions that occur in human beings, specifically based on the survey carried out by Plutchik [39]. This study has been widely used in the identification of emotions based on the particularity with which these emotions are defined and which has served to develop research that deals with the way a person feels [40,41,42,43]. In his work, Plutchik [44] defined eight primary emotions, joy, trust, fear, surprise, sadness, aversion, anger, and anticipation, and possible combinations.
Likewise, our work is mainly based on the studies carried out by Ahmed et al. [13] and Chan [14]. They defined 20 symptoms related to depression: sadness, pessimism, past failure, loss of pleasure, guilty feeling, punishment feeling, self-dislike, self-criticalness, suicidal thoughts, crying, agitation, loss of interest, indecisiveness, worthlessness, loss of energy, changes in sleeping pattern, irritability, changes in appetite, concentration difficulty, and tiredness. The relationship between the symptoms and the primary emotions already mentioned and obtained with a natural language processing tool are those that allow us to establish a parameter for identifying the levels of depression in the texts that users write on social networks and that are schematically represented in the model defined for such a task. To achieve this, interviews were conducted with a group of three experienced specialists in the psychological care of patients to obtain timely information on what symptoms a person with depression suffers from. Additionally, this group of specialists weighted each of the symptoms using the AHP method [45] to identify the most relevant symptoms of depression. This method makes decisions between alternatives based on the variables to be managed that have a hierarchical value, allowing us to transform qualitative criteria into quantitative ones. Due to its value in decision making, it has been used in various fields of research since it is the best alternative [46,47,48,49].

3.2. Correlation between Emotions and Symptoms

Within the research activities, a significant step was to establish the correlation of emotions with symptoms of depression. Next, the process of determining the degree of correlation between emotions and symptoms is described below.
  • A group of three experts determined the weight that each of the symptoms has with respect to the others using the Analytical Hierarch Process (AHP), which is a method for making decisions that allows for priority scales to be generated based on expert judgments expressed through pairwise comparisons via a preference scale [50]. The result of this stage can be seen in Appendix A.
  • Once the weighted matrix of depression symptoms was obtained, the next step was to obtain the normalized pairwise comparison matrix. This technique has been widely used to tackle the subjective and objective judgments about qualitative and/or quantitative criteria in multi-criteria decision making [51], where each data point obtained in every column in the first matrix is divided by the sum of the score of each symptom represented in that same matrix. To indicate how the weights assigned to each symptom were obtained concerning the other, they received a weight determined by psychologists. This weight could be 1, 3, 5, 7, and 9 per degree, with the highest value compared to the others, or there could be intermediate values such as 2, 4, or 6. In the first row, we can see the values of 1.00, 0.50, 2.00, etc., and in the first column, we can see the values of 1.00, 2.00, 0.50, etc. The values obtained at the intersection are the weights each symptom has divided according to the previous values (1, 2, 3, 4, 5, 7, and 9) concerning the others. The sum of the values obtained in each comparison (last row) is the value that will be used to obtain the normalized pairwise comparison matrix (see Appendix B).
  • The weights of each of the symptoms of depression in relation to the others were obtained, and the resulting percentages were converted to integer values (see Appendix C).
  • Three steps are utilized in multi-criteria decision making to obtain alternative relations: (1) Determine the relevant criteria and alternatives. (2) Attach numerical measures to the relative importance of the criteria and the impacts of the alternatives on these criteria. (3) Process the numerical values to determine the ranking score of each alternative [52]. In our study, to determine the correlation between emotions and symptoms of depression, each expert defined the corresponding symptom–emotion relationships. The responses that specialists agreed on were accepted, and the rest were discarded (see Appendix D). It should be clarified that joy and trust were not related to the symptoms of depression in any of the cases, so only six emotions at most were related to each of the symptoms.
  • According to Lawshe [53], if the subject matter experts are generally perceived as true experts, then it is unlikely that there is a higher authority on the content validity of one test. As mentioned, three psychologists validated our model. This group of experts distributed 10 points between the emotions related to a symptom according to the importance they felt the emotion has concerning the symptom (see Appendix E).
  • The values given by each expert were added to obtain a single value for each symptom–emotion relationship (see Appendix F).
  • The final weights of the emotions regarding symptoms of depression are obtained in this part. It should be noted that the weight of the emotions regarding symptoms is used in decimal value so that when multiplied by the weight of the symptom, the sum of the final weights accumulates a total of 100 (see Appendix G).
  • The weight of the emotions regarding symptoms of depression (values obtained in step 7) is multiplied by the weight of symptoms obtained in the first phase of this process (step 3) and then multiplied by the emotion value obtained by the MeaningCloud tool to obtain the final score that indicates the total value obtained from the model. Figure 1 shows the correlation between symptoms and emotions resulting from this process. As can be seen, there is a strong correlation between the emotion of aversion and the symptom of self-criticalness, between the emotion of sadness and the symptom of crying, as well as between the emotion of surprise and the symptom of agitation.

3.3. Model for Determining Levels of Depression

The model for determining levels of depression is outlined as follows: It starts with collecting comments from social media, and then establishing the correlation between emotions and identified symptoms, and finally calculating the overall level of depression.
The model and its stages are shown in Figure 2.
Next, each model stage is described in detail.
Data extraction: This stage of the model is where user comments are obtained through the social network. In the case of comments on X, it is important to indicate that the characteristics of the network must be followed in terms of the maximum number of characters, which is 280. It is also important to obtain the date and time of the comment to obtain the time lapse.
Preprocessing: Data preprocessing is a significant and essential stage whose primary goal is to obtain final datasets that can be considered correct and valid for further data mining algorithms [54]. This module performs NLP preprocessing tasks to make collected data suitable for analysis and modeling and to achieve good performance on emotion detection tasks, specifically hashtag extraction, hashtag segmentation, URL removal, mention removal, tokenization, lower-case conversion, stopword removal, and stemming.
Emotion detection: In this stage, MeaningCloud API uses NLP techniques to identify entities and concepts from the text [55]. The Emotion Recognition pack is based on Robert Plutchik’s Wheel of Emotions because of its clarity and potential [56]. Likewise, the emotions listed are obtained: sadness, happiness, anger, aversion, trust, fear, surprise, and anticipation.
Depression diagnosis: This stage is further divided into two parts: the correlation between emotions and symptoms of depression and the diagnosis of the level of depression. These two parts are described below.
Correlation between emotions and symptoms: This process is responsible for establishing the relationship between emotions and symptoms of depression (Section 3.2).
Diagnosing the level of depression: The total depression value (final score) shows the predefined value to indicate the value of the prognosis and is presented to the medical specialist. Finally, the values of symptoms and emotions collected by the NLP-based system are evaluated.
An NLP-based system called Mental-Health was developed as proof of concept of the proposed model. Next, we describe the Mental-Health architecture.

3.4. Mental-Health Architecture

According to Perry and Wolf [57] software architecture is a set of architectural elements with a particular form. They distinguish three different classes of architectural elements: processing elements, data elements, and connecting elements. In such a way, we designed software as proof of concept called Mental-Health. The software architecture created is shown below to indicate the elements that integrate it, which will allow us to provide an idea of how information is interconnected and processed to clearly illustrate the structure of our model applied to the software. This architecture shows how each layers interact, as shown in Figure 3.
Presentation layer. The architecture workflow begins with the login and user access to the Mental-Health platform. This layer corresponds to a set of graphic interfaces developed where the main Mental-Health functionalities are displayed, such as the medical specialist dashboard, patient profile, scheduled appointments, patient list, list of comments extracted from the patient, diagnosis, emotions and symptoms obtained, prognosis, and reporting.
Service layer. The service layer is divided into four modules. The first is the social media data extraction/collection module, which is responsible for extracting and gathering comments from registered users on social media. The NLP-based preprocessing module is responsible for carrying out NLP-based preprocessing tasks to effectively understand and analyze the data collected. The emotion detection module is responsible for detecting emotions from the text; this module is where the emotion–symptom correlation that was previously explained is applied. The diagnosis module is responsible for applying the depression detection model and determining the value that allows for the depression level to be determined.
Persistence layer. This layer is responsible for storing patient information, such as ID, name, the clinic where they are treated, email, mobile phone number, registration date, status, family background, and the information corresponding to the comments written in X that are used to make the diagnoses of depression organized in the corresponding dataset. It stores each of the social network analysis reports or depression prognoses and ensures they are always available so that they can be viewed by a medical specialist at any time.
The hardware and software tools used for the implementation of Mental-Health are shown in Appendix I.

4. Results

4.1. Case Study: Detecting Users’ Depression Levels

This case study aims to determine how efficient Mental-Health is in detecting users’ depression levels through social network posts. For this purpose, a group of 20 patients were involved; precisely, 13 were previously diagnosed as depressed, and 7 were non-depressed. The sample included people between the ages of 15 and 56 of both the male and female sexes. These patients have an X account and computing devices through which they post whenever they want. They were asked to publish one daily tweet describing their feelings over a period of two weeks. This time was selected since it is the period needed to apply a PHQ-9 questionnaire to detect depression. It is essential to mention that the people were asked to publish at least one tweet per day because, according to the specialists, it is very complex for patients with depression to write extensively about their condition.
It should be mentioned that the consent of all patients was requested through a signature authorizing the researchers to take their information to extract their tweets to identify their levels of depression through the Mental-Health platform and with the advice of the medical specialists who have been treating them. The following sections describe the most relevant aspects of this case study.
Patient List. This section shows the doctor’s patient list (see Figure 4). The information presented include the patients’ names, clinics, emails, mobile device numbers, registration dates, statuses, and actions to be carried out.
Patients’ posts. When the doctor selects a patient, Mental-Health shows the patient’s posts obtained from a social network, in this case, from X (see Figure 5).
Detection of patients’ depression levels. Appendix H presents the algorithm detailing the internal functioning of the depression detection model within the Mental-Health system to provide a more precise representation of its operation.
To start the depression screening, Table 1 shows the emotion scores obtained from the patients’ posts using MeaningCloud. This tool assigns a value to each emotion detected on a scale from 0 to 1, where a value close to 0 denotes a weak emotion and a value close to 1 denotes a stronger emotion.
Next, to determine the depression scores of the patients, the model proposed in this work (Table 2) and the emotion values obtained through the MeaningCloud tool (Table 1) were used, resulting in the scores presented in Table 2. Table 2 contains a new column named “Normalized value” that represents the sum of the multiplications of the final weight value by the emotion value. Furthermore, at the end of Table 2, the depression score is presented, which was obtained by adding all normalized values. Specifically, the formula used to obtain the depression score is shown below.
Depression score =
Normalized Value1(FinalWeight1*ApiValue1 + FinalWeight2*ApiValue2 + … + FinalWeightN*ApiValueN)
+
Normalized Value2(FinalWeight1*ApiValue1 + FinalWeight2*ApiValue2 + … + FinalWeightN*ApiValueN)
+

N
Once the depression score is obtained, Mental-Health determines a patient’s depression level according to the ranges presented in Table 3. The three medical specialists established these ranges.
Also, Mental-Health provides a description of the symptoms detected, which contains the scores obtained using the model (refer to Figure 6).
Finally, Mental-Health also provides users with the emotions detected from the posts (see Figure 7).

4.2. Evaluation

To determine whether Mental-Health allows for patients’ depression levels to be correctly detected from social network posts, the results were compared with those obtained through the PHQ-9 questionnaire [58,59], which allowed us to identify the depression level that a person can have in a period of two weeks. This questionnaire consists of nine questions with four possible responses (0 to 3), resulting in a score between 0 and 27. Based on the obtained score, a patient is diagnosed with a depression level according to the following ranges:
  • A score of 0–4: This indicates an absence or minimal presence of depressive symptoms. This suggests that a person is unlikely to have a significant depressive disorder.
  • A score of 5–9: This indicates a mild presence of depressive symptoms. The person may experience some depressive symptoms, but this is not considered a significant level of depression.
  • A score of 10–14: This indicates a moderate presence of depressive symptoms. The symptoms can affect the person’s daily life, and they may require interventions or treatment.
  • A score of 15–19: This indicates a moderately severe presence of depressive symptoms. The person is likely experiencing significant difficulties due to depressive symptoms, and it may be appropriate to consider therapeutic intervention.
  • A score of 20 or more: This indicates a severe presence of depressive symptoms. The person may be experiencing significant depression that can affect their daily functioning. Urgent therapeutic intervention is recommended.
As can be seen, both the PHQ-9 questionnaire and Mental-Health define five depression levels (see Figure 8).
First, all 20 patients were asked to answer the PHQ-9 questionnaire, and then the obtained results were compared with the depression levels provided by Mental-Health. The dataset obtained from the comments of the 20 patients is available at the following link: https://mental-health.com.mx/datasets/Dataset-patients.xlsx (accessed on 1 April 2024).
In any study utilizing information processing, it is crucial to specify how the data were extracted and which data points are significant. Presented below is the information that we consider important for dataset processing. The description and details of the dataset shown below can be found in Appendix J, Appendix K, Appendix L, Appendix M, Appendix N and Appendix O.
  • Many comments range from 20 to 30 characters (Appendix J).
  • Most comments are 8 to 10 words long (Appendix K).
  • The most repeated words are “I feel” (En) = “siento” (Sp) and “Restless” (En) = “inquieto” (Sp), to mention a few (Appendix L).
  • The most common bigrams are “I feel” (En) = “me siento” (Sp) and “I can’t” (En) = “no puedo” (Sp) (Appendix M).
  • The most common trigrams are “I do not feel “(En) = “no me siento” (Sp) and “I feel very” (En) = “me siento muy” (Sp) (Appendix N).
  • A word cloud of the dataset was created (Appendix O).
Concerning the presented dataset, it is necessary to indicate that the three medical specialists who helped us define the depression detection model through texts provided us with information about their patients from the corresponding ethics collection. In addition, all of the patients who provided information consented to our use of the data, signed a data use approval document, and wrote their comments to process them and obtain valuable data regarding the determination of depression levels. These specialists provided us with information on 100 patients. However, only 20 of these patients were included in the dataset because only those 20 met the requirement of writing at least one comment per day during the 14-day evaluation period. The rest of the patients wrote sporadically, and to validate their comments with the PHQ-9 questionnaire, they needed to write for 14 consecutive days. Once the users wrote the texts on social networks with the values obtained using Mental-Health, we create the confusion matrix to obtain the efficiency of the application of our system. It should be noted that most of the patients had a history of depression, which is why they did not write much. Furthermore, comments were only collected at the express request of the medical specialists.
Many clinical tests are used to indicate a disease. The tests correctly identify patients with or without a disease [60]. In this work, the confusion matrix [61] was used to determine the classification performance of the proposed model. The diagnosis provided by Mental-Health was compared with the diagnosis provided by the specialists. Table 4 presents the confusion matrix obtained using Mental-Health; furthermore, the statistical values are presented.
We can infer several findings about the classification performance of the model for different depression levels as assessed using the PHQ-9 questionnaire:
  • Severe Depression: The model did not identify cases of severe depression because there were no people who had comments that indicated a high level of depression.
  • Moderate Depression: The model shows excellent precision and recall for moderate depression. This indicates that the model correctly identifies all cases of moderate depression, and all predictions made by the model for moderate depression are accurate.
  • Mild Depression: The model has a precision of 1.0. Since only two cases were presented, its recall is 0.5; at this point, the score of the incorrect case, “minimal”, was very close to “mild” (the correct one), which was due to the similarity in the comments.
  • Minimal Depression: The model’s precision for minimal depression is 0.8, meaning that 80% of the cases predicted as minimal depression are correct. Its recall is 0.57, indicating that it correctly identifies 57% of the cases of minimal depression. In addition to this point, we can say that in some cases, very negative or very positive comments on the emotions with the highest values can affect the obtained results.
Overall, the model performs well in identifying moderately severe and moderate depression levels with good precision and recall.
Given the above data, Mental-Health is a good tool for determining depression levels since the patients were diagnosed with depression by the specialists. At the same time, some of the cases did not have a previous diagnosis of depression. Therefore, the first parameter that indicates whether they have any depressive traits is a good indicator. Secondly, the average falls within the appropriate range as it matches the values defined in Mental-Health concerning the values determined using the PHQ-9 questionnaire.

5. Discussion

Mental illnesses have become a global health problem because the people who suffer from them present characteristics such as a loss of interest in work, fun, and family relationships. Among these mental illnesses, the one that most affects the population is depression, because in extreme cases of this illness, people die by suicide. The coronavirus 2019 (COVID-19) pandemic contributed to increased suicidal behaviors [62]. This fact marked a milestone in the magnification of mental illnesses such as depression due to its explosive growth. Strategies have been defined to identify depression in its earliest stage to provide medical treatment that can prevent people’s symptoms from increasing and help improve their moods with the aim of avoiding suicide.
The detection of depression was first carried out through questionnaires that specialists in mental illnesses applied to patients, such as the PHQ-9 questionnaire or the Hamilton questionnaire [63]. However, with the advent of new information and communication technologies, the detection of depression can be carried out through the texts that users write on their social networks. In this work, an NLP-based system for identifying levels of depression through social network posts was presented. The development of Mental-Health involved three specialists in psychology and psychiatry who helped establish the appropriate values for the symptoms and emotions found. In future work, it is planned to adapt Mental-Health so that it helps to identify diseases related to depression, such as anxiety.

6. Limitations

In this work, the proposed model as well as Mental-Health have the following limitations:
  • Due to the characteristics of the information obtained by medical specialists which the evaluated patients had to provide, the dataset presented 20 patients with their corresponding comments made each day.
  • The model shows some limitations in identifying cases of mild and minimal depression. Further improvements might be necessary to enhance its performance for these categories.
  • To determine effectiveness in detecting depression, a comparison must be made with the ranges used by the PHQ-9 questionnaire.
  • Mental-Health does not identify the intentions of certain hidden phrases in texts, such as irony, sarcasm, or figurative language.
  • Mental-Health does not identify new forms of textual expression, such as emoticons.
  • Mental-Health is only applicable to the Spanish and English languages.

7. Conclusions

Great efforts have been made to detect the initial symptoms of depression and to be able to influence the earliest stages of this disease to help reduce the number of people who suffer from it. Even though different types of works have been conducted on matters that are related to the topic in this study, like models, methods, approaches, systems, studies, web applications, frameworks, classifiers, analyses, platforms, and algorithms, we have not found any study that focuses on the detection of the symptoms that a person can present and on the relationship that exists with the emotions detected through the analysis of feelings using comments that users write on social networks. Overall, the proposed model offers a systematic and data-driven approach to detecting levels of depression based on user-generated content on social networks. By leveraging psychological research, NLP techniques, and expert judgment, it provides a valuable tool for identifying individuals needing mental health support. This allows us to feel motivated by being able to contribute to the health sector to improve people’s states and, based on the work carried out, focus on mental illnesses related to depression, such as anxiety, which allows us to extend our model to become the basis for the detection of other mental illnesses.

Author Contributions

Conceptualization, R.S.-Z., G.A.-H. and M.A.P.-V.; methodology, R.S.-Z. and M.d.P.S.-Z.; software, J.L.S.-C. and M.d.P.S.-Z.; validation, M.A.P.-V., J.L.S.-C. and M.B.-L.; formal analysis, R.S.-Z. and G.A.-H.; investigation, M.d.P.S.-Z. and M.A.P.-V.; data curation, R.S.-Z. and G.A.-H.; writing—original draft preparation, R.S.-Z. and M.d.P.S.-Z.; writing—review and editing, R.S.-Z. and G.A.-H.; visualization, R.S.-Z. and M.B.-L.; supervision, M.A.P.-V. and M.B.-L.; project administration, J.L.S.-C. and M.A.P.-V. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Institutional Review Board Statement

All subjects gave their informed consent for inclusion before they participated in the study called “Mental-Health: An NLP-Based System for Detecting Depression Levels through User Comments on Twitter (X)”. This study was conducted in accordance with the Declaration of Helsinki, and the protocol was approved by the Ethics Committee of PRODEP-Program for Teacher Professional Development (project identification code: 511-6/2020-6794; date of approval: 9 October 2020).

Informed Consent Statement

Informed consent was obtained from all subjects involved in this study.

Data Availability Statement

The data will be made available by the authors on request.

Acknowledgments

All of the researchers thank Mexico’s Secretariat of Public Education (SEP) through the PRODEP program, Tecnológico Nacional de México (TecNM), and Mexico’s National Council of Humanities, Sciences and Technologies (CONAHCYT) for supporting this work.

Conflicts of Interest

The authors declare no conflicts of interest.

Appendix A

Table A1. Weighted matrix of depression symptoms.
Table A1. Weighted matrix of depression symptoms.
FeatureSAPEPFLPGFPUSDSCSTCRAGLIINWOLECSIRCACDTI
SA1.000.502.000.503.000.502.000.331.000.251.000.501.002.003.001.001.001.001.001.00
PE2.001.002.000.504.000.502.000.502.000.332.001.002.003.004.002.002.002.002.002.00
PF0.500.501.000.502.003.001.000.251.000.140.500.500.501.002.000.500.500.500.500.50
LP2.002.002.001.004.000.502.000.502.000.332.001.002.003.004.002.002.002.002.002.00
GF0.330.250.500.251.000.170.500.170.330.140.250.250.250.501.000.330.330.330.330.33
PU2.002.000.332.006.001.004.000.503.000.502.002.002.003.005.003.003.003.003.003.00
SD0.500.501.000.502.000.251.000.251.000.140.500.500.501.002.000.500.500.500.500.50
SC3.002.004.002.006.002.004.001.003.000.502.002.002.004.006.006.003.003.003.003.00
ST1.000.501.000.503.000.331.000.331.000.251.000.501.002.003.001.001.001.001.001.00
CR4.003.007.003.007.002.007.002.004.001.002.003.003.005.007.004.004.004.004.004.00
AG1.000.502.000.504.000.502.000.501.000.501.001.001.002.003.002.002.002.002.002.00
LI2.001.002.001.004.000.502.000.502.000.331.001.002.003.004.002.002.002.002.002.00
IN1.000.502.000.504.000.502.000.501.000.331.000.501.002.003.002.002.002.002.002.00
WO0.500.331.000.332.000.331.000.250.500.200.500.330.501.002.000.500.500.500.500.50
LE0.330.250.500.251.000.200.500.170.330.140.330.250.330.501.000.330.330.330.330.33
CS1.000.502.000.503.000.332.000.171.000.250.500.500.502.003.001.001.001.001.001.00
IR1.000.502.000.503.000.332.000.331.000.250.500.500.502.003.001.001.001.001.001.00
CA1.000.502.000.503.000.332.000.331.000.250.500.500.502.003.001.001.001.001.001.00
CD1.000.502.000.503.000.332.000.331.000.250.500.500.502.003.001.001.001.001.001.00
TI1.000.502.000.503.000.332.000.331.000.250.500.500.502.003.001.001.001.001.001.00
Total26.1717.3338.3315.8368.0013.9542.009.2528.176.3519.5816.8321.5843.0065.0032.1729.1729.1729.1729.17
Sadness = SA, Pessimism = PE, Past Failure = PF, Loss of Pleasure = LP, Guilty Feeling = GF, Punishment Feeling = PU, Self-Dislike = SD, Self-Criticalness = SC, Suicidal Thoughts = ST, Crying = CR, Agitation = AG, Loss of Interest = LI, Indecisiveness = IN, Worthlessness = WO, Loss of Energy = LE, Changes in Sleep Pattern = CS, Irritability = IR, Changes in Appetite = CA, Concentration Difficulty = CD, Tiredness = TI.

Appendix B

Table A2. Normalized pairwise comparison matrix.
Table A2. Normalized pairwise comparison matrix.
FeatureSAPEPFLPGFPUSDSCSTCRAGLIINWOLECSIRCACDTITotal
SA0.040.030.050.030.040.040.050.040.040.040.050.030.050.050.050.030.030.030.030.030.04
PE0.080.060.050.030.060.040.050.050.070.050.100.060.090.070.060.060.070.070.070.070.06
PF0.020.030.030.030.030.220.020.030.040.020.030.030.020.020.030.020.020.020.020.020.03
LP0.080.120.050.060.060.040.050.050.070.050.100.060.090.070.060.060.070.070.070.070.07
GF0.010.010.010.020.010.010.010.020.010.020.010.010.010.010.020.010.010.010.010.010.01
PU0.080.120.010.130.090.070.100.050.110.080.100.120.090.070.080.090.100.100.100.100.09
SD0.020.030.030.030.030.020.020.030.040.020.030.030.020.020.030.020.020.020.020.020.02
SC0.110.120.100.130.090.140.100.110.110.080.100.120.090.090.090.190.100.100.100.100.11
ST0.040.030.030.030.040.020.020.040.040.040.050.030.050.050.050.030.030.030.030.030.04
CR0.150.170.180.190.100.140.170.220.140.160.100.180.140.120.110.120.140.140.140.140.15
AG0.040.030.050.030.060.040.050.050.040.080.050.060.050.050.050.060.070.070.070.070.05
LI0.080.060.050.060.060.040.050.050.070.050.050.060.090.070.060.060.070.070.070.070.06
IN0.040.030.050.030.060.040.050.050.040.050.050.030.050.050.050.060.070.070.070.070.05
WO0.020.020.030.020.030.020.020.030.020.030.030.020.020.020.030.020.020.020.020.020.02
LE0.010.010.010.020.010.010.010.020.010.020.020.010.020.010.020.010.010.010.010.010.01
CS0.040.030.050.030.040.020.050.020.040.040.030.030.020.050.050.030.030.030.030.030.03
IR0.040.030.050.030.040.020.050.040.040.040.030.030.020.050.050.030.030.030.030.030.04
CA0.040.030.050.030.040.020.050.040.040.040.030.030.020.050.050.030.030.030.030.030.04
CD0.040.030.050.030.040.020.050.040.040.040.030.030.020.050.050.030.030.030.030.030.04
TI0.040.030.050.030.040.020.050.040.040.040.030.030.020.050.050.030.030.030.030.030.04
Total1111111111111111111120
Sadness = SA, Pessimism = PE, Past Failure = PF, Loss of Pleasure = LP, Guilty Feeling = GF, Punishment Feeling = PU, Self-Dislike = SD, Self-Criticalness = SC, Suicidal Thoughts = ST, Crying = CR, Agitation = AG, Loss of Interest = LI, Indecisiveness = IN, Worthlessness = WO, Loss of Energy = LE, Changes in Sleep Pattern = CS, Irritability = IR, Changes in Appetite = CA, Concentration Difficulty = CD, Tiredness = TI.

Appendix C

Table A3. Percentage of symptoms.
Table A3. Percentage of symptoms.
SymptomPercentage
Crying15
Self-criticalness11
Punishment feeling9
Loss of pleasure7
Pessimism6
Loss of interest6
Agitation5
Indecisiveness5
Sadness4
Suicidal thoughts4
Irritability4
Changes in appetite4
Concentration difficulty4
Tiredness4
Past failure3
Changes in sleep pattern3
Self-dislike2
Worthlessness2
Guilty feeling1
Loss of energy1
Total100

Appendix D

Table A4. Equivalence between symptoms and emotions.
Table A4. Equivalence between symptoms and emotions.
SymptomsEmotions
SadnessAversionAnger FearJoy TrustAnticipationSurprise
Sadness NANANANA
PessimismNANANA
Past failureNANANANA
Loss of pleasureNANANA
Guilty feelingNANANANA
Punishment feelingNANANANANA
Self-dislikeNANANANA
Self-criticalnessNANANANA
Suicidal thoughtsNANANANA
CryingNANANANANA
AgitationNANANANA
Loss of interestNANANANA
Indecisiveness NANANANA
WorthlessnessNANANA
Loss of energyNANANANA
Changes in sleep patternNANANA
IrritabilityNANA
Changes in appetiteNANANANA
Concentration difficultyNANANA
TirednessNANANA

Appendix E

Table A5. Symptom–Emotion Scores.
Table A5. Symptom–Emotion Scores.
SymptomsEmotions
MSSadnessAversionAngerFearJoyTrustAnticipationSurprise
SadnessMS152-3----
MS271-1--1-
MS37--2--1-
SM6.331-2--0.66-
PessimismMS12332----
MS22111--5-
MS3--10-----
SM1.331.334.661--1.66-
Past failureMS15--3--2-
MS261-2--1-
MS34-33----
SM50.3312.66--1-
Loss of pleasureMS1325-----
MS22132--2-
MS34--2--4-
SM312.661.33--2-
Guilty feelingMS135-2----
MS251-3--1-
MS34--4--2-
SM42-3--1-
Punishment feelingMS14-6-----
MS23-61----
E33-42--1-
SM3.33-5.331--0.33-
Self-dislikeMS1 53---2-
MS2333---1-
MS36-3---1-
SM32.663---1.33-
Self-criticalnessMS135-2----
MS2235-----
MS33231--1-
SM2.663.332.661--0.33-
Suicidal thoughtsMS152-1--2-
MS25--2--3-
MS35-12--2-
SM50.660.331.66--2.33-
CryingMS17--3----
MS27-12----
MS37-11--1-
SM7-0.662--0.33-
AgitationMS1 -----37
MS2 ------10
MS3 -53--2-
SM 1.661 1.665.66
Loss of interestMS15-11--3-
MS23--2--5-
MS34-21--3-
SM4-11.33--3.66-
IndecisivenessMS1---4--6-
MS23--7----
MS31--5--4-
SM1.33--5.33--3.33-
WorthlessnessMS144----2-
MS221-3--4-
MS33-32--2-
SM31.6611.66--2.66-
Loss of energyMS153-2----
MS27--3----
MS34-12--3-
SM5.3310.332.33--1-
Changes in sleep patternMS13411---1
MS223-5----
MS34-22--2-
SM32.3312.66--0.660.33
IrritabilityMS11341---1
MS2-25---21
MS32331--1-
SM12.6640.66--10.66
Changes in appetiteMS134-2--1-
MS235-2----
MS33223----
SM33.660.662.33--0.33-
Concentration difficultyMS124----31
MS24--4--2-
MS33-22--3-
SM31.330.662--2.660.33
TirednessMS153----2-
MS242-3--1-
MS34-23--1-
SM4.331.660.662--1.33-
- = not registered.

Appendix F

Table A6. Weights of emotions concerning the symptoms of depression.
Table A6. Weights of emotions concerning the symptoms of depression.
Emotions
SymptomsSadnessAversionAngerFearAnticipationSurprise
Sadness6.331020.660
Pessimism1.331.334.6611.660
Past failure50.3312.6610
Loss of pleasure312.661.3320
Guilty feeling420310
Punishment feeling3.3305.3310.330
Self-dislike32.66301.330
Self-criticalness2.663.332.6610.330
Suicidal thoughts50.660.331.662.330
Crying700.6620.330
Agitation001.6611.665.66
Loss of interest4011.333.660
Indecisiveness1.33005.333.330
Worthlessness31.6611.662.660
Loss of energy5.3310.332.3310
Changes in sleep pattern32.3312.660.660.33
Irritability12.6640.6610.66
Changes in appetite33.660.662.330.330
Concentration difficulty31.330.6622.660.33
Tiredness4.331.660.6621.330

Appendix G

Table A7. Final weights of symptom–emotion relationship.
Table A7. Final weights of symptom–emotion relationship.
SymptomWeightRelated EmotionWeight of Emotion Regarding
Symptom
Final Weight
Crying15Sadness0.710.5
Anger0.0660.99
Fear0.23
Anticipation0.0330.495
Self-criticalness11Sadness0.2662.926
Aversion0.3333.663
Anger0.2662.926
Fear0.11.1
Anticipation0.0330.363
Punishment feeling9Sadness0.3332.997
Anger0.5334.797
Fear0.10.9
Anticipation0.0330.297
Loss of pleasure7Sadness0.32.1
Aversion0.10.7
Anger0.2661.862
Fear0.1330.931
Anticipation0.21.4
Pessimism6Sadness0.1330.798
Aversion0.1330.798
Anger0.4662.796
Fear0.10.6
Anticipation0.1660.996
Loss of interest6Sadness0.42.4
Anger0.10.6
Fear0.1330.798
Anticipation0.3662.196
Agitation5Anger0.1660.83
Fear0.10.5
Anticipation0.1660.83
Surprise0.5662.83
Indecisiveness5Sadness0.1330.665
Fear0.5332.665
Anticipation0.3331.665
Sadness4Sadness0.6332.532
Aversion0.10.4
Fear0.20.8
Anticipation0.0660.264
Suicidal thoughts4Sadness0.52
Aversion0.0660.264
Anger0.0330.132
Fear0.1660.664
Anticipation0.2330.932
Irritability4Sadness0.10.4
Aversion0.2661.064
Anger0.41.6
Fear0.0660.264
Anticipation0.10.4
Surprise0.0660.264
Changes in appetite4Sadness0.31.2
Aversion0.3661.464
Anger0.0660.264
Fear0.2330.932
Anticipation0.0330.132
Concentration difficulty4Sadness0.31.2
Aversion0.1330.532
Anger0.0660.264
Fear0.20.8
Anticipation0.2661.064
Surprise0.0330.132
Tiredness4Sadness0.4331.732
Aversion0.1660.664
Anger0.0660.264
Fear0.20.8
Anticipation0.1330.532
Past failure3Sadness0.51.5
Aversion0.0330.099
Anger0.10.3
Fear0.2660.798
Anticipation0.10.3
Changes in sleep
pattern
3Sadness0.30.9
Aversion0.2330.699
Anger0.10.3
Fear0.2660.798
Anticipation0.0660.198
Surprise0.0330.099
Self-dislike2Sadness0.30.6
Aversion0.2660.532
Anger0.30.6
Anticipation0.1330.266
Worthlessness2Sadness0.30.6
Aversion0.1660.332
Anger0.10.2
Fear0.1660.332
Anticipation0.2660.532
Guilty feeling1Sadness0.40.4
Aversion0.20.2
Fear0.30.3
Anticipation0.10.1
Loss of energy1Sadness0.5330.533
Aversion0.10.1
Anger0.0330.033
Fear0.2330.233
Anticipation0.10.1
Total100 100

Appendix H

Algorithm A1. Mental-Health System Algorithm
BEGIN
// Step 1: Collect user’s posts from a specified period
posts = collectPosts(user, period)

// Step 2: Preprocess the data including tokenization and removing stop words
processPost(post):
  tokens = tokenize(post)
  filteredTokens = removeStopWords(tokens)
  return filteredTokens

processedPosts = []
FOR EACH post IN posts DO
  processedPosts.ADD(processPost(post))
END FOR

// Step 3: Detect emotions in each post
detectEmotions(post):
  emotions = []
  // Implement the logic to detect emotions and their intensity
  // emotions = [(emotion1, intensity1), (emotion2, intensity2), ...]
  return emotions

postsWithEmotions = []
FOR EACH post IN processedPosts DO
  detectedEmotions = detectEmotions(post)
  postsWithEmotions.ADD(detectedEmotions)
END FOR

// Step 4: Intensity is multiplied by the weight of each emotion related to the symptom of depression
emotionWeights = {
  "sadness": 1.5,
  "joy": -1.0,
  "anger": 1.2,
  "fear": 1.3,
  "surprise": 0.5,
  // Add more emotions and their respective weights
}

sumEmotionWeights(emotions):
  total = 0
  FOR EACH (emotion, intensity) IN emotions DO
    weight = emotionWeights[emotion]
    total += intensity * weight
  END FOR
  return total

// Step 5: Sum the partial results obtained in the previous step for each symptom
partialResults = []
FOR EACH emotions IN postsWithEmotions DO
  result = sumEmotionWeights(emotions)
  partialResults.ADD(result)
END FOR

// Step 6: Get the final sum of all values obtained in the previous step
finalSum = 0
FOR EACH result IN partialResults DO
  finalSum += result
END FOR
// Step 7: Determine the level of depression according to the given ranges
determineDepressionLevel(sum):
  IF sum >= 80 AND sum <= 100 THEN
    return "Severe depression"
  ELSE IF sum >= 60 AND sum < 80 THEN
    return "Moderately severe depression"
  ELSE IF sum >= 40 AND sum < 60 THEN
    return "Moderate depression"
  ELSE IF sum >= 20 AND sum < 40 THEN
    return "Mild depression"
  ELSE
    return "Minimal depression"
  END IF
depressionLevel = determineDepressionLevel(finalSum)
PRINT "The user’s depression level is: " + depressionLevel
END

Appendix I. Hardware and Software Tools Used

  • Hardware:
  • cPanel Version 110.0 (build 10); SSL certificates: yes; domain: mental-health.com.mx; Architecture x86_64; Operating System CentOs (Linux); shared IP address, 31.22.4.229; Path to Sendmail, /usr/sbin/sendmail; Path to Perl, /usr/bin/perl; Perl Version 5.16.3; Kernel Version 3.10.0-962.3.2.lve1.5.77.el7.x86_64; Ram: 4 GB DDR4; HD: 250 GB (SSD).
  • Software:
  • Apache Version 2.4.57, MySQL Version 10.6.14-MariaDB-cll-lve, PHP 7.4, PHPMyAdmin, Docker, MeaningCloud API 2.1, Twitter API 2.0, AngularJS Framework 1.6.1, Bootstrap 5 Bundle, JQuery 3.7, DataTables 1.5.1, PDFMake 0.1.32, SweetAlert 2.11.

Appendix J

Figure A1. Number of characters per comment.
Figure A1. Number of characters per comment.
Mathematics 12 01926 g0a1

Appendix K

Figure A2. Number of words per comment.
Figure A2. Number of words per comment.
Mathematics 12 01926 g0a2

Appendix L

Figure A3. Most common words in the dataset.
Figure A3. Most common words in the dataset.
Mathematics 12 01926 g0a3

Appendix M

Figure A4. Most common bigrams in the dataset.
Figure A4. Most common bigrams in the dataset.
Mathematics 12 01926 g0a4

Appendix N

Figure A5. Most common trigrams in the dataset.
Figure A5. Most common trigrams in the dataset.
Mathematics 12 01926 g0a5

Appendix O

Figure A6. Word cloud based on dataset.
Figure A6. Word cloud based on dataset.
Mathematics 12 01926 g0a6

References

  1. World Health Organization. Mental Disorders. 2022. Available online: https://www.who.int/es/news-room/fact-sheets/detail/mental-disorders (accessed on 19 September 2022).
  2. Informativa, H. Salud Mental En Adultos, INCyTU. 2018; Volume 52, pp. 1–4. Available online: https://www.foroconsultivo.org.mx/INCyTU/documentos/Completa/INCYTU_18-007.pdf (accessed on 30 January 2018).
  3. Rottenberg, J. Emotions in Depression: What Do We Really Know? Annu. Rev. Clin. Psychol. 2017, 13, 241–263. [Google Scholar] [CrossRef]
  4. Berking, M.; Wirtz, C.M.; Svaldi, J.; Hofmann, S.G. Emotion regulation predicts symptoms of depression over five years. Behav. Res. Ther. 2014, 57, 13–20. [Google Scholar] [CrossRef]
  5. Suveg, C.; Hoffman, B.; Zeman, J.L.; Thomassin, K. Common and specific emotion-related predictors of anxious and depressive symptoms in youth. Child Psychiatry Hum. Dev. 2009, 40, 223–239. [Google Scholar] [CrossRef] [PubMed]
  6. Power, M.J.; Tarsia, M. Basic and complex emotions in depression and anxiety. Clin. Psychol. Psychother. 2007, 14, 19–31. [Google Scholar] [CrossRef]
  7. Stets, J. Handbook of Social Psychology; Springer: Berlin/Heidelberg, Germany, 2006. [Google Scholar] [CrossRef]
  8. Hussain, J.; Satti, F.A.; Afzal, M.; Khan, W.A.; Bilal, H.S.M.; Ansaar, M.Z.; Ahmad, H.F.; Hur, T.; Bang, J.; Kim, J.I.; et al. Exploring the dominant features of social media for depression detection. J. Inf. Sci. 2020, 46, 739–759. [Google Scholar] [CrossRef]
  9. Kim, J.; Lee, J.; Park, E.; Han, J. A deep learning model for detecting mental illness from user content on social media. Sci. Rep. 2020, 10, 11846. [Google Scholar] [CrossRef] [PubMed]
  10. Lavhare, J.N.; Kulkarni, M.A. Mental disorders detection using social networking sites. In Proceedings of the 2021 Third International Conference on Intelligent Communication Technologies and Virtual Mobile Networks (ICICV 2021), Tirunelveli, India, 4–6 February 2021; pp. 113–117. [Google Scholar] [CrossRef]
  11. Coppersmith, G.; Leary, R.; Crutchley, P.; Fine, A. Natural Language Processing of Social Media as Screening for Suicide Risk. Biomed. Inform. Insights 2018, 10, 117822261879286. [Google Scholar] [CrossRef] [PubMed]
  12. Chancellor, S.; De Choudhury, M. Methods in predictive techniques for mental health status on social media: A critical review. Npj Digit. Med. 2020, 3, 43. [Google Scholar] [CrossRef] [PubMed]
  13. Ahmed, I.; Banu, H.; Al-Fageer, R.; Al-Suwaidi, R. Cognitive emotions: Depression and anxiety in medical students and staff. J. Crit. Care 2009, 24, e1. [Google Scholar] [CrossRef]
  14. Chan, D.W. Depressive symptoms and perceived competence among Chinese secondary school students in Hong Kong. J. Youth Adolesc. 1997, 26, 303–319. [Google Scholar] [CrossRef]
  15. Alghowinem, S.M.; Gedeon, T.; Goecke, R.; Cohn, J.; Parker, G. Interpretation of Depression Detection Models via Feature Selection Methods. IEEE Trans. Affect. Comput. X 2020, 1–18. [Google Scholar] [CrossRef] [PubMed]
  16. Li, A.; Jiao, D.; Zhu, T. Detecting depression stigma on social media: A linguistic analysis. J. Affect. Disord. 2018, 232, 358–362. [Google Scholar] [CrossRef]
  17. Skaik, R.; Inkpen, D. Using twitter social media for depression detection in the canadian population. In ACM International Conference Proceeding Series; Association for Computing Machinery: New York, NY, USA, 2020; pp. 109–114. [Google Scholar] [CrossRef]
  18. Shah, F.M.; Ahmed, F.; Joy, S.K.S.; Ahmed, S.; Sadek, S.; Shil, R.; Kabir, M.H. Early Depression Detection from Social Network Using Deep Learning Techniques. In Proceedings of the 2020 IEEE Region 10 Symposium (TENSYMP 2020), Dhaka, Bangladesh, 5–7 June 2020; Volume 1, pp. 823–826. [Google Scholar] [CrossRef]
  19. Nusrat, M.O.; Shahzad, W.; Jamal, S.A. Multi Class Depression Detection Through Tweets using Artificial Intelligence. arXiv 2024, arXiv:2404.13104. [Google Scholar]
  20. Biradar, A.; Totad, S.G. Detecting Depression in Social Media Posts Using Machine Learning; Springer: Singapore, 2019. [Google Scholar] [CrossRef]
  21. Rao, G.; Zhang, Y.; Zhang, L.; Cong, Q.; Feng, Z. MGL-CNN: A Hierarchical Posts Representations Model for Identifying Depressed Individuals in Online Forums. IEEE Access 2020, 8, 32395–32403. [Google Scholar] [CrossRef]
  22. Malviya, K.; Roy, B.; Saritha, S.K. A Transformers Approach to Detect Depression in Social Media. In Proceedings of the 2021 International Conference on Artificial Intelligence and Smart Systems (ICAIS 2021), Coimbatore, India, 25–27 March 2021; pp. 718–723. [Google Scholar] [CrossRef]
  23. Yang, T.; Li, F.; Ji, D.; Liang, X.; Xie, T.; Tian, S.; Li, B. Fine-grained depression analysis based on Chinese micro-blog reviews. Inf. Process. Manag. 2021, 58, 102681. [Google Scholar] [CrossRef]
  24. Wang, X.; Zhang, C.; Sun, L. An improved model for depression detection in micro-blog social network. In Proceedings of the 2013 IEEE 13th International Conference on Data Mining Workshops (ICDMW 2013), Dallas, TX, USA, 7–10 December 2013; pp. 80–87. [Google Scholar] [CrossRef]
  25. Stephen, J.J.; Prabu, P. Detecting the magnitude of depression in Twitter users using sentiment analysis. Int. J. Electr. Comput. Eng. 2019, 9, 3247–3255. [Google Scholar] [CrossRef]
  26. Angskun, J.; Tipprasert, S.; Angskun, T. Big data analytics on social networks for real-time depression detection. J. Big Data 2022, 9, 69. [Google Scholar] [CrossRef]
  27. Leis, A.; Ronzano, F.; Mayer, M.A.; Furlong, L.I.; Sanz, F. Detecting Signs of Depression in Tweets in Spanish: Behavioral and Linguistic Analysis. J. Med. Internet Res. 2019, 21, e14199. [Google Scholar] [CrossRef] [PubMed]
  28. Nadeem, M. Identifying Depression on Twitter. arXiv 2016, arXiv:1607.07384. [Google Scholar]
  29. Alsagri, H.S.; Ykhlef, M. Machine learning-based approach for depression detection in twitter using content and activity features. IEICE Trans. Inf. Syst. 2020, E103D, 1825–1832. [Google Scholar] [CrossRef]
  30. Arora, P.; Arora, P. Mining Twitter Data for Depression Detection. In Proceedings of the 2019 International Conference on Signal Processing and Communication (ICSC), Noida, India, 7–9 March 2019; pp. 186–189. [Google Scholar] [CrossRef]
  31. Narynov, S.; Mukhtarkhanuly, D.; Omarov, B. Dataset of depressive posts in Russian language collected from social media. Data Br. 2020, 29, 105195. [Google Scholar] [CrossRef] [PubMed]
  32. Lin, C.; Mei, J.; Leung, H. SenseMood: Depression Detection on Social Media. In Proceedings of the 2020 International Conference on Multimedia Retrieval, Dublin, Ireland, 8–11 June 2020; pp. 407–411. [Google Scholar]
  33. Ricard, B.J.; Marsch, L.A.; Crosier, B.; Hassanpour, S. Exploring the Utility of Community-Generated Social Media Content for Detecting Depression: An Analytical Study on Instagram. J. Med. Internet Res. 2018, 20, e11817. [Google Scholar] [CrossRef] [PubMed]
  34. Martínez-Castaño, R.; Pichel, J.C.; Losada, D.E. A big data platform for real time analysis of signs of depression in social media. Int. J. Environ. Res. Public Health 2020, 17, 4752. [Google Scholar] [CrossRef] [PubMed]
  35. Safa, R.; Bayat, P.; Moghtader, L. Automatic Detection of Depression Symptoms in Twitter Using Multimodal Analysis; Springer: Berlin/Heidelberg, Germany, 2021. [Google Scholar] [CrossRef]
  36. Chiong, R.; Budhi, G.S.; Dhakal, S.; Chiong, F. A textual-based featuring approach for depression detection using machine learning classifiers and social media texts. Comput. Biol. Med. 2021, 135, 104499. [Google Scholar] [CrossRef] [PubMed]
  37. de J. Titla-Tlatelpa, J.; Ortega-Mendoza, R.M.; Montes-y-Gómez, M.; Villaseñor-Pineda, L. A profile-based sentiment-aware approach for depression detection in social media. EPJ Data Sci. 2021, 10, 54. [Google Scholar] [CrossRef]
  38. Yang, X.; McEwen, R.; Ong, L.R.; Zihayat, M. A big data analytics framework for detecting user-level depression from social networks. Int. J. Inf. Manag. 2020, 54, 102141. [Google Scholar] [CrossRef]
  39. Plutchik, R. The nature of emotions: Human emotions have deep evolutionary roots, a fact that may explain their complexity and provide tools for clinical practice. Am. Sci. 2001, 89, 344–350. [Google Scholar] [CrossRef]
  40. Beltrán, C.M.; Navarrete, A.A.S.; Vidal-Castro, C.; Rubio-Manzano, C.; Martínez-Araneda, C. Improving the affective analysis in texts: Automatic method to detect affective intensity in lexicons based on Plutchik’s wheel of emotions. Electron. Libr. 2019, 37, 984–1006. [Google Scholar] [CrossRef]
  41. Qi, X.; Wang, W.; Guo, L.; Li, M.; Zhang, X.; Wei, R. Building a Plutchik’s Wheel Inspired Affective Model for Social Robots. J. Bionic Eng. 2019, 16, 209–221. [Google Scholar] [CrossRef]
  42. Chafale, D.; Pimpalkar, A. Sentiment Analysis on Product Reviews Using Plutchik’s Wheel of Emotions with Fuzzy. Int. J. Eng. Technol. 2014, 1, 1–8. [Google Scholar]
  43. Mondal, A.; Gokhale, S.S. Mining Emotions on Plutchik’s Wheel. In Proceedings of the 2020 Seventh International Conference on Social Networks Analysis, Management and Security (SNAMS 2020), Paris, France, 14–16 December 2020; pp. 1–6. [Google Scholar]
  44. Plutchik, R. A psychoevolutionary theory of emotions. Soc. Sci. Inf. 1982, 21, 529–553. [Google Scholar] [CrossRef]
  45. Danner, M.; Hummel, J.M.; Volz, F.; Van Manen, J.G.; Wiegard, B.; Dintsios, C.M.; Bastian, H.; Gerber, A.; Ijzerman, M.J. Integrating patients’ views into health technology assessment: Analytic hierarchy process (AHP) as a method to elicit patient preferences. Int. J. Technol. Assess. Health Care 2011, 27, 369–375. [Google Scholar] [CrossRef] [PubMed]
  46. Lin, Z.C.; Yang, C.B. Evaluation of machine selection by the AHP method. J. Mater. Process. Technol. 1996, 57, 253–258. [Google Scholar] [CrossRef]
  47. Li, F.; Phoon, K.K.; Du, X.; Zhang, M. Improved AHP Method and Its Application in Risk Identification. J. Constr. Eng. Manag. 2013, 139, 312–320. [Google Scholar] [CrossRef]
  48. Al Khalil, M.I. Selecting the appropriate project delivery method using AHP. Int. J. Proj. Manag. 2002, 20, 469–474. [Google Scholar] [CrossRef]
  49. Podvezko, V. Application of AHP technique. J. Bus. Econ. Manag. 2009, 10, 181–189. [Google Scholar] [CrossRef]
  50. Saaty, T.L. Decision making—The Analytic Hierarchy and Network Processes (AHP/ANP). J. Syst. Sci. Syst. Eng. 2004, 13, 1–35. [Google Scholar] [CrossRef]
  51. Kou, G.; Ergu, D.; Lin, C.; Chen, Y. Pairwise comparison matrix in multiple criteria decision making. Technol. Econ. Dev. Econ. 2016, 22, 738–765. [Google Scholar] [CrossRef]
  52. Arslan, M.Ç.; Çatay, B.; Budak, E. A decision support system for machine tool selection. J. Manuf. Technol. Manag. 2004, 15, 101–109. [Google Scholar] [CrossRef]
  53. Lawshe, C.H. A Quantitative Approach To Content Validity. Pers. Psychol. 1975, 28, 563–575. [Google Scholar] [CrossRef]
  54. García, S.; Luengo, J.; Herrera, F. Tutorial on practical tips of the most influential data preprocessing algorithms in data mining. Knowledge-Based Syst. 2016, 98, 1–29. [Google Scholar] [CrossRef]
  55. MeaningCloud, MeaningCloud/SentimentAnalysis. 2023. Available online: https://www.meaningcloud.com/products/sentiment-analysis (accessed on 1 August 2023).
  56. MeaningCloud, MeaningCloud/AutomaticEmotionRecongnition. 2023. Available online: https://www.meaningcloud.com/blog/automatic-emotion-recognition (accessed on 2 August 2023).
  57. Perry, D.E.; Wolf, A.L. Foundations for the Study of Software Architecture. ACM SIGSOFT Softw. Eng. Notes 1992, 17, 40–52. [Google Scholar] [CrossRef]
  58. Kroenke, K.; Spitzer, R.L.; Williams, J.B.W. The PHQ-9: Validity of a Brief Depression Severity Measure. J. Gen. Intern. Med. 2001, 16, 606–613. [Google Scholar] [CrossRef] [PubMed]
  59. Martin, A.; Rief, W.; Klaiberg, A.; Braehler, E. Validity of the Brief Patient Health Questionnaire Mood Scale (PHQ-9) in the general population. Gen. Hosp. Psychiatry 2006, 28, 71–77. [Google Scholar] [CrossRef] [PubMed]
  60. ALalkhen, G.; McCluskey, A. Clinical tests: Sensitivity and specificity, Contin. Educ. Anaesthesia. Crit. Care Pain 2008, 8, 221–223. [Google Scholar] [CrossRef]
  61. Townsend, J.T. Erratum to: Theoretical analysis of an alphabetic confusion matrix. Percept. Psychophys. 1971, 10, 256. [Google Scholar] [CrossRef]
  62. Efstathiou, V.; Stefanou, M.-I.; Siafakas, N.; Makris, M.; Tsivgoulis, G.; Zoumpourlis, V.; Spandidos, D.; Smyrnis, N.; Rizos, E. Suicidality and COVID-19: Suicidal ideation, suicidal behaviors and completed suicides amidst the COVID-19 pandemic (Review). Exp. Ther. Med. 2021, 23, 107. [Google Scholar] [CrossRef] [PubMed]
  63. Hamilton, M. A Rating Scale for depression. J. Neurol. Neurosurg. Psychiatry 1960, 23, 56–63. [Google Scholar] [CrossRef] [PubMed]
Figure 1. Correlation between symptoms and emotions.
Figure 1. Correlation between symptoms and emotions.
Mathematics 12 01926 g001
Figure 2. A general diagram of the model for depression level detection.
Figure 2. A general diagram of the model for depression level detection.
Mathematics 12 01926 g002
Figure 3. Mental-Health architecture.
Figure 3. Mental-Health architecture.
Mathematics 12 01926 g003
Figure 4. Patient list.
Figure 4. Patient list.
Mathematics 12 01926 g004
Figure 5. Comments obtained from X.
Figure 5. Comments obtained from X.
Mathematics 12 01926 g005
Figure 6. Depression symptoms.
Figure 6. Depression symptoms.
Mathematics 12 01926 g006
Figure 7. Emotions detected.
Figure 7. Emotions detected.
Mathematics 12 01926 g007
Figure 8. Depression levels.
Figure 8. Depression levels.
Mathematics 12 01926 g008
Table 1. The values of the emotions obtained with MeaningCloud.
Table 1. The values of the emotions obtained with MeaningCloud.
Emotion API Value
Sadness0.22
Aversion 0.15
Anger0.26
Fear1.0
Joy0.26
Trust0.11
Anticipation0.41
Surprise0.07
Table 2. Application of depression level detection model.
Table 2. Application of depression level detection model.
SymptomWeightRelated
Emotion
Weight of Emotion Regarding SymptomFinal WeightNormalized Value
Crying15Sadness0.710.55.770
Anger0.0660.99
Fear0.23
Anticipation0.0330.495
Self-criticalness11Sadness0.2662.9263.203
Aversion0.3333.663
Anger0.2662.926
Fear0.11.1
Anticipation0.0330.363
Punishment feeling9Sadness0.3332.9972.928
Anger0.5334.797
Fear0.10.9
Anticipation0.0330.297
Loss of pleasure7Sadness0.32.12.556
Aversion0.10.7
Anger0.2661.862
Fear0.1330.931
Anticipation0.21.4
Pessimism6Sadness0.1330.7982.031
Aversion0.1330.798
Anger0.4662.796
Fear0.10.6
Anticipation0.1660.996
Loss of interest6Sadness0.42.42.382
Anger0.10.6
Fear0.1330.798
Anticipation0.3662.196
Agitation5Anger0.1660.831.254
Fear0.10.5
Anticipation0.1660.83
Surprise0.5662.83
Indecisiveness5Sadness0.1330.6653.494
Fear0.5332.665
Anticipation0.3331.665
Sadness4Sadness0.6332.5321.525
Aversion0.10.4
Fear0.20.8
Anticipation0.0660.264
Suicidal thoughts4Sadness0.521.560
Aversion0.0660.264
Anger0.0330.132
Fear0.1660.664
Anticipation0.2330.932
Irritability4Sadness0.10.41.110
Aversion0.2661.064
Anger0.41.6
Fear0.0660.264
Anticipation0.10.4
Surprise0.0660.264
Changes in
appetite
4Sadness0.31.21.538
Aversion0.3661.464
Anger0.0660.264
Fear0.2330.932
Anticipation0.0330.132
Concentration
difficulty
4Sadness0.31.21.658
Aversion0.1330.532
Anger0.0660.264
Fear0.20.8
Anticipation0.2661.064
Surprise0.0330.132
Tiredness4Sadness0.4330.91.567
Aversion0.1660.9
Anger0.0660.5
Fear0.20.5
Anticipation0.1330.2
Past failure3Sadness0.51.51.344
Aversion0.0330.099
Anger0.10.3
Fear0.2660.798
Anticipation0.10.3
Changes in
sleep pattern
3Sadness0.30.91.267
Aversion0.2330.699
Anger0.10.3
Fear0.2660.798
Anticipation0.0660.198
Surprise0.0330.099
Self-dislike2Sadness0.30.60.477
Aversion0.2660.532
Anger0.30.6
Anticipation0.1330.266
Worthlessness2Sadness0.30.60.784
Aversion0.20.4
Anger0.10.2
Fear0.20.4
Anticipation0.30.6
Guilty feeling1Sadness0.40.90.440
Aversion0.20.9
Fear0.30.5
Anticipation0.10.2
Loss of energy1Sadness0.5330.5330.415
Aversion0.10.1
Anger0.0330.033
Fear0.2330.233
Anticipation0.10.1
Depression score 37.30
Table 3. Depression levels.
Table 3. Depression levels.
Depression Level Range
Severe80–100
Moderately severe60–79.99
Moderate40–59.99
Mild20–39.99
Minimal0–19.99
Table 4. Confusion matrix and metrics.
Table 4. Confusion matrix and metrics.
PHQ-9 Questionnaire Depression LevelsMetrics
Mental-Health
Depression Levels
SevereModerately SevereModerateMildMinimalPrecision Recall
Severe0000000
Moderately severe030001.01.0
Moderate 008001.01.0
Mild000111.00.5
Minimal 002140.80.57
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Salas-Zárate, R.; Alor-Hernández, G.; Paredes-Valverde, M.A.; Salas-Zárate, M.d.P.; Bustos-López, M.; Sánchez-Cervantes, J.L. Mental-Health: An NLP-Based System for Detecting Depression Levels through User Comments on Twitter (X). Mathematics 2024, 12, 1926. https://doi.org/10.3390/math12131926

AMA Style

Salas-Zárate R, Alor-Hernández G, Paredes-Valverde MA, Salas-Zárate MdP, Bustos-López M, Sánchez-Cervantes JL. Mental-Health: An NLP-Based System for Detecting Depression Levels through User Comments on Twitter (X). Mathematics. 2024; 12(13):1926. https://doi.org/10.3390/math12131926

Chicago/Turabian Style

Salas-Zárate, Rafael, Giner Alor-Hernández, Mario Andrés Paredes-Valverde, María del Pilar Salas-Zárate, Maritza Bustos-López, and José Luis Sánchez-Cervantes. 2024. "Mental-Health: An NLP-Based System for Detecting Depression Levels through User Comments on Twitter (X)" Mathematics 12, no. 13: 1926. https://doi.org/10.3390/math12131926

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop