Editor’s introduction
The study evaluates a Fuzzy Ensemble model composed of five fine-tuned BERT variants—Base, Large, LSTM, GRU, and CNN—applied to Community Question Answering datasets like Stack Overflow and Jira. The model uses fuzzy logic to combine outputs, improving accuracy in identifying neutral and negative sentiments, which are often misclassified by general-purpose tools. It achieves a maximum F1-score of 0.883 when compared to state-of-the-art tools such as SentiStrength-SE and GPT. The researchers also conducted ANOVA to assess differences in performance, finding a p-value of 0.684, which indicates no statistically significant differences among the six models tested.
Introduction
Opinion mining or sentiment analysis is a technique to mine the emotion/ sentiment of users from textual data. Sentiment analysis can be applied on document level, sentence or phrase level, or aspect level. The accuracy of sentiment analysis often depends on the lexicon/dictionary. The current research shows that the domain-specific lexicons often outperform the generic lexicon in terms of precision and accuracy.
Like other domains, sentiment analysis of software engineering text is valuable and has various applications such as getting the opinion of users, analyzing the quality of content, analyzing the product review and identifying community smells. There are various sources to extract software engineering text some of the popular sources include community question-answering sites (Stack Overflow, Quora, Yahoo Answers, etc.), bug reports, and app reviews. Certain studies have been performed for domain-specific sentiment analysis of software engineering text, and tools are also developed for this purpose. For example, Obadi et al. performed a systematic mapping study of sentiment analysis tools developed for software engineering. Lin et al. observed that existing sentiment analysis tools are not suitable for the SE domain and produce negative and biased results.
The limitations of existing tools for sentiment analysis were identified after an extensive review of the literature. These limitations answer the RQ1 and can be enlisted as i) struggle to compute negative and neutral sentiments on SE text; ii) only work well on a particular dataset on which these are trained and iii) are not suitable as general-purpose resource as results are often biased. Authors also studied and experimented with various machine learning techniques [–] for sentiment analysis, but the results are quite diverse.
To overcome these limitations, five variants of BERT are developed, fine-tuned, and trained on SentiSE dataset to compute the sentiment of SE text. The results of BERT models i.e. Bert-Base, Bert-Large, Bert-LSTM, Bert-GRU, and Bert-CNN are ensembles using fuzzy logic to compute the sentiment from SE text. The effectiveness of the fuzzy ensemble model is evaluated on four benchmark datasets. The results are also compared with the existing techniques, i.e., SentiStrength-SE, Senti4SD, SentiCR, and GPT. From the evaluation of results, it is concluded that newly proposed Fuzzy Ensemble model gives the best results on all the datasets. The results indicate that both individual BERT models and the proposed fuzzy ensemble model demonstrate notable performance in predicting neutral and positive sentiment classes. This achievement addresses a common limitation observed in existing models that often struggle with accurate predictions for neutral sentiment. The model is trained on one dataset and tested on various datasets. The performance of the proposed fuzzy ensemble is not only comparable with the existing tools but it is better than the existing tools on Stack Overflow, Jira, and CodeReview datasets. The incorporation of a fuzzy ensemble mechanism provides a holistic approach to sentiment analysis, effectively leveraging the strengths of multiple BERT models. The comparison of accuracy rates for positive, negative, and neutral classes shows performance across different sentiment categories. These findings collectively underscore the efficacy of the ensemble approach in achieving robust sentiment prediction.
Related work
General-purpose sentiment analysis tools do not perform well in the SE domain because these tools are not created by using specialized vocabulary. Few tools for the SE domain are created but these tools are tested against the general-purpose tools. The purpose of Islam et al. study is to investigate which tool is best for the SE domain and to what extent predictions of these tools agree/disagree with each other. Stack Overflow posts, JIRA issue comments, and Code review comments authors created datasets, and three sentiment analysis tools named SentiStrength-SE, Senti4SD, and EmoTxt were tested. SentiStrength-SE achieved the highest accuracy on the JIRA issue comments, whereas, Senti4SD had high accuracy on the Stack Overflow dataset. The overall average accuracy of SentiStrength-SE is 65.26% on the Code review dataset. It is observed that all these tools struggle to compute negative sentiments.
In the SE domain, sentiment classifiers trained on general-purpose datasets are biased in classifying neutral sentences as negative. A balanced Gold standard dataset consisting of 4423 posts was developed manually. Distributed Semantic model was created by using 20 million Stack Overflow posts. The authors tried to overcome this by creating an SVM classifier using lexicon-based, keyword-based, and semantic features using the R interface. 25x features ranked by information gain were selected. Senti4SD was compared with SentiStrength and SentiStrength-SE. Calefato et al. observe 19% improvements in precision for negative and 25% improvements in recall for the neutral class compared with SentiStrength.
In another research, Lin et al. developed a sentiment analysis technique for a software library recommender system. Authors extracted 40k sentences from stack overflow and manually labeled them positive, neutral, and negative. Recursive Neural Network (RNN) was used to compute the sentiment of sentences. The newly developed technique is named Stanford CoreNLP–SO. The proposed technique was applied to three SE datasets: Stack Overflow, Mobile app reviews, and JIRA issue comments. The technique was compared with four cutting-edge techniques named SentiStrength, NLTK, Stanford CoreNLP, and SentiStrength–SE. Precision and recall are used as evaluation metrics. After extensive training, the authors observed the negative results. The results of all the techniques are comparable but not satisfactory to recommend the APIs. It concludes that sentiment analysis for SE is not yet mature and requires the attention of researchers.
Novielli et al. did a study to replicate the results of. The authors include all three cutting-edge tools available for sentiment analysis of the SE domain. This study investigates which tool is best for the SE domain and to what extent these tools agree/disagree with each other. JIRA issue comments, Stack Overflow posts, Code review comments, and Java libraries authors created datasets, and three sentiment analysis tools named SentiStrength-SE, Senti4SD, and SentiCR were tested. The accuracy of tools is detected by measuring the precision, recall, and F-score. SE-specific tools performed well as compared with baseline SentiStrength. SentiStrength-SE achieved the highest accuracy on the JIRA dataset whereas, Senti4SD had high accuracy on the Stack Overflow dataset. The F-measure for Senti4SD is 0.84 on SO data.
Islam et al. compare the four dictionaries (AFFIN, VERDA, Senti-Strength, MPQA) to identify which has a higher or lower potential for the analysis of sentiments in Software Engineering text. Results show that AFFIN performance is better for analyzing SE text whereas MPQA performs poorly due to informal words.
The first paper in which BERT Base is trained on 55000 manually annotated sentences of SO posts. The proposed model is compared with the authors’ previous work, i.e., RNN4SentiSE and SentiMoji. The single sentence-based BERT model achieved 0.87 F-measure. The authors did not compare the proposed model with the domain-specific sentiment analysis tools.
Wu et al. stated that most sentiment analysis tools are trained on movies and product review datasets; therefore, these tools produce negative results when applied to the SE domain. To overcome this limitation, authors fine-tune the BERT Base model (BERT-FT) on GitHub and SO datasets. A comparison of BERT-FT is made with two existing SA tools. The performance of BERT-FT is better than SentiCR and Senti4SD tools. BERT-FT is trained independently on different datasets for comparison purposes. It means that the different BERT models are fine-tuned on six datasets to produce the results.
Batra et al., reported that there is much room to improve existing SE-based sentiment analysis tools because of low F1-score. The authors trained three different models of BERT named BERT-Base, RoBERTa, and ALBERT on GitHub, Jira, and SO datasets and proposed a ranking-based ensemble of BERT models. In addition to this, Barta et al. also used Distil BERT which is a compressed variant of the BERT model. The proposed model achieves 6 to 12% improvements on all datasets. This research’s limitations are that not a single model produces the best results on all the datasets, and the proposed models are not compared with the existing SE domain-specific sentiment analysis tools. The overall F1-score of the authors’ best model is 0.85.
In a recent research, Uddin et al. studied the various SE-specific sentiment analysis tools and observed that no single tool gives satisfactory results. Therefore, the authors proposed the ensemble-based sentiment analysis tool, an ensemble of five existing sentiment analysis tools, and RoBERTa. Prediction of existing sentiment analysis tools and text is input to the RoBERTa. The F1-score of a score of the developed tool is 0.805, whereas the F1-score of the standalone RoBERTa is 0.801.
Experiment 1: Fine tuning CQA-BERT
In the first two experiments, the Hugging Face library, which is the PyTorch interface for working with BERT is utilized. In addition to pre-trained transformer models, this library also includes several pre-built task-specific modifications of these models. Bert for the Sequence Classification model is fine-tuned for domain-specific sentiment analysis. In this model, a single layer of neurons is added at the top of BERT for classification. When domain-specific data is fed the entire BERT and classification layer is trained for a specific task.
Google Colaboratory is used for implementation in all experiments with BERT. Authors fine-tune both BERT_Base_Uncased and BERT_Large_Uncased models for domain-specific sentiment analysis. Models were trained on different sentence lengths i.e. 64, 128, 256, and 512. The model’s accuracy across different sentence lengths was calculated for example accuracy of the BERT-Base model on a test dataset with a sentence length of 64 is 0.825, and the accuracy with 256 sentence length is 0.846 and the accuracy with 512 sentence length is 0.846. From the results of different sentence lengths, it is observed that increasing sentence length does not considerably improve the accuracy of the model therefore, 256 sentence length is used in the rest of the experiments. The accuracy of both fine-tuned models on the validation dataset is 0.850 whereas the test data accuracy of the Bert-Base model is 0.846 with a sentence length of 256 is higher than the Bert-Large model. Precision, recall, and F1-Score metrics consistently reflected the strong performance of both models. The Cohen’s Kappa coefficient, measuring inter-rater agreement, was 0.722 for Bert-Base and 0.723 for Bert-Large, indicating substantial agreement. Additionally, the area under the receiver operating characteristic curve (AUC) values further affirmed the models’ discriminative power, with Bert-Base achieving an AUC of 0.861 and Bert-Large close behind at 0.867. These comprehensive results underscore the robustness of both Bert-Base and Bert-Large, with Bert-Base exhibiting a slight advantage in accuracy.
Fuzzy ensemble validation on CodeReview dataset
The classification results of fine-tuned models on the CodeReview dataset, as presented in the Fig 9, reveal nuanced insights into their performance. Notably, the Bert-Base model achieves a commendable accuracy of 0.889, demonstrating its ability to correctly classify instances in a binary sentiment setting. However, the precision and recall metrics suggest that while the model is accurate, it may struggle with capturing the full scope of positive instances, as evidenced by the precision of 0.854 and recall of 0.681.
The CQA-Bert model exhibits superior overall performance, with an accuracy of 0.919, demonstrating its effectiveness in binary sentiment classification. The high precision (0.908) and recall (0.767) values indicate a well-balanced ability to correctly identify both positive and negative instances. The model’s F1-Score of 0.822 further underscores its balanced performance in achieving both precision and recall.
On the other hand, the Bert-LSTM and Bert-GRU models display lower recall values, suggesting challenges in identifying positive instances. These models may be prone to false negatives, potentially missing positive sentiments in the CodeReview dataset. The Bert-CNN model, while achieving a high accuracy of 0.832, exhibits lower precision (0.723), indicating a higher rate of false positives. This trade-off between precision and recall is a critical consideration based on the specific requirements of the sentiment analysis task.
Interestingly, the proposed Fuzzy Ensemble model demonstrates notable improvements in performance on the CodeReview dataset. Despite the initial challenges posed by training models on a multi-class classification problem for a binary dataset, the Fuzzy Ensemble achieves an accuracy of 0.877, showcasing its adaptability and effectiveness in refining sentiment predictions. The precision (0.908) and recall (0.796) values suggest a well-balanced performance, resulting in a high F1-Score of 0.848. Additionally, the Cohen’s Kappa and ROC AUC values for the Fuzzy Ensemble align closely with those of the CQA-Bert model, indicating comparable overall effectiveness.
In summary, the CodeReview dataset’s binary nature poses challenges for models initially designed for multi-class classification. Despite this, the Fuzzy Ensemble model emerges as a promising solution, significantly enhancing sentiment classification performance and achieving results that are acceptable and competitive within the given context.
Conclusion and future work
Sentiment analysis, a challenging task for both machines and humans, has garnered substantial attention in the context of software engineering texts. As demonstrated by Pang and Lee, even human sentiment analysis accuracy hovers around 80%. In response to this challenge, our research undertook a large-scale evaluation of existing sentiment analysis tools for software engineering, coupled with the training of diverse classifiers to enhance accuracy. The extensive preprocessing phase was integral to refining the classifiers, ensuring their robust performance. The dataset, sourced from diverse software engineering interactions in SentiSE, served as a comprehensive benchmark for our evaluations. Notably, our proposed Fuzzy Ensemble model emerged as the epitome of accuracy across all datasets. Specifically, the Fuzzy Ensemble model achieved remarkable accuracy scores: 0.877 on the CodeReview dataset, 0.888 on the JavaLib dataset, 0.785 on the Jira dataset, and an outstanding 0.901 on the Stack Overflow dataset. These results substantiate the efficacy of the Fuzzy Ensemble model in accurately discerning sentiment within various software engineering contexts. Crucially, our evaluation positioned the Fuzzy Ensemble model as the superior performer compared to established state-of-the-art tools, including outperforming GPT on all datasets examined in this paper. This underscores the significance of our proposed model as a robust and versatile solution for sentiment analysis in the intricate landscape of software engineering texts. In conclusion, our research not only contributes valuable insights into the performance of sentiment analysis tools within the software engineering domain but also establishes the Fuzzy Ensemble model as a potent and accurate tool. The strides made in enhancing sentiment analysis accuracy hold promise for advancing the understanding of sentiment in software engineering, paving the way for more sophisticated and effective applications in the future.
In the future, a plan to extend domain-specific sentiment analysis tools to predict sentiments on aspect level is under consideration. The creation of a lexicon-based sentiment analysis tool to automatically extract lexicon from domain-specific datasets is also under process. The accuracy of the Fuzzy Ensemble model can be improved by using the balanced training dataset and a larger dataset for fine-tuning the Bert models. The results of the Fuzzy Ensemble model will be used to prioritize the software requirements and this model is part of the prioritization framework that consists of Quality Assessment, sentiment detection, topic modeling and prioritization module.


