SIS @ LT - EDI -2023: Detecting Signs of Depression from Social Media Text (2023)

Abstract: Various biological, genetic, psychological or social factors that feature a target oriented life with chronic stress and frequent traumatic experiences, lead to pessimism and apathy. The massive scale of depression should be dealt with as a disease rather than a ‘phase’ that is neglected by the majority. However, not a lot of people are aware of depression and its impact. Depression is a serious issue that should be treated in the right way. Many people dealing with depression do not realize that they have it due to the lack of awareness. This paper aims to address this issue with a tool built on the blocks of machine learning. This model analyzes the public social media texts and detects the signs of depression under three labels namely “not depressed”, “moderately depressed”, and “severely depressed” with high accuracy. The ensembled model uses three learners namely Multi-Layered Perceptron, Support Vector Machine and Multinomial Naive Bayes Classifier. The distinctive feature in this model is that it uses Artificial Neural Networks, Classifiers, Regression and Voting Classifiers to compute the final result or output.

## introduction depression is a chronic feeling of emptiness, sadness, or inability to feel pleasure that may appear to happen for no clear reason, according to 'medical news today'. it is distinct from grief and other emotions. it is considered to be a common mental disorder. a sense of melancholy pervades through a single word or text and to detect this the project is assigned to analyze the text with its highest accuracy rate of depression. as described in the world health organization's comprehensive mental health action plan 2013-2020 1 , depres-1 https://www.who.int/health-topics/@xmath0, particularly for women. depression currently accounts for 4.3 percent of the global burden of disease, and it is expected to be the leading cause of disease burden in high-income countries by 2030 @xcite . it is important to note that each individual's experience with depression is unique, and the causes can vary from person to person. some of the common factors leading to depression is said to be competitive lifestyle, need to meet high expectations and low self-esteem. people are much concerned about getting a good qualification, better career paths, social dignity etc., the spawn of internet and communication technologies, distinctly the online social networks have modernized how people interact and communicate with each other digitally. people tend to express more on social media compared to real life interactions and communications.it is also important to note that measuring the severity of the disorder is also a difficult task that could only be done by a highly trained professional with the use of different techniques such as text descriptions and clinical interviews, as well as their judgments @xcite . this project depicts a deep architecture for explicitly predicting and classifying depression levels as 'not depressed', 'moderately depressed', or 'severely depressed' from their social media texts. strong learners such as support vector machine (svm), multilayer perceptron (mlp), deep neural networks and naive bayes are used for classifying texts. this project uses data from social media networks to explore various methods of early detection of major depressive disorder (mdd) based on machine learning techniquies. a thorough analysis of the dataset to characterize the subjects' behavior based on different aspects of their writings @xcite . the main contributions of the project can be summarized as follows: depression is a chronic feeling of emptiness, sadness, or inability to feel pleasure that may appear to happen for no clear reason, according to 'medical news today'. it is distinct from grief and other emotions. it is considered to be a common mental disorder. a sense of melancholy pervades through a single word or text and to detect this the project is assigned to analyze the text with its highest accuracy rate of depression. as described in the world health organization's comprehensive mental health action plan 2013-2020 (?), depression alone affects more than 300 million people worldwide and is one of the largest single causes of disability worldwide, particularly for women. depression currently accounts for 4.3 percent of the global burden of disease, and it is expected to be the leading cause of disease burden in high-income countries by 2030 @xcite . it is important to note that each individual's experience with depression is unique, and the causes can vary from person to person. some of the common factors leading to depression is said to be competitive lifestyle, need to meet high expectations and low self-esteem. people are much concerned about getting a good qualification, better career paths, social dignity etc., the spawn of internet and communication technologies, distinctly the online social networks have modernized how people interact and communicate with each other digitally. people tend to express more on social media compared to real life interactions and communications. this project depicts a deep architecture for explicitly predicting and classifying depression levels as 'not depressed', 'moderately depressed', or 'severely depressed' from their social media texts. strong learners such as support vector machine (svm), multilayer perceptron (mlp), deep neural networks and naive bayes are used for classifying texts. this project uses data from social media networks to explore various methods of early detection of major depressive disorder (mdd) based on machine learning techniquies. this paper is writtern in the format @xcite a thorough analysis of the dataset to characterize the subjects' behavior based on different aspects of their writings @xcite . the main contributions of the project can be summarized as follows: ## existing works there have been many projects that have dealt with finding a tool to detect depression in social media. most of them included the implementation of machine learning techniques such as support vector machines and naive bayes. the overall accuracy obtained from those works is 70 percent. this paper aims to increase the accuracy level of detecting depression and in a way that it doesn't affect the user's privacy. halfin's study @xcite demonstrated that the early detection, intervention, and appropriate treatment can promote easing and reduce the emotional and financial burdens of depression, and @xcite observed significant improvements in depressive symptoms among subjects who had undergone early screening or diagnosis of depression. @xcite found that early intervention for depression can improve employee productivity and reduce major problems and complications. the prediction of major depressive disorder (mdd) at early stages is proved to improve the health and maintain peace of a subject. the detection of mdd is so far has been predicted by one method or one weak learner. ## proposed method by extending the work done previously, this machine learning model is based on support vector machine(svm), multinomial naive bayes and multi layer perceptron(mlp). by combining the above algorithms, the result thus obtained will have higher accuracy as it is built on not one, but 3 highly effective ml models. the final prediction of the text is classified or computed using an ensembling technique called bagging (bootstrap aggregating) and a voting classifier. a voting classifier is a machine learning estimator that trains various base models and predicts an outcome on the basis of aggregating and considering the majority output regarding the findings of each base estimator @xcite . brief explanation about the algorithms used in the final model: support vector machine (svm): the svm algorithm is implemented through the 'svc' class. svms @xcite are powerful classifiers that aim to find an optimal hyperplane to separate different classes in the data. in this code, svm with a linear kernel ('@xmath1, which takes a linear decision boundary between classes. the figure 2 is an illustration of support vector machine and how it classifies different data points using regression function. support vector machine (svm) is a type of algorithm in supervised machine learning domain most used for undertaking classifications tasks @xcite . while svm algorithms can be employed for regression analysis tasks, but in practice they are most used for classification applications, such as classifying binary data into two distinct classes @xcite . multilayer perceptron (mlp): the mlp algorithm is implemented through the 'mlpclassifier' class . it's a type of neural network that consists of multiple layers of nodes. it uses a process called backpropagation to navigate through complex data. the figure 3 is an illustration of multilayer perceptron and how it classifies different data points using multiple hidden layers. in this code, an mlp classifier with a single hidden layer containing 100 neurons is used. multilayer perceptron is used because it uses generalized delta learning rules and easily gets trained in less number of iterations(aggarwal and singh, 2015). a minimal multilayer perceptron has 3 layers including one hidden layer, one input layer and one output layer. the increase in the number of hidden layers corresponds to more accurate results. if it has more than 1 hidden layer, it is called a deep ann. an mlp is a typical example of a feedforward artificial neural network. multinomial naive bayes (nb): bayesian algorithms predict the class depending on the probability of belonging to that class foot_0 . it calculates a set of probabilities from the frequency count and the combinations of values in a given data set. this algorithm is based on bayes' theorem, assuming that all variables are independent. bayes' theorem follows the following formula(?) . naive bayes algorithms assume features are independent of each other, and hence no correlation between the features tend to implement through the 'multinomialnb' class are probabilistic classifier based on bayes' theorem. in the code, the multino-mialnb classifier is used, which is optimal for discrete features such as word frequencies or tf-idf values commonly encountered in text classification tasks. including nb as a weak learner in the ensemble can improve accuracy by taking advantage of its ability to handle text data and make independent assumptions. multinomial naive bayes classifier is used to classify data that is not dependent on a time period or a scale. these algorithms are combined in the ensemble approach to leverage the strengths of each individual algorithm and create a more robust and accurate model. hence, by combining multiple algorithms the model is gives a prediction with high accuracy. multinomial naïve bayes classifier is a supervised learning method that uses probability and is focused on text classification cases. this method follows the principle of multinomial distribution in conditional probability. although using multinomial distributions, this algorithm can be applied to text cases by converting to a nominal form that can be computed with an integer value. the probability calculation is described in the below equation @xcite . p (c|d) ∝ p (c)πp (t|c)](2) where p(t) ¸is the conditional probability of the word in the text that belongs to class c and p(c) is the prior probability.( farisi et al., 2019) ensemble learning: ensemble learning is a machine learning archetype or theory where multiple learners are trained or applied to datasets to solve the same problem by extracting multiple predictions then combined into one composite prediction @xcite . deep learning architectures are showing better performance compared to the shallow or traditional models. deep ensemble learning models combine the advantages of both the deep learning models as well as the ensemble learning such that the final model has better generalization performance. it is a process that uses a set of models, each of them obtained by applying a learning process to a given problem. this set of models (ensemble) is integrated in some way to obtain the final prediction. ensemble learning is a technique that combines multiple individual models (weak learners) to make predictions.(kotsiantis and pintelas, 2007) the model use the voting classifier and bagging classifier.the ensemble combines the predictions of the various learners to obtain the final prediction. in the first version of the code, a votingclassifier is used with three weak learners: multilayer perceptron(mlp), support vector machine (svm), and multinomial naive bayes. in the another model , a baggingclassifier is used, where the ensembling model combines multilayer perceptron (mlp), support vector machine (svm) and random forest(rf). though both models tend to compute outcomes with promising accuracy, the first model provides the highest accuracy. to prove that average voting in an ensemble is better than individual model, marquis de condorcet proposed a theorem wherein he proved that if the probability of each voter being correct is above 0.5 and the voters are independent, then addition of more voters increases the probability of majority vote being correct until it approaches 1 (condorcet, 1785) @xcite . although marquis de condorcet proposed this theorem in the field of political science and had no idea of the field of machine learning, but it is the similar mechanism that leads to better performance of the ensemble models. assumptions of marquis de condorcet theorem also holds true for ensembles @xcite ,(hansen and @xcite . the reasons for the success of ensemble learning include: statistical, computational and representation learning, bias-variance decomposition and strength-correlation @xcite @xcite . ## working of the model the code is implemented more than once in order to obtain the optimal result, a total of 4 compilations were implemented. version 1: the classification report provides an evaluation of the model's performance in each class. the ensemble method -voting classifier is used here, which compares the prediction of multiple weak learners to make the final prediction. while using the voting ensemble technique, the predictions for the "not depression" and "severe" classes have been classified in terms of the precision , re-call and f1-score. the accuracy if this model is 58 percent. this accuracy score is not appreciable for this type of text classification. so this problem needs to be addressed in the next run. the overall accuracy for detecting severe depression is 98 percent using this classifier. but the other classes remain moderately accurate. this is not the goal of this paper, hence certain changes are made to make it more accurate. the classification report while using the voting classifier is depicted below stating the model's accuracy. version 2: in the updated version of the code, bagging classifier is implemented instead of a voting classifier. in bagging, multiple weak learners are trained on different subsets of training data and their predictions are aggregated to make the final prediction. one of the weak learners used here is multinomial naive bayes, a variant of naive bayes instead of the random forest classifier. it's used as it provides better accuracy while handling text classification, and provides ensemble diversity. that is, adding the mnb(multinomial naive bayes) alongside mlp and svm,provides diversity to the ensemble which improves the overall accuracy. in this run, the overall accuracy obtained is 72 percent, hence the accuracy is improved compared to the previous model and this is also greater than the accuracy obtained in the existing methods. to make sure this is the maximum accuracy, the same model is run twice. it is observed that the maximum and highest accuracy of detecting depression in texts is 72 percent. the classification report while using bagging classifier is depicted below stating the model's accuracy. ## data the dataset used in the paper is of public data, ensuring that the user's privacy is not invaded at any cost. but the public data might contain depressive texts in a disingenuous meaning too. this might make it hard to separate the genuine texts from them, hence public data needs to be further filtered. the dataset contains 7202 texts for training, 3,246 texts for development, and 500 texts for testing, while each sample is composed of three columns: pid(person identity), text, and label. the test dataset contains only pid and text for which the label is predicted using the model. ## implementation the model can be implemented in any python environment as long as it supports the necessary modules and libraries used in the code. such machine learning frameworks are jupyter notebook, python idle or google colab. this model is implemented in google colab. libraries and modules like pandas, vectorizer, neural network, svm(support vector machine), naive bayes are used for the implementation. ## result analysis as discussed previously, the updated version of the model provides the prediction with the highest accuracy of 72 percent(f1 score). this final version of the model is implemented by using the weak learners svm, naive bayes, mlp, ensemble learning( bagging classifier). the model correctly predicted and classified the texts into labels namely 'not depressed', 'moderately depressed', or 'severely depressed'. since preprocessing can eliminate unneeded words and make the word more structured in the created model so that it is more efficient and performance will increase. factors like sarcastic texts, threatening, fabricated content etc.., seem to affect the accuracy and consistency of the model. though this is a model with high accuracy to detect depression, it can be improved to give better results. the predicted results computer by the model are given in ## conclusion in this era it is important to keep lead and awareness on the depression rate, some phases or events make us more vulnerable to depression. there are various factors that could trigger emotional influx, and to detect all these, different algorithms with the highest accuracy have been opted. based on the results of testing and analysis, it can be concluded as follows: the system that was built successfully classified texts into labels namely 'not depressed', 'moderately depressed', or 'severely depressed'. with the most optimal result is f1-score average of 72 percent using preprocessing based on the classification process. the optimal classification principle is to improve the model performance with standardized classification and management with the dependence of word occurrence. this change improved the performance of the dataset classification model. the ensemble technique algorithm is a fast, easy-to-implement, almost modern text classification algorithm. proposed method and algorithm offers many possibilities for text classification. the main findings of this study is the importance of using ensemble techniques in the early detection of mdd to prevent any occurrences of tragic incidents, the comparison of the voting classifier and bagging classifier to predict the depression condition, and the improvement of state-of-the-art algorithms. it does have its own demerits that are to be figured out, yet it still provides us by attaining the goal of detecting the depression levels.