Section 3 Future Roadmap

## **Chapter 4**

## Sentiment Analysis of Social Media Using Artificial Intelligence

*K. Victor Rajan*

## **Abstract**

Social media refers to the development and sharing of sentiment, information, and interests, as well as other forms of opinion via virtual communities and networks. Nowadays, social networking and micro blogging websites are considered reliable sources of information since users may openly express their opinions in these forums. An investigation of the sentiment on social media could assist decision-makers in learning how consumers feel about their services, products, or policies. Extracting emotion from social media messages is a difficult task due to the difficulty of Natural Language Processing (NLP). These messages frequently use a combination of graphics, emoticons, text, etc. to convey the sentiment or opinion of the general people. These claims, known as eWOM (Electronic Word of Mouth), are quite common in public forums where people may express their opinions. A classification issue arises when categorizing the sentiment of eWOM as positive, negative, or neutral. We could not use standard NLP tools to examine social media sentiment. In this chapter, we will study the role of Artificial Intelligence in identifying the sentiment polarity of social media. We will apply ML(Machine Learning) methods to resolve this classification issue without diving into the difficulty of eWOM parsing.

**Keywords:** social media analytics, sentiment analysis, artificial intelligence, electronic word of mouth, machine learning

## **1. Introduction**

Sentiment polarity has a context-sensitive meaning in sentiment analysis. Based on the sum of the positive and negative opinions stated about an event, automatic methods calculate the sentiment polarity. Generally, daily sentiment scores are often calculated by measuring the number of positive as well as negative words in a sentence. A sentence with more negative words (reflecting violence, anger, sadness) than positive (displaying happiness, celebration, joy) is deemed negative.

**Definition**: Sentiment polarity of textual data is the result of analysis expressed in terms of a numerical value obtained by the algebraic sum of opinion contained in each entity of the sentence, document, or message. The sentiment polarity can be determined as positive, negative, or neutral.

Sentiment polarity score (*Sp*) of a message is the linear combination of all polarities. This is in turn converted as a ratio to the sum to get a rational value between �1 and 1. Hence,

$$\mathbf{S}\_p = \begin{pmatrix} \mathbf{W}\_p \ \mathbf{W}\_n \end{pmatrix} / \begin{pmatrix} \mathbf{W}\_p + \mathbf{W}\_n \end{pmatrix} \tag{1}$$

where *Wp* denotes the number of positive words in the and *Wn* represents a number of negative words in the message.

Several decision-makers, including business organizations and governmental authorities, may learn more about public opinion by using social media analytics. Short messages are used by users to share their opinions on social networking platforms. Sentiment analysis of social media evaluates emotions and opinions [1]. These social media messages reflecting the opinion, sentiment, and emotion of the public via a combination of text, images, and emoticons are sometimes referred to as eWOM.

**Definition:** eWOM refers to messages that are written to be exposed via internet-mediated online communication, especially towards a brand, product, or organization.

The field of social media analysis has grown up fast in this decade to answer the question 'What do people feel about a certain event or topic?'. Analyzing the sentiments, opinions, and emotions of people has its importance. For instance, we could assess a community's well-being; we can stop suicides, etc. Additionally, by examining client feedback, businesses may gain a great deal of insight into the level of consumer satisfaction. However, the non-standard format of these messages makes it challenging to understand the language of eWOM. For example, the message 'Enjoying my lazy Sunday !!' is a mix of words and emoji representing positive sentiment about Sunday. An eWOM like this is difficult for parsing because it contains special and emoticons symbols. The context of the sentence could not be interpreted unless parsers are also familiar with the meaning of the emoji . Sentiment analysis would not be correct until these messages are translated into plain text while retaining their context and emotions.

Social media users always express their sentiments over a product or a public event. A user-generated message containing sentiment can be defined as a quadruple:

$$\mathbf{u} = (\mathbf{o}, \mathbf{f}, \mathbf{s}, \mathbf{h}) \tag{2}$$

here

o indicates a target object.

f represents a feature of the object.

s denotes the sentiment value of the opinion (+ve, �ve, or neutral).

h signifies opinion holder.

For example, the following is a user review of mobile phones.

*Although the battery life of my new phone is not long, that is ok for me.*

When we parse this message, we get the quadruple as follows: o new phone. f battery life. s not long (-ve sentiment). h ok for me.

Sentiment analysis involves major sub-tasks namely pre-processing, transformation, and classification. Though pre-processing and transformation can be done using text manipulation, classification is a complex task. It involves recognizing the sentiment along with the context. The system should interpret the meaning and analyze the sentiment similar to human intelligence. A systematic methodology is needed as shown below.


Artificial Intelligence (AI) is a powerful source for the crowd's wisdom to filter out non-textual information and our study focuses on how artificial intelligence can effectively be used to identify the sentiment of eWOM.

## **2. Architecture of social sentiment analysis system**

After extracting plain text from social media messages, we can use computer algorithms to automatically classify the sentiment polarity. The following two categories might be used to broadly classify sentiment analysis algorithms:


The subjectivity, polarity, or object of any opinion is frequently determined by a lexicon-based system using a set of criteria created by people. These rules may take into account a variety of NLP methods developed in computational linguistics, like part-of-speech tagging, tokenization, stemming, and parsing.

Contrary to lexicon-based systems, AI-based methods are on the basis of ML algorithms instead of hand-crafted rules. Typically, the process of identifying the polarity of sentiment is defined as a classification problem, in which a classifier is provided a text and outputs a polarity label, like positive, negative, or neutral.

Lexicon-based systems do not perform well due to the non-standard language of social media users. Results are more accurate, which is one major advantage of AIbased systems. They resemble a human scoring system while classifying the sentiment polarity by taking the contextual information into account. Machine Learning algorithms are widely used to solve complex real-world problems. It is a promising strategy that has been widely used in AI disciplines including NLP, semantic parsing, transfer learning, computer vision, and many others. Social media sentiment analysis is a complicated task because of the following difficulties:


Automatic systems try to extract the sentiment polarity using computer algorithms and techniques. The colloquial language makes it hard for automatic systems to interpret the context and sentiment being expressed. The sentiment analysis methodology we show here employs machine learning methods to classify sentiment at the sentence level and acts directly at that level (**Figure 1**).

The first step is to translate the eWOM into plain English text using pre-defined mapping for symbols and emojis. The text is then converted to a feature vector representing the features. The Ml method creates a model from pairs of feature vectors and labels (such as positive and negative), which are input into the process. The well-trained model predicts sentiment polarity for new incoming input.

## **3. Feature engineering of messages**

Social media messages are not well-formed and unstructured. The system for analyzing sentiment needs to be tailored to handle the style and specifics of this informal writing style. For example, the message "Enjoying my lazy Sunday " signifies a positive sentiment. It comprises one word and one emoji representing happiness. Feature engineering is the method of selecting and transforming unprocessed data into features that could be utilized in ML. The inclusion of symbols and emojis plays a significant role in detecting hidden sentiments. The first step in processing the eWOM is feature engineering. We need to derive meaningful sentences

**Figure 1.** *Architecture of sentiment analysis system.*

from eWOM so that the message is informative, non-redundant and supports the next learning and generalization steps [2]. Feature engineering (FE) works as follows.


Translation of emojis is a crucial part of the feature selection. Popular emojis used in sentiment analysis can be translated to plain text using their corresponding Unicode Common Locale Data Repository (CLDR) meaning. The Unicode chart offers a list of the emoji character, codes, and meanings. For example, has the code U+1F604 and means smiling face. Similarly, has the code U+0270C which means victory hand. A complete list of Unicode for emojis is available at "http://unicode.org/emoji/charts/f ull-emoji-list.html" for reference. Translation of emojis helps us to capture the sentiment without losing the original context. The following diagram indicates the steps involved in the feature engineering of eWOM (**Figure 2** and **Table 1**).

The converted plain text may not be a meaningful English sentence but it captures the original sentiment and context. This could be applied as an input vector to ML algorithms. Following are examples of a few plain texts extracted from eWOM.

**Figure 2.** *Feature engineering of eWOM.*


#### **Table 1.**

*Sentences extracted from eWOM.*

The extracted plain text is given as input to an automatic system that uses a machine learning algorithm for classification. The automatic system is defined as follows.

Sentiment polarity classification system M is a quadruple

$$\mathbf{M} = \{\mathfrak{a}, \lambda, \mathfrak{d}, \mathfrak{q}\}\tag{3}$$

where

α ¼ f g *e*1,*e*2, … *en* is a set of messages from social media,

λ ¼ ∣*ei* � *ej*∣ is a function that calculates the similarity score of messages,

δ !an algorithm to classify the sentiment polarity, and

φ ¼ *Sp*, *Sn*, *So* is a set of output labels: positive, negative, and neutral.

For a given input in α, the algorithm δ produces an output label in φ with the help of the function the following diagram shows the overview of the sentiment classification machine (**Figure 3**).

**Figure 3.** *Sentiment polarity classification system.*

The sentiment polarity of social media messages can be efficiently predicted by an artificial intelligence system if we identify the right choice for

1.Function to calculate the similarity score of two messages.

2.A machine learning algorithm for classification.

We will discuss the selection of algorithms for these two tasks in detail in the following sections.

## **4. Similarity score of messages**

Machine learning algorithms mainly work on numerical input vectors. It is essential to convert the pre-processed text to a numerical vector for algorithms to predict the sentiment polarity correctly. The ML model is trained with labeled data sets for positive, negative, and neutral messages. A well-trained model predicts the sentiment polarity of incoming messages by comparing it with members of the training data set. Comparing two messages and giving a numerical score on how similar they are being important for high accuracy. TF-IDF ("Term Frequency-Inverse Document Frequency") is a vectorization approach used widely in text processing. This approach examines the relative frequency of terms in a text via an inverse percentage of the phrase throughout the full corpus of documents [3, 4]. It works well for text categorization or making it possible for machines to interpret input words represented as numbers. In TF-IDF, the same texts must result in a closer vector. TF-IDF is the multiplicative product of the Term Frequency and Inverse Document Frequency scores of the word.

TF represents the "number of times the word appears in the doc / Total number of words in the document.

IDF ¼ ln Number of documents ð Þ *=*Number of documents the word appears in *:*

$$\text{TF-IDF} = \text{TF}^\* \text{IDF} \tag{4}$$

The phrase is rarer and vice versa, depending on the TF-IDF score. A smaller score between the documents indicates that they are highly similar to each other. A score of 0 indicates that the papers are entirely equal. Following is an illustration of TF-IDF score calculation using two simple sentences.

Document 1: It is going to rain today. Document 2: Today I am not going outside.


#### *Advances in Sentiment Analysis – Techniques, Applications, and Challenges*


**Table 2.**

*Word count.*

Step 1: Tokenize the words and count their frequency (**Table 2**). Step 2: Find Term Frequency "(TF).

TF ¼ ðNumber of times the word appears in the documentÞ*=*ð Þ Total no*:*of words in a document (5)


#### **Table 3.**

*Term frequency.*

(See **Table 3**).

Step 3: Find IDF for documents.

IDF ¼ Log Number of documents ½ � ð Þ*=*ð Þ Number of documents containing the word (6)


*Sentiment Analysis of Social Media Using Artificial Intelligence DOI: http://dx.doi.org/10.5772/intechopen.113092*


#### **Table 4.**

*Inverse document frequency.*

## (See **Table 4**). Step 4: Calculate TF-IDF for each word.



#### **Table 5.**

*TF-IDF for two documents.*

## (See **Table 5**).

To measure the similarity between these 2 documents, we need a distance metric. Hamming distance is suitable to measure the distance between column vectors.

Hamming distance is used usually with boolean or string vectors, detecting the points where the vectors do not match. While comparing two vectors of equal length, it is the number of positions in which the values are different. It is also known as the overlap metric.

Now let's use hamming distance to measure the distance between the documents (**Table 6**).



**Table 6.** *Hamming distance between Document 1 and 2.*

$$
\lambda \, (\text{doc1}, \text{doc2}) = 8 \tag{8}
$$

We observe that these two documents have only two words in common. Hamming distance of TF-IDF is eight. The similarity score generated by our algorithm is a good metric to measure the distance between documents. Two similar documents will have a score of zero. A non-zero score indicates their distance. Having converted the input to a numerical vector and identified a distance metric, we can now use a machinelearning algorithm for sentiment polarity classification.

## **5. Sentiment classification using machine learning**

An identification task for sentiment polarity is usually defined as a classification problem, where a classifier is fed a text and outputs a label, like "positive, negative, or neutral". In general, supervised and unsupervised learning techniques may be used to

**Figure 4.** *KNN classification with k = 9.*

*Sentiment Analysis of Social Media Using Artificial Intelligence DOI: http://dx.doi.org/10.5772/intechopen.113092*

classify text using a machine learning methodology. Many tagged documents are used in the supervised approaches. Unsupervised approaches are employed when it is challenging to find these labeled training documents. Since thousands of messages of emitted every minute on social media, we can manually label a few thousand and use them for supervised learning. A training data set consisting of three labels namely, positive, negative, and neutral is prepared by picking messages from social media sites like Twitter, Facebook, etc. Only the training documents that are most similar to the incoming document are used by the machine learning algorithm to label it. Popular text classification algorithms include K-Nearest Neighbor (KNN). With the help of supervised learning, this method divides objects into one of the predetermined categories of a sample group. Here we will see how KNN can be used to classify sentiment polarity. If we represent the numerical vectors as points in a diagram, then the training data set will look like this (**Figure 4**).

It is trained with a set of labeled data sets. The label of incoming input is predicted based on the majority voting of its neighbors. The algorithm can be described below.

#### **Algorithm**: KNN classification


We have three clusters for the labels namely positive, negative, and neutral. During training, labeled data items form the clusters based on the distance from their neighbors. A new data point is assigned a label by picking up nine neighbors and their majority voting.

#### **5.1 Popular algorithms for classification**

We have seen how KNN supervised learning method could be applied used for sentiment polarity classification. However, there are few other machine learning algorithms. Researchers can experiment with the following algorithms and choose the right choice based on performance.

**XG boost**: Extreme Gradient Boosting is referred to as XGBoost. The GBDT ("Gradient-Boosted Decision Tree") ML approach is scalable and distributed. It offers parallel tree boosting and is the most effective ML technique for classification and regression issues.

**Support vector machines (SVM)**: SVM is a supervised method in which the learning method examines the data and finds patterns. We display the data as points in an "n-dimensional" space. The value of every attribute is then connected to a specific coordinate, which facilitates categorization.

**Naive bayes(NB)**: NB is depending on Bayes' Theorem, an approach for determining conditional probability on the basis of previous information and the naive belief that each attribute is independent of the others. The greatest advantage of Naive Bayes is that it works quite well even with small amounts of training data, whereas the majority of ML algorithms rely on huge amounts of training data.

**Convolutional neural networks (CNN)**: Deep learning is gaining popularity due to enhanced chip processing capabilities (GPU units), much cheaper hardware costs, and major advancements in ML methods. Deep neural network design was first used by researchers to assess document similarity. A series of word embeddings constructed from data sets used as inputs to train a CNN-based representation learning model may also be utilized to classify the sentiment polarity.

## **5.2 Popular performance metrics for classification**

The performance of a machine learning algorithm needs to be evaluated before selecting the model for real-world applications. Our sentiment analysis is a classification problem. The results of any classification algorithm can be evaluated by creating a confusion matrix and popular metrics. The following table shows the confusion matrix for a "binary classification" model (**Table 7**).

Based on the elements of the confusion matrix, a set of metrics is generally calculated for assessing the performance of the classification model.

## *5.2.1 Accuracy and error rate*

A classification model's quality may be assessed using these key metrics. A "true positive, a false positive, a true negative, and a false negative", respectively, are denoted as TP, FP, TN, and FN. Following are definitions for the terms Accuracy and Error Rate in classification.

$$\text{Accuracy} = \frac{(\text{TP} + \text{TN})}{\text{N}}, \text{Error Rate} = \frac{(\text{FP} + \text{FN})}{\text{N}} \tag{9}$$

where *N* indicates the total number of samples. Clearly, we have Error Rate = 1 Accuracy.

## *5.2.2 Recall, F1 score, and precision*

These are also the main metrics for unbalanced test sets, and they are applied more frequently than error rate or accuracy. For binary classification, precision, as well as recall, are specified below. The harmonic mean of recall and accuracy is the F1 score.


**Table 7.**

*Confusion matrix for classification model.*

The F1 score is best when it is 1 (perfect recall and precision), and it is worse when it is 0.

$$\text{Precision} = \frac{\text{TP}}{\text{(TP} + \text{FP)}}, \text{Recall} = \frac{\text{TP}}{\text{(TP} + \text{FN)}}, \text{F1-Score} = \frac{2^\ast \text{Prec}^\* \text{Rec}}{(\text{Prec} + \text{Rec})} \tag{10}$$

We may always calculate recall and precision for every class label in multi-class classification problems, assess each class label's performance individually, or simply average the numbers to obtain the overall recall and precision. The average for the three classifications positive, negative, and neutral in our situation may be determined.

## **6. Applications of social media sentiment analysis**

Traditional polling may be replaced by AI-based social media analysis, which is also a more affordable way for decision-makers to comprehend the situation and address any emerging crises. Social media is used by the public proactively to express their sentiment and opinion. People post millions of messages every minute on social media. If these messages are analyzed and opinion is extracted, it will help decision-


#### **Table 8.**

*Sentiment classification by automatic system.*

**Figure 5.**

*Real world applications of social media analytics.*

makers to quickly respond to any crisis. Following are examples of sentiments captured by an automatic system from Twitter (**Table 8**).

Results are convincing in the possibility to replace manual sentiment classification with automatic systems. The experimental results show promising output and can be used by online marketing companies, and government agencies for decision-making [5]. Online advertisement agencies can use this study for effectively targeted marketing campaigns. On the other hand, Government organizations could know how the public is affected by a policy or decision and then decide how to respond to public opinion. It has many applications in the real world. The above diagram shows the areas where social media analytics is finding its applications (**Figure 5**).

It allows business organizations to determine how consumers feel about their brands and products, identify how they feel about advertising efforts, and generally track which way the wind is blowing. Social media analytics helps commercial organizations in the following areas:


## **7. Conclusion**

The AI strategy produced greater results when it came to categorizing eWOMs' sentiments based on polarity. The two-step process, namely Feature Extractor and Machine Learning, eliminates the main difficulty in employing NLP tools to comprehend social media communications. Commercial enterprises may increase accuracy and acquire greater insights when assessing customer comments and complaints by employing a centralized sentiment analysis system. The following are some general advantages of AI-based sentiment analysis:

**Sorting data at scale:** It is difficult and time-consuming to manually review thousands of tweets, customer service discussions, or survey responses. AI-based sentiment analysis enables businesses to analyze massive amounts of data economically and efficiently.

**Real-time analysis:** Organizations may immediately detect dangerous circumstances on a real-time basis with the use of social media analysis and take action before consumers start to leave. Text sentiment labeling is highly subjective and is affected by personal experiences, viewpoints, and opinions. Words such as extremely, quiet, most, etc. are examples of intensifiers. These are the terms that affect how the adjacent non-neutral terms feel. They may be broken down into 2

categories: those that raise the intensity of feeling (very, very much) and those that tone it down (little). Through a rule-based method, determining the strength of an emotion might not be straightforward. The AI-based model may still be improved to determine the level of emotion intensity.

## **Author details**

K. Victor Rajan Atlantic International University, Hawaii, USA

\*Address all correspondence to: victor@jts.co.in

© 2023 The Author(s). Licensee IntechOpen. This chapter is distributed under the terms of the Creative Commons Attribution License (http://creativecommons.org/licenses/by/3.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

## **References**

[1] Iriani A, Hendry, Manongga DHF, Chen R-C. Mining public opinion on radicalism in social media via sentiment analysis. International Journal of Innovative Computing, Information and Control. 2020;**16**(5):1787-1800

[2] Adnan D, Fei S. Feature selection for sentiment analysis based on content and syntax models. Decision Support Systems. 2012;**53**:704-711

[3] Qaiser S, Ali R. Text mining: Use of TF-IDF to examine the relevance of words to documents. International Journal of Computer Applications. 2018; **181**:25-29

[4] Ravi K, Ravi V. Sentiment classification of Hinglish text. In: Third International Conference in Recent Advances in Information Technology. RAIT-2016. 2016. pp. 641-645. DOI: 10.1109/RAIT.2016.7507974

[5] Ravi K, Ravi V. A survey on opinion mining and sentiment analysis: Tasks, approaches and applications. Knowledge-Based Systems. 2015;**89**: 14-46. ISSN: 0950-7051

## **Chapter 5** Citizen Sentiment Analysis

*Yohei Seki*

## **Abstract**

Recently, the co-creation process between citizens and local governments has become increasingly significant as a mechanism for addressing administrative concerns, such as public facility maintenance, disaster response, and overall administrative improvement driven by citizen feedback. Social media platforms have been recognized as effective tools to facilitate this co-creation process. Compared to traditional methods like surveys and public comment solicitations, social listening is deemed superior for obtaining authentic and naturally articulated citizen voices. However, there is a noticeable lack of research concerning the gathering of opinions specifically related to municipal issues via platforms like X (Twitter). This study seeks to address this gap by presenting an original methodology for analyzing citizen opinions through the deployment of large language models. Utilizing these models, we introduce three distinct applications based on our framework, each considering a different opinion typology. We demonstrate that our approach enables the analysis and comparison of citizen sentiments across various cities in relation to common political issues, tailoring the analysis to diverse goal types. The results of this research not only contribute to the understanding of citizen engagement via social media but also provide valuable insights into potential applications of large language models for municipal-related opinion analysis.

**Keywords:** sentiment analysis, social listening, X (Twitter), citizen engagement, large language models

## **1. Introduction**

Citizen cooperation has become indispensable in recent years in local government administration as a way to reduce administrative costs. The advent of communication through social networking sites (SNS) has enabled citizens to identify and tackle administrative issues such as the repair of public facilities, graffiti removal, and disaster countermeasures, akin to the Open311 platform<sup>1</sup> .

However, citizen participation is paramount in the decision-making process of local government administration. Traditional methods of collecting opinions, such as questionnaires and public comments, have inherent limitations, including a limited participant pool and the influence of vocal individuals. As a solution, the potential of public opinion analysis using SNSs like X (formerly known as Twitter) has been acknowledged.

<sup>1</sup> https://www.open311.org/

For an authentic collection of citizen opinions, it is crucial to garner opinions from specific municipalities through social media platforms. While participation in region-specific SNSs might be low, platforms like X with a larger user base can serve as a useful tool for collecting and analyzing citizen opinions on administrative issues. In Section 3.2, we introduce a strategy to amass citizen sentiment in a specific city.

Given the age group bias in X participation, directly incorporating citizen opinions from X into public administration might not be feasible. Hence, it is crucial to comparatively analyze these opinions with those from other cities. While city comparisons are necessary, there is a dearth of studies that collect and compare tweets from multiple cities using a social listening approach. To address this gap, we introduce a general framework in Section 3. In Sections 4, 5, and 6, we also present research on citizen sentiment across cities through three concrete applications, linking it to realworld scenarios.

While sentiment and polarity analysis have traditionally been used for product reviews and X trends, it is vital to assess citizens' attitudes toward the target of their opinions when analyzing their authentic voices. This requires annotated corpora with detailed information, tailored to the application's goal. We introduce three types of opinion typology in line with the application's objective.

Collecting opinions on specific administrative issues from SNS poses challenges due to the diverse range of topics discussed. It's not only important to collect opinions with relevant keywords but also to consider and analyze them within the context of the administrative issue at hand. As facility and event names related to administrative issues vary from city to city, creating tailored training data for opinion analysis for each city and administrative topic is desirable, albeit cost-intensive.

This chapter details the research conducted to address these challenges, emphasizing the use of large-scale language models and fine-tuning approaches for citizen opinion analysis. Our work builds on the studies by [1, 2] and explores the application of these methods in citizen sentiment analysis.

## **2. Related works**

Sentiment analysis or opinion mining has been conducted for a long time [3]. The first target document genre is newspaper [4], product review [5], or blogs [6]. Then, social media such as Twitter (now called X) became the main target to conduct public opinion analysis [7, 8]. Recently, social media sentiment analysis has been extended to applications focused on public service [9]. In this section, we discuss two types of related works from the two viewpoints as follows: (a) applications of citizen sentiment analysis and (2) opinion typology used for citizen sentiment analysis.

#### **2.1 Application of citizen sentiment analysis**

Citizen sentiment analysis has been a focal point since 2010 [8]. Subsequently, researchers have explored citizen comments in various domains, such as urban projects [10], reactions to government secretary accounts [11], and responses to the COVID-19 pandemic [12], all of which have proven to be effective target domains.

Alizadeh et al. [10] conducted research to collect citizen opinions for informing local government decision-making. They gathered tweets using project-specific hashtags or query keywords. Hubert et al. [11], on the other hand, explored citizen comments in response to tweets posted by five secretaries of the Government of Mexico.

In contrast, our method focuses on collecting more generalized citizen opinions relevant to political issues across different cities. We collected citizen comments based on the city using the approach described in Section 3.2. Additionally, we extracted citizen responses using broader query keywords related to political issues, including those pertaining to COVID-19 infections. This approach allows us to gain insights into the broader sentiments and opinions of citizens across cities on various political matters, offering valuable information for decision-making and policy analysis.

#### **2.2 Opinion typology used for citizen sentiment analysis**

Opinion analysis on Twitter (X) has attracted significant attention from numerous researchers, primarily focusing on the classification of emotions in tweets [13–15]. Dini et al. [13], for instance, challenged the conventional assumption that all tweets inherently express opinions and consequently introduced a task for identifying nonopinionated tweets. In contrast, Jabreel et al. [14] designed a classification task to identify a single emotion and proposed an attention-based technique for recognizing multiple emotions within a tweet.

These pioneering studies have advanced Twitter opinion analysis, exploring diverse aspects such as emotion classification and identification of opinion-expressing tweets. However, they primarily focus on polarity [16] and emotion classification [13–15, 17], which we argue, may not fully represent the breadth and complexity of citizens' opinions expressed on X.

In response to this gap, we propose a unique framework for citizen sentiment analysis. After presenting a common framework for this in Section 3, we introduce a set of opinion typologies tailored for different applications. These include eliciting feedback from citizens (Section 4), comparing policy discussion trends with city council members (Section 5), and estimating social connections among citizens (Section 6). We argue that these typologies offer a more nuanced understanding of citizen sentiment, enabling the extraction and organization of citizen feedback by analyzing tweets from a variety of perspectives.

## **3. Citizen sentiment analysis framework**

#### **3.1 Our framework overview**

We present a sentiment analysis framework designed for analyzing citizen comments, consisting of four stages as shown in **Figure 1**.


#### **Figure 1.**

*Our citizen sentiment analysis framework.*

The framework begins with the collection of city-specific tweets. These tweets are then categorized using a custom opinion typology implemented via a fine-tuned large language model. This typology, informed by the application's purpose, allows for a nuanced analysis of public sentiment. Next, we consolidate the categorized opinions based on their assigned labels within specific timeframes for each city. Finally, we visualize and compare the temporal trends of civic sentiment across different cities.

The methodology of the tweet collection stage is detailed in Section 3.2. The subsequent stages are discussed in relation to three applications: extracting civic feedback (Section 4), comparing citizens' and city councilors' opinions (Section 5), and estimating social capital (Section 6).

## **3.2 Crawling citizen comments**

In recent years, X (Twitter) has become a prominent platform for capturing citizen sentiments and opinions. Extracting relevant accounts from this vast social media platform is essential to gain valuable insights into local issues. This section introduces a method for efficiently crawling citizen comments on X, with a focus on city-level residents. To crawl citizen comments, we have proposed a methodology to collect citizen accounts from X using profile information [18].

## *3.2.1 Seeded resident account collection*

We define a method to collect citizen accounts by leveraging profile information. This method involves matching district names with user profiles to gather seeded resident accounts. Japan's Twitter user profile search service<sup>2</sup> plays a crucial role in extracting the initial set of seed accounts.

<sup>2</sup> https://twpro.jp/

## *3.2.2 Account extension*

To enhance the scope of our extracted accounts, we propose extensions based on followers' characteristics. These extensions are subjected to three specific constraints: the maximum number of followers (3000), the maximum number of friends (4000), and the minimum number of followers of the seed account. The first two constraints were set to exclude famous people or bot accounts. By applying these constraints, we ensure that the extended accounts remain relevant and representative of city-level residents.

## *3.2.3 Preliminary experiment: Tsukuba City*

For evaluation purposes, we conducted a preliminary experiment in Tsukuba City, Japan, a city with a population of approximately 250,000. In this experiment, we targeted accounts relevant to Tsukuba City and extended them based on twice the number of followers (i.e., the followers of followers of followers). Additionally, we randomly selected 200 citizen accounts and manually annotated their career types.

## *3.2.4 Results and discussion*

The results of the manual annotations are presented in **Figure 2**, indicating a substantial representation of residential users among the extracted accounts. This observation aligns with Tsukuba City's demographic, which mainly consists of students due to its status as a academic city. The proposed X account extraction method proves effective in gathering citizen comments from city-level residents. By leveraging profile information and applying follower-based extensions, we obtained a significant dataset of valid residential users. The method's reliability and applicability are demonstrated through the case study in Tsukuba City, providing valuable insights for understanding local opinions and sentiments on X and other social media platforms.

**Figure 2.** *Career type rate in Tsukuba city.*

## **4. Application (1): extraction of citizen feedback**

In this section, we describe the application to extract citizen feedback for local government administration. This work is based on our paper [1].

## **4.1 Goal**

Obtaining citizens' feedback is crucial for enhancing local government and nongovernmental customer service initiatives and mitigating infectious disease spread, thereby promoting a vibrant social life. Current systems, like public comment platforms and council membership competitions, have limitations in attracting sufficient residents and may be biased toward certain attitudes. To address this, a new method is proposed for acquiring a large volume of unbiased and experienced citizen feedback.

The study introduces a novel approach to extract citizens' opinions from X, where users express diverse thoughts daily. Unlike conventional studies focusing on polarity and emotion classification, this research adopts appraisal theory [19] to categorize various opinions, thereby enabling a comprehensive analysis. A large language model (LLM) is utilized to analyze tweets from multiple perspectives and extract citizen feedback based on specific conditions.

By adopting this new approach, local governments and nongovernmental entities can obtain a diverse range of citizen opinions, leading to better policy guidance and service improvement. The proposed method enables policymakers to gain valuable insights into public sentiment during the pandemic, fostering more effective and inclusive decision-making processes.

## **4.2 Opinion typology for extracting citizen feedback**

This study introduces a novel methodology for gleaning citizens' opinions from the prominent social media platform, X. Capitalizing on the platform's user interaction diversity, we conveniently capture a broad range of civic sentiments. Our method hinges on three attitude categories derived from appraisal theory: affect (e.g., satisfaction or dissatisfaction), judgment of behavior (e.g., staff performance evaluation),

**Figure 3.**

*Appraisal opinion type for extracting citizen feedback.*


#### **Table 1.**

*Opinion typology used in our study [1].*

and appreciation (e.g., assessment of facilities or products). This approach empowers us to probe into the varied opinions expressed by citizens on X, differentiating feedback according to informational needs, as depicted in **Figure 3**.

To overcome the limitations of existing studies, which often overlook opinions and attitudes toward society, we propose analyzing citizens' opinions from multiple viewpoints, including appraisal opinion types, while also examining their chronological appearance frequency. By doing so, we aim to better understand citizens' opinions and attitudes toward society within specific time ranges during the COVID-19 pandemic. This comprehensive approach will yield a more holistic and nuanced understanding of public sentiment, thereby aiding policymakers and researchers in developing effective strategies and policies to address societal concerns.

Additionally, we address the absence of linguistic modality and speech act theory categories in appraisal theory by introducing the "communication opinion type" viewpoint. Furthermore, within the "attitude" category of appraisal theory, the value of the category combines both positive and negative opinions without distinction. To rectify this, we define the "polarity" viewpoint.

In summary, the opinion typology used in this study is presented in **Table 1**.

#### **4.3 Methodology**

We used a common LLM to simultaneously estimate the three viewpoints (polarity/appraisal/communication opinion types) of the opinion unit. The three viewpoints of the opinion units refer to the same opinion. Therefore, we assumed that these estimation tasks relate to each other and show their effectiveness of the multitask learning approach [20] for estimation tasks. By performing multiple tasks concurrently using a shared model, we performed that higher F1-scores were achieved compared to independent task performance significantly. This multitasks learning approach enhances opinion extraction accuracy. In the first paper [1], we used BERT model [21] as a pretrained LLM. In the later version [22], we updated our model using T5 model [23], because it was an LLM which leveraged a unified approach to treat all NLP tasks as a "text-to-text" problem, and was also suitable for multitask learning.

In addition, comparing citizen opinions across different cities is crucial to discern whether sentiments expressed are specific to the analyzed city or shared among citizens in diverse locations. However, variations in municipal policies and hospitality services necessitate creating another data for training citizen opinion extraction models in each city of interest. Creating training data for all cities incurs high costs, rendering such an approach unrealistic.

To address this challenge, in our work [22], we proposed a method for extracting citizen opinions in a target city by leveraging data from a city with pre-constructed

**Figure 4.**

*Selecting comments for labeling in target with confidence level.*

training data (referred to as the source city) alongside a relatively small amount of data from the target city. Specifically, we utilized the confidence levels of predictions made on the target city's data by a model fine-tuned on the source city's data to effectively select the target city's training data. The proposed method reduces the cost of creating training data to approximately half of that required for extracting citizen opinions from an entirely new city. The steps of our proposed method are illustrated in **Figure 4**.

In our experiments, annotating the top 50% of unlabeled tweets with confidence levels and applying fine-tuning to adapt to the target city outperformed methods that randomly selected 50% or the bottom 50% of unlabeled tweets significantly in terms of F1 score. Additionally, we observed no significant difference in estimation accuracy in terms of F1-score when compared to the estimation of opinion types using 100% of unlabeled data in the target cities as labeled training data for fine-tuning as an upper bound. Therefore, this approach allows us to discern sentiments across different cities more efficiently and cost-effectively.

#### **4.4 Comparing citizen feedback across different cities**

In this study, we conducted an analysis to extract citizens' opinions specific to target cities, using nursery school services as an example, in the governmentdesignated cities of Yokohama and Sapporo in Japan. Specifically, we focused on citizens' opinions expressing parental sentiments in Yokohama during the early period of the COVID-19 disaster in April 2020. The results revealed that Yokohama citizens who are raising children expressed dissatisfaction ("affect") with the city's policy to open daycare centers during this period. These opinions were specific to Yokohama residents and hold potential value for the city in improving its policies.

In contrast, the opinions of Sapporo citizens displayed a noteworthy trend, with a significant proportion consisting of evaluations ("appreciation") concerning various aspects, including events and things. This allowed us to extract opinions expressing confusion about the current situation of nursery schools remaining open during the COVID-19 pandemic, as well as opinions about specific events, such as cases of discrimination against infected people occurring at nursery schools. These tweets provided valuable insights for proposing policy improvements, as they shed light on specific events that citizens were troubled by and allowed us to discern areas where improvements could be made.

Our analysis highlighted the significance of extracting location-specific citizen opinions, as it provides valuable feedback for local governments to enhance policy decision-making processes and address citizens' concerns effectively.

## **5. Application (2): comparison of stances for citizens with city councilors**

In this section, we introduce the application of citizens'stances analysis for political issues to compare with the stances of city councilors, with referring to [2].

## **5.1 Goal**

In local governance, analyzing the disparities in citizens' and city councilors' opinions on political matters is vital for representing the people's will in politics and fostering citizen engagement. With the abundance of citizens expressing their views on X and city councils sharing meeting minutes as open data on the web, digital archives offer valuable resources for opinion analysis.

In this study, we propose and evaluate a method for automatically predicting stances in citizen tweets and city council minutes, subsequently aggregating the percentages of "favor" or "against" for each city. By comparing the results for each city, we ascertain the distinct characteristics of citizens and city councilors, underscoring the significance and efficacy of our approach.

### **5.2 Attribute type for comparing stances**

In our study, the dataset constructed may encompass texts unrelated to political issues. To address this, we performed annotations not only for "stance" but also for "relevance" to the political matter. Additionally, for a more in-depth opinion analysis, we further annotated two attributes: "usefulness," indicating whether the texts include specific information and evidence, and "regional dependency," determining if they are connected to the place of residence. An overview of the attribute typology employed in this research is presented in **Table 2**.

### **5.3 Methodology**

In our dataset, some texts do not explicitly mention political issues but contain opinions on them, while others seem to express opinions on unrelated topics. To achieve accurate stance prediction, it becomes crucial to account for the relevance of the political issue. Thus, in this study, we employed multitask learning [20] to simultaneously train the stance and relevance attributes. Moreover, considering the interconnected nature of the usefulness and regional dependency attributes with relevance, we also employed multitask learning, training them together with relevance. By adopting this multitask approach, we enhance the model's ability to capture the intricacies and dependencies among attributes, leading to more accurate and


**Table 2.** *Attribute typology used in our study [2].* comprehensive predictions of stance, relevance, usefulness, and regional dependency in citizen tweets and city council minutes.

#### **5.4 Comparing stances across different cities**

In this study, we direct our attention to the distribution of stance labels in order to identify valuable citizen and councilor comments related to political issues. By analyzing these labels, we gain insights into the perceptions of individuals concerning various issues. Notably, we conducted a comparative examination of two cities: Osaka and Yokohama, ordinance-designated cities in Japan.

Our findings reveal a significant contrast instances between the citizens and councilors of these two cities. Specifically, individuals from Osaka displayed a notably more positive stance toward the attraction of integrated resorts (IR) in comparison to their counterparts in Yokohama. This disparity in attitudes aligns with the ultimate decision taken by the Yokohama Mayor in 2021 to discontinue the IR attraction. It is essential to note that the timing of this decision postdates the timing of the stance analysis conducted in this research.

These results demonstrate the potential of our approach in extracting valuable insights from citizen and councilor comments, contributing to a better understanding of the prevailing sentiments and opinions surrounding political issues. By focusing on stance labels, we gain a nuanced understanding of the viewpoints held by different stakeholders, allowing us to identify patterns and differences among cities. The contrasting stances observed in Osaka and Yokohama regarding integrated resorts exemplify the effectiveness of our methodology.

## **6. Application (3): comparing social capital in each city**

#### **6.1 Goal**

The objective of this research is to provide a quantitative analysis of the intensity of human connections and elucidate the varying degrees of these connections across different cities. In doing so, we posit the potential for municipalities to gauge the strength of their local social ties, thereby enabling local governments to effectively address social isolation in areas with comparatively weaker ties.

This study further quantifies human connection strength during the unprecedented period of the 2020 and 2021 novel COVID-19 pandemic, when social relationships were notably strained. By scrutinizing variations in our calculated values over time, in conjunction with alterations in the prevalence of mood disorders, our investigation aims to unravel the underpinnings of the reported increase in conditions like depression, which have surged during the COVID-19 outbreak and have been inadequately explored in preceding studies.

To achieve these objectives, we leverage social capital [24] – a concept intrinsically linked to the quantification of human connection strength - as a metric, deriving our data from tweets on the social media platform, X. This study seeks to validate the efficacy of an affordable quantification method founded on tweet data, which has been under-explored in comparison to the more traditional, yet costly, quantification approach reliant on questionnaire surveys, widely utilized in conventional research. Note that this is ongoing work and reported in the domestic non-reviewed conference in Japan [25].

## **6.2 Indicator type for estimating social capital**

In our proposed methodology, we initially aggregate tweets from cities at both ends of the spectrum concerning the prevalence of mood disorders, as reported on X.

Subsequently, employing the construct of social capital, we derive two indicators from the assembled tweets, assigning attributes through annotation to formulate a comprehensive dataset. The proposed indicators are delineated as follows:


Our indicators are conceptualized based on the bifurcation of social capital as per Putnam [24], who differentiated it into two categories bridging and bonding, each embodying distinct characteristics of human connections.

We assembled tweets from four cities: Mito and Oita, characterized by the highest rates of mood disorder patient increase, and Aomori and Takasaki, marked by the lowest rates. Documents were curated such that each category comprised 500 tweets from the pre-pandemic period and 500 from the pandemic period, yielding a total of 1,000 tweets per category. Thus, the resultant dataset encapsulates approximately 8,000 sentences.

To procure tweets pertinent to each indicator, we gathered tweets spanning June 2018–September 2021, encapsulating both pre-pandemic and pandemic periods, guided by the subsequent search queries:

• Event and Activity Participation

The search query was "participation."

• Family Ties Intensity

Search queries encompassed "son," "daughter," "mother," "father," "brother," "younger brother," "family," "husband," "wife," "parents," and so on.

Tweets were collected from 12,927 Mito citizen accounts, 9,026 Oita citizen accounts, 9,784 Aomori citizen accounts, and 9,301 Takasaki citizen accounts. These were retrieved based on profile information from X (Twitter) using Twitter's Streaming API. The number of tweets collected amounted to 10,083,874 from Mito, 5,823,539 from Oita, 11,177,635 from Aomori, and 6,974,843 from Takasaki. Accordingly, for each city, we culled tweets containing the defined queries so that a sum of 2,000 tweets (1,000 for each indicator) were collected during the specified period. Reposts were omitted, and URLs contained within the tweets were excised. This dataset serves as the foundation for training a classification model for each attribute, individual city, and respective indicator.

In this methodology, we delineate attributes that are uniformly allocated to the degree of connectivity with relatives, in addition to labels denoted to the degree of event participation. Social capital is quantified for each indicator, drawing from tweets associated with the ensuing labels.

## *6.2.1 Attributes assigned to the level of event participation*


## *6.2.2 Attributes assigned to the degree of connection with relatives*


## **6.3 Methodology**

The model was trained to assign the label of the attributes to each tweet using the labeled annotation corpus with RoBERTa [26]. Then, the labels were assigned to the unlabeled tweets in each city using the model, allowing for the quantification of social capital based on the assigned labels to each tweet.

By assigning labels to a large number of unknown tweets using the proposed method in this study, we calculate correlation coefficients between the number of labeled tweets per month and the number of patients with mood disorders per city in the target cities. The period of analysis was from June 2018 to December 2021. The number of patients

*Citizen Sentiment Analysis DOI: http://dx.doi.org/10.5772/intechopen.113030*

with mood disorders per month is calculated using REZULT3 , a medical database provided by Japan System Techniques Corporation (JAST). This data set is based on the receipt data of more than 7 million patients held by JAST, and the number of patients is calculated by ICD-10 code, which is the International Statistical Classification of Diseases, and by region. In order to analyze the data by period, correlation coefficients were calculated for a six-month period, from June 2018 to December 2019 (before COVID-19) and from January 2020 to March 2022 (after COVID-19).

## **6.4 Correlation of number of labeled tweets and number of patients with mood disorders in cities**

During the early COVID-19 pandemic period from January to June 2020, we observed a negative correlation (0.157 to 0.656) between the number of patients with mood disorders and the count of tweets labeled "currently participating" and "online" in the attribute "forms of event participation." This supports the hypothesis that a higher participation of citizens in events is associated with a decrease in the number of mood disorder cases.

The strong negative correlation case in Aomori city case is depicted in **Figure 5**. Note that Aomori was characterized by the lowest rates of mood disorder patient increase. During this period, numerous tweets discussed online drinking parties and social gatherings, utilizing Zoom for virtual interactions.

The negative correlation coefficient between the number of patients with mood disorders and the count of tweets labeled as "positive" for offline connectedness from January to June 2020 was notably higher (0.525 to 0.629) in cities. This suggested that kinship ties might have reduced mood disorder patient numbers in early COVID-19 pandemic stages.

#### **Figure 5.**

*Negative correlation between # of tweets currently participating in online events and # of patients with mood disorders in Aomori city*.

<sup>3</sup> https://www.jastlab.jast.jp/rezult\_data/

## **7. Limitations**

Our approach exhibits several limitations. Notably, it struggles to analyze opinions that rarely surface on social media. For instance, although restroom locations in offline events constitute an important concern, few users discuss this topic on X. Additionally, due to limited X usage among older demographics, assessing elder-specific issues is challenging. Another complication is distinguishing the impact of non-opinion factors when analyzing real-world problem influences. An example would be assessing the effect of social media rumors on decreasing COVID-19 vaccination rates, considering that inadequate local government services also contribute to this decline. Understanding these limitations is crucial before deploying our proposed methodology for analysis.

## **8. Conclusions**

In this chapter, we presented our methodologies for citizen sentiment analysis using tweets in a specific city, with a focus on three main applications: (1) comparing citizen feedback in multiple cities; (2) comparing the stance of citizens with city councilors; and (3) estimating social capital to affect the number of patients with mood disorder. Our approach encompassed a wide range of political issues, enabling us to compare citizen responses and connections across various cities by collecting tweets specific to each location. To prove the generality of our framework, we introduced multiple opinion typologies according to the application goal. Moreover, to enhance the accuracy and efficiency of extracting citizen comments, we incorporated a multitask learning framework based on LLMs.

Looking ahead, we plan to construct a conversation agent in each city to adapt generative AI to each city, by creating specific instructions in each city. This application plays a role as a virtual citizen, and holds significant promise for facilitating targeted interventions to enhance community well-being. By bridging the gap between digital interactions and real-life connections, our research contributes to a more comprehensive understanding of citizen sentiments and lays the groundwork for more informed decision-making in public administration.

## **Acknowledgements**

This work was partially supported by the Japanese Society for the Promotion of Science Grant-in-Aid for Scientific Research (B) (#23H03686) and Grant-in-Aid for Challenging Exploratory Research (#22 K19822).

*Citizen Sentiment Analysis DOI: http://dx.doi.org/10.5772/intechopen.113030*

## **Author details**

Yohei Seki Institute of Library, Information, and Media Science, University of Tsukuba, Japan

\*Address all correspondence to: yohei@slis.tsukuba.ac.jp

© 2023 The Author(s). Licensee IntechOpen. This chapter is distributed under the terms of the Creative Commons Attribution License (http://creativecommons.org/licenses/by/3.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

## **References**

[1] Ishida T, Seki Y, Kashino W, Kando N. Extracting citizen feedback from social media by appraisal opinion type viewpoint. Journal of Natural Language Processing. 2022;**29**(2): 416-442. DOI: 10.5715/jnlp.29.416 [Accessed: 1 July 2023]

[2] Senoo K, Seki Y, Kashino W, Kando N. Visualization of the gap between the stances of citizens and City Councilors on political issues. In: Tseng Y-H, Katsurai M, Nguyen HN, editors. From Born-Physical to Born-Virtual: Augmenting Intelligence in Digital Libraries, Lecture Notes in Computer Science. Vol. 13636. Hanoi, Vietnam: Springer; 2022. pp. 73-89. DOI: 10.1007/ 978-3-031-21756-2\_6 [Accessed: 1 July 2023]

[3] Pang B, Lee L. Opinion Mining and Sentiment Analysis. Boston: Now Publishers Inc; 2008

[4] Wiebe JM, Wilson T, Bruce RF, Bell M, Martin M. Learning subjective language. Computational Linguistics. 2005;**30**(3):277-308. Available from: https://aclanthology.org/J04-3002.pdf [Accessed: 1 July 2023]

[5] Blitzer J, Dredze M, Pereira F. Biographies, bollywood, boom-boxes and blenders: domain adaptation for sentiment classification. In: Proceedings of the 45th Annual Meeting of the Association of Computational Linguistics (ACL), Prague, Czech Republic. 2007. pp. 440-447. Available from: https:// aclanthology.org/P07-1056/ [Accessed: 1 July 2023]

[6] Macdonald C, Ounis I. The TREC Blogs06 collection: creating and analysing a blog test collection. Technical report TR-2006-224. Department of Computing Science,

University of Glasgow: 2006. Available from: http://terrierteam.dcs.gla.ac.uk/ publications/macdonald06creating.pdf [Accessed: 1 July 2023]

[7] Martinez-Camara E, Martin-Valdivia MT, Urena-Lopez LA, Montejo-Raez AR. Sentiment analysis in twitter. Natural Language Engineering. 2014;**20**(1):1-28. DOI: 10.1017/S1351324912000332 [Accessed: 1 July 2023]

[8] Stylios G, Christodoulakis D, Besharat J, Vonitsanou M, Kotrotsos I, Koumpouri A, et al. Public opinion Mining for Governmental Decisions. Electronic Journal of e-Government. 2010;**8**(2):203-214

[9] Verma S. Sentiment analysis of public services for smart society: Literature review and future research directions. Government Information Quarterly. 2022;**39**(3):101708. DOI: 10.1016/j. giq.2022.101708 [Accessed: 1 July 2023]

[10] Alizadeh T, Sarkar S, Burgoyne S. Capturing citizen voice online: Enabling smart participatory local government. Cities. 2019;**95**:102400. DOI: 10.1016/j. cities.2019.102400 [Accessed: 1 July 2023]

[11] Hubert RB, Estevez E, Maguitman A, Janowski T. Analyzing and visualizing government-citizen interactions on twitter to support public policy-making, digital government. Research and Practice. 2020;**1**(2):15

[12] Alamoodi AH, Zaidan BB, Zaidan AA, Albahri OS, Mohammed KI, Malik RQ, et al. Expert Systems with Applications. 2021;**167**:114155

[13] Dini L, Bittar A. Emotion analysis on twitter: The hidden challenge, proceedings of the tenth international

*Citizen Sentiment Analysis DOI: http://dx.doi.org/10.5772/intechopen.113030*

conference on. Language Resources and Evaluation. 2016;**2016**:3953-3958

[14] Jabreel M, Moreno A. A deep learning-based approach for multi-label emotion classification in tweets. Applied Sciences. 2019;**9**(6):1123

[15] Mohammad SM, Bravo-Marquez F, Salame M, Kiritchenko S. Task 1: Affect in Tweets. In: Proceedings of The 12th International Workshop on Semantic Evaluation. New Orleans, LA, USA. 2018. pp. 1-17

[16] Dimitrov D, Baran E, Fafalios P, Yu R, Zhu X, Zloch M, et al. TweetsCOV19 – A knowledge base of semantically annotated tweets about the COVID19 pandemic. In: Proceedings of the 29th ACM International Conference on Information & Knowledge Management. (Online). 2020. pp. 2991-2998

[17] Lwin MO, Lu J, Sheldenkar A, Schulz PJ, Shin W, Gupta RK, et al. Global sentiments surrounding the COVID-19 pandemic on twitter: Analysis of twitter trends. JMIR Public Health and Surveillance. 2020;**6**(2):e19447

[18] Seki Y. Use of twitter for analysis of public sentiment for improvement of local government service. In: Proceeding of the 2nd IEEE Int'l Conf. On Smart Computing (SMARTCOMP 2016). St. Louis, MO, USA. 2016. pp. 325-327. DOI: 10.1109/SMARTCOMP. 2016.7501726 [Accessed: 1 July 2023]

[19] Martin JR, White PRR. The Language of Evaluation: Appraisal in English. London, UK: Palgrave Macmillan; 2005

[20] Caruana R. Multitask learning. Machine Learning. 1997;**28**(1):41-75. DOI: 10.1023/A:1007379606734 [Accessed: 1 July 2023]

[21] Devlin J, Chang MW, Lee K, Toutanova K. BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. In: Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies. Vol. 1 (Long and Short Papers). Minneapolis, MN, USA. 2019. pp. 4171-4189

[22] Ishida T, Seki Y, Keyaki A, Kashino W, Kando N. Evaluation of citizen opinion extraction across cities (in Japanese). Journal of Natural Language Processing. 2022;**30**(2): 586-631. DOI: 10.5715/jnlp.30.586 [Accessed: 1 July 2023]

[23] Raffel C, Shazeer N, Roberts A, Lee K, Narang S, Michael M, et al. Exploring the limits of transfer learning with a unified text-to-text transformer, the. Journal of Machine Learning Research. 2020;**21**(101):5485-5551

[24] Putnam RD, Leonardi R, Nanetti R. Making DemocracyWork: Civic Traditions in Modern Italy. Princeton, NJ, JSA: Princeton University Press; 1994. p. 280

[25] Yonemaru S, Seki Y, Keyaki A, Kashino W, Kando N. Development of a Regional Social Connectivity Index Leveraging Twitter Data (in Japanese). In: Forum on Data Engineering and Information Management (DEIM 2023), Gifu, Japan. 2023, Article No. 5b-5-3

[26] Liu Y, Ott M, Goyal N, Du J, Joshi M, Chen D, et al. Roberta: A robustly optimized bert pretraining approach. arXiv:1907.11692. 2019

## **Chapter 6**

## Perspective Chapter: Embracing the Complexity of Human Emotion

*Saeed Albarhami Thabit*

## **Abstract**

In this chapter, we delve into the multifaceted world of human emotions through the lens of advanced analysis techniques, aiming to unlock a deeper understanding of human behavior and decision-making processes in our digital landscape. We begin by illustrating the complexity of human emotions and the significance of accurate emotion detection across various applications, from marketing and customer relationship management to healthcare and social media monitoring. This context leads us to discuss state-of-the-art emotion detection methods, including transformer-based models, context-aware emotion detection, physiological signal recognition, and multimodal emotion analysis. Here, we adopt a systematic approach to emotion analysis, utilizing the transformer-based architecture fine-tuned on a tweets dataset. Our methodology achieves an accuracy of 82.53%, a precision of 82.79%, a recall of 82.53%, and an F1 score of 82.29% in predicting emotional categories. The chapter also scrutinizes challenges, limitations, and ethical considerations in this field, including ambiguity, subjectivity, and cross-cultural variations. Finally, we glance into the future of emotion analysis, focusing on integrating emotional intelligence into artificial intelligence systems and developing personalized techniques. We aim to spur further research and collaboration in this field, thus enriching our understanding of the dynamic role of human emotions in our interconnected world.

**Keywords:** emotion analysis, human emotions, emotional complexity, transformer-based models, multimodal emotion analysis, context-aware emotion detection, physiological signals, mental health monitoring, human behavior, decision-making processes, digital landscape, public opinion analysis, ethical considerations, cross-cultural variations, emotional intelligence, personalized emotion analysis, social media monitoring

## **1. Introduction**

In our increasingly interconnected world, understanding the complexities of human emotions has become essential. In the digital landscape, the quest to understand and analyze complex human emotions has become more relevant through the lens of the most recent advanced emotion analysis techniques, setting the stage for a profound grasp of human behavior, communication, and decision-making processes. This chapter dives into the mysterious world of human emotions, employing

advanced emotion analysis techniques as a powerful tool to unveil the underlying emotions that drive our actions and interactions.

We start by journeying into the labyrinth of human emotions, highlighting why understanding emotional complexity is crucial. The importance of accurate emotion analysis is discussed across various contexts, from marketing and customer relationship management, as emphasized in earlier research on the crucial role of polarity detection and emotion recognition in comprehending and forecasting customer service experiences [1, 2] to healthcare and social media monitoring, highlighted in past studies such as [2–6]. We then delve into cutting-edge techniques for complex emotion detection, including transformer-based models [7], multimodal emotion analysis [8, 9], context-aware emotion detection [10, 11]. We also discuss emotion recognition using physiological signals [4, 12–14] and address their potential to deepen our understanding of human emotions. The chapter also navigates emotion analysis's challenges, limitations, and ethical aspects, including issues like ambiguity, subjectivity, and cross-cultural variations in emotional expression, emphasizing a call to action for further research and collaboration to fully comprehend the multi-dimensional nature of human emotions in our digital era.

We conclude with a glimpse into the future of emotion analysis, accentuating the integration of emotional intelligence in AI systems, ethical considerations, and the emergence of personalized emotion analysis techniques tailored to individual preferences and cultural backgrounds. By offering a comprehensive view of recent advancements and challenges in emotion analysis, this chapter aims to inspire further research and collaboration, fostering a more profound understanding of the multidimensional nature of human emotions in our digital era.

## **2. Background**

The landscape of human emotions is a rich tapestry woven with a multitude of feelings, emotions, and sentiments, varying in depth, complexity, and expression. Emotions are multifaceted and rarely exist in isolation, with humans often experiencing a blend of emotions simultaneously. Human nature's nuanced complexity offers intriguing possibilities and poses significant challenges for emotion analysis. Emotions are fundamentally subjective and deeply personal, making their accurate assessment challenging. To illustrate, consider the feeling of joy. One person's expression of joy could be another's expression of satisfaction, depending on their emotional and cultural background. This inherent subjectivity necessitates an intricate understanding of individual emotions in emotion analysis.

Emotions are also dynamic and ephemeral, changing rapidly in response to stimuli. The emotion behind words can change dramatically depending on the context or even the tone in which they are expressed. For instance, a person tweeting "I love this!" might convey genuine enthusiasm when discussing their favorite book but sarcasm when discussing a disliked policy. This demonstrates the necessity for emotion analysis models that consider the context and changes in emotion over time. Therefore, static emotion analysis models can often fall short, necessitating more dynamic and context-aware models that can adapt to the fluidity of human emotions.

Cultural and societal factors can profoundly influence emotional expression and interpretation. The same emotion can be expressed differently across cultures, and what might be perceived as a positive emotion in one culture could be seen as negative in another. Consider the example of a movie viewer watching a sad scene. One person

#### *Perspective Chapter: Embracing the Complexity of Human Emotion DOI: http://dx.doi.org/10.5772/intechopen.112701*

might react with profound sadness, tears welling in their eyes, while another might feel a sense of nostalgic melancholy, yet another might be unmoved, deeming it overly sentimental. This variability in emotional reactions to the same stimulus underscores the personal nature of emotions, presenting a considerable challenge for emotion analysis. Consequently, understanding the cultural nuances of emotional expression and incorporating them into emotion analysis models is critical.

Furthermore, emotional complexity extends beyond verbal or textual expression. Non-verbal signals such as facial expressions and tone play an essential role in communicating emotions and are often more truthful than words. For example, when a person says "I am fine" with a neutral facial expression, their tone may reveal underlying sadness or frustration. This highlights the importance of multimodal emotion analysis, which integrates text, audio, and visual data to understand emotions comprehensively. Therefore, a comprehensive understanding of emotional complexity necessitates the incorporation of these non-verbal cues in emotion analysis.

The challenge of understanding emotional complexity underscores the significance of employing advanced emotion analysis techniques to navigate the complex emotional landscape, respect its intricacies, and accurately decode the underlying emotions. This challenging task of emotional understanding requires an amalgamation of linguistics, psychology, machine learning, and deep learning techniques. However, overcoming this challenge promises to revolutionize numerous fields, from marketing and customer relationship management to mental health monitoring and public opinion analysis.

Understanding emotional complexity is a vital prerequisite for the advancement of emotion analysis. By recognizing the multi-dimensional nature of human emotions and developing sophisticated techniques to capture these dimensions, we can better effectively and ethically harness the power of human emotions. This journey, as challenging as it is fascinating, provides immense opportunities for further research, collaboration, and innovation in emotion analysis.

As our understanding of emotional complexity deepens, numerous applications have started to benefit from this wealth of information. From personalized marketing to mental health support, emotion analysis allows us to tap into a human being's most intimate element – their emotions.

#### **2.1 Personalized marketing and advertising**

Personalized marketing and advertising have truly revolutionized traditional business practices, giving businesses a unique opportunity to engage with their audience more intimately. Emotion analysis, often conducted via advanced artificial intelligence technologies and emotion analysis tools, plays a pivotal role in this revolution, serving as the backbone for understanding and engaging with the complex emotional landscape of consumers. The heart of emotion analysis lies in the interpretation of the emotional states and reactions of customers. This process examines various customer feedback forms such as product reviews, social media commentary, or customer service interactions. By investigating these mediums, businesses can understand how their products or services are being emotionally received and perceived by the customers [2].

Emotion analysis can help reveal patterns of customer opinion that go unnoticed. For instance, it can bring to light a widespread emotion of disappointment in a product feature or unveil a sense of joy associated with a particular service experience. This information can be further segmented by demographic groups, providing valuable insights into the emotional responses of different market segments.

Once these emotions are understood, businesses can adjust their marketing and advertising strategies accordingly. If the analysis reveals a negative emotion towards a product, the company may modify the marketing message to address and mitigate this negativity. On the other hand, if customers demonstrate a positive emotional response to a particular product feature or service, the company might amplify these emotions in their advertising campaigns, harnessing the power of positive affirmation to enhance customer loyalty and encourage repeat business.

Furthermore, emotion analysis can also be used to create more personalized and emotionally resonant marketing campaigns [10, 15, 16]. By understanding the specific emotions associated with a brand or product, companies can tailor their messaging to evoke similar emotions, creating a more profound and authentic connection with their audience. For example, a car company that finds its customers associate feelings of freedom and adventure with their products might develop advertising campaigns that evoke these emotions, resonating on a deeper, more personal level with their audience.

Emotion analysis in personalized marketing and advertising thus holds immense potential for fostering customer loyalty and engagement. As businesses refine their understanding of their customers' emotional responses, they will be better equipped to respond to their needs, tailor their products, and shape their messaging to resonate more deeply with their target audience. As such, emotion analysis represents a powerful tool in the modern business arsenal that promises to continue shaping the landscape of personalized marketing and advertising in the years to come.

#### **2.2 Social media monitoring**

Social media is a goldmine for emotion analysis. Social media platforms have precipitated a paradigm shift in how businesses interact with consumers and understand and monitor public opinion [3, 17]. Such platforms serve as a rich repository of public opinion, and when mined intelligently, they can provide unprecedented insights into consumer attitudes, needs, and behaviors. In this context, sentiment and emotion analysis applied to social media monitoring can be invaluable. For instance, consider a company's launch of a new product or service. By analyzing the social media discourse surrounding this launch—which could range from tweets to posts and photos to videos, a company can gain an in-depth understanding of public view towards the product or service. Moreover, sophisticated emotion analysis algorithms can uncover the polarity of the emotion (positive, negative, or neutral) and the nuances of the emotional responses elicited, such as excitement, disappointment, anticipation, confusion, or admiration.

Consider a tech company unveiling a new smartphone model as a hypothetical example. Emotion analysis of social media reactions could reveal that while the phone's design elicits positive emotions and excitement, its price generates disappointment or frustration. This nuanced understanding can inform the company's subsequent marketing strategies, pricing decisions, and design improvements for future models. The power of emotion analysis in social media monitoring extends beyond product launches. It can be employed to assess public reaction to advertising campaigns, gauge consumer satisfaction with customer service, monitor brand reputation, track emotion towards competitors, and identify emerging market trends or consumer needs.

By harnessing the power of sentiment and emotion analysis in social media monitoring, businesses can turn the tide of public opinion in their favor, make informed strategic decisions, and maintain a competitive edge in an increasingly digital marketplace.

#### **2.3 Customer relationship management (CRM)**

Within the domain of Customer Relationship Management (CRM), understanding emotional complexity allows businesses to respond to customer interactions promptly and empathetically. CRM has become a vital strategy in today's business landscape, where the customer is at the center of all operations. Using sentiment and emotion analysis within CRM frameworks is steering in a new era of personalized and emotionally aligned customer service, driving customer satisfaction and loyalty [1, 2].

A key aspect of CRM is interaction management, encompassing all touchpoints between a business and its customers. Here, emotion analysis can offer critical insights into a customer's mind. For instance, an email from a disgruntled customer might express disappointment or feeling undervalued. An advanced CRM system with emotion analysis capabilities can decipher these complex emotions, providing a nuanced understanding of the customer's feeling. This understanding empowers customer service representatives to respond empathetically and effectively, thus enhancing the overall customer experience. For instance, suppose a customer sends an email complaint about a recently purchased product that did not meet their expectations. A typical response might address the complaint at face value, offering a refund or replacement. However, with sentiment and emotion analysis, the CRM system could reveal underlying disappointment due to high expectations from the brand or annoyance at the inconvenience caused. Thus, the customer service representative could tailor their response to acknowledge these emotions, apologize, and offer a goodwill gesture, such as a discount on the next purchase. This tailored response will likely transform a potentially negative customer experience into a positive one, fostering customer loyalty.

In a broader sense, emotion analysis in CRM can aid in proactive issue resolution, trend identification, and strategic decision-making. For example, consistently high levels of frustration or disappointment related to a specific product or service aspect could prompt a business to investigate and rectify the underlying issue, potentially preventing a multitude of similar complaints in the future. By integrating emotion analysis into CRM systems, businesses can respond to customers more effectively and preempt issues, improve their offerings, and ultimately enhance customer satisfaction and loyalty.

#### **2.4 Healthcare and mental health support**

In healthcare, understanding patients' emotions can enhance patient-provider communication and potentially improve care delivery [2–5]. Healthcare providers can use emotion analysis to assess patients' feelings about their treatment, helping to adapt it better to suit their emotional needs. A patient's complex emotions might include fear, confusion, or hope, which could significantly impact their treatment and recovery process. Each application shows how embracing emotional complexity provides a richer understanding of human feeling, fostering more authentic and effective connections and solutions. By continuing to improve and develop emotion analysis techniques, we open up a world of possibilities for greater emotional understanding in our increasingly digital era. Prior research [18] demonstrated that social media can effectively detect and diagnose major depressive disorder through behavioral cues, while [19] highlighted the feasibility and efficacy of conversational agents like Woebot in delivering self-help interventions for anxiety and depression, emphasizing their potential as engaging tools for proactive mental health care. This empathetic interaction brings mental health support to those who might otherwise not have access, providing comfort and understanding in a non-judgmental, AI-powered space.

## **3. Literature review**

In this literature review section, we explore the frontiers of emotion detection, examining the pioneering techniques that have emerged in this arena in the past few years. Advanced emotion analysis methodologies, analogous to precision instruments, can unravel the complex network of human emotions intricately, unveiling profound insights into our behavioral patterns, decision-making processes, and interpersonal dynamics. These sophisticated techniques not only cater to academic interest but are also designed in a manner that can captivate the curiosity of an everyday reader, owing to the universality of the emotional experience they decode.

#### **3.1 Transformer-based models**

The field of emotion analysis has undergone a profound transformation with the advent of transformer-based models such as BERT (Bidirectional Encoder Representations from Transformers) [20], GPT-3 (Generative Pretrained Transformer 3) [21], T5 (Text-to-Text Transfer Transformer) [22], and LLaMA (Large Language Model Meta AI) [23]. BERT employs bidirectional training of transformers, facilitating a nuanced understanding of word context by referencing the surrounding text. GPT-3, an autoregressive language model, utilizes machine learning techniques to generate human-like text. T5 innovatively reformulates every natural language processing task as a text-to-text problem, thereby training the model on diverse tasks. LLaMA, a collection of foundation language models, enables the adaptation of large pre-trained models to specific tasks, negating the necessity for extensive fine-tuning.

All these models, including their various adaptations, employ self-attention mechanisms [7]. This fundamental component of transformer architectures empowers models to assess the relevance of words in a sentence according to their contextual interrelation rather than their standalone significance. Consequently, this mechanism supports an understanding of the broader context of a sentence, including crucial linguistic elements such as negation.

Moreover, transformer-based models can also learn subtle emotional nuances crucial in complex emotion detection. Consider a statement such as, "It is a fine day." Here, the word "fine" may convey a cheerful or neutral emotion depending on the speaker's tone, context, and individual language usage habits. A model like BERT, pretrained on a large text corpus, might have encountered similar usage patterns and could more accurately predict the intended emotion.

#### **3.2 Context-aware emotion analysis**

Context plays an important role in understanding human emotions. The same statement can hold different emotional connotations in different scenarios. Consider a

#### *Perspective Chapter: Embracing the Complexity of Human Emotion DOI: http://dx.doi.org/10.5772/intechopen.112701*

tweet saying, "The final season was mind-blowing!" Without context, it is impossible to determine whether the emotion is positive (excitement about a television show season final) or negative (criticism of a political leader's final term). Context-aware emotion analysis approaches try to incorporate such context by considering additional information about the source, subject matter, or surrounding text or by using sophisticated models capable of learning contextual representations [10, 11].

Despite the advancement in LLMs (Large Language Models) that process vast amounts of text data using deep learning techniques to generate coherent and contextually relevant text resembling human language [24], such as transformer-based like "BERT, GPT-3, T5, LLaMA", and others [20–23] are designed to consider the context when processing text. The transformer architecture is built around selfattention [7], allowing the model to weigh the importance of each word in a sentence when trying to understand or generate a particular word. These models can take into account the broader context to a certain extent. Nevertheless, they only explicitly measure aspects like emotion or subjectivity if specifically trained to do so in tasks such as emotion analysis. However, their ability to account for context can benefit such tasks.

Context-aware emotion analysis is a more specialized task that explicitly seeks to understand the feeling in light of the broader context. So, in situations where understanding opinion is critical (like customer reviews and social media monitoring.), models specifically trained for context-aware emotion analysis could be more effective than a general-purpose transformer model. However, there is vastly active research in this area, and many of the latest transformer-based models are very good at tasks like emotion analysis, even in complex and nuanced situations. Nonetheless, they could be better, and there can still be instances where they might not fully capture the emotion, especially in cases where more profound domain knowledge or cultural understanding is required.

Consider the following hypothetical scenario: a sentence states," The company's latest yearly earnings report showed a decline in revenue but an increase in market share." Trying to find whether the sentence represents satisfaction and happiness or disappointment and fear can be difficult without context and domain knowledge, as it might be either positive(satisfaction) or negative(disappointment); for instance, considering the company in a highly competitive industry, "the company's latest yearly earnings report showed a decline in revenue but an increase in market share" might suggest that the company has successfully gained a larger market share than its competitors, indicating potential long-term growth and profitability, therefore, the overall message could be satisfaction and happiness. However, on the other hand, the company's latest yearly earnings report showed a decline in revenue might raise concerns about a negative trend in sales. Despite an increase in market share, the decline in revenue suggests challenges in attracting customers or generating sufficient sales, potentially impacting the company's overall financial health; therefore, the overall emotion could be disappointment and fear.

#### **3.3 Emotion recognition using physiological signals**

Recent advancements in wearable technology have opened up new avenues for emotion detection [9]. Wearable devices can capture physiological signals such as heart rate and skin temperature, galvanic skin response, and even brainwave patterns, which are demonstrably linked to emotional states. For example, a sudden spike in heart rate and skin temperature might indicate a state of excitement or stress. To

illustrate, heart rate variability (HRV), the variation in time between each heartbeat, is a robust indicator of an individual's emotional state [9, 25]. Numerous studies have substantiated the correlation between HRV and emotions; for instance, an elevated heart rate and reduced HRV often signify a heightened emotional state, such as excitement or tension. Similarly, skin temperature is another physiological signal that varies with emotional changes. Research reveals that skin temperature increases during periods of intense emotional arousal due to the activation of the sympathetic nervous system. A sudden spike in skin temperature indicates a state of excitement, fear, or anger.

Moreover, Galvanic Skin Response (GSR), which measures changes in the skin's conductance, is highly sensitive to emotional arousal [16, 26]. An emotional event triggers the sweat glands, increasing skin conductance—a phenomenon that wearables can accurately measure, aiding in emotion recognition. Electroencephalogram (EEG) signals have also been used in emotion recognition, although more challenging to acquire outside clinical or research settings [16, 26, 27]. Brainwave patterns have been associated with different emotional states, opening up the possibility of emotion detection from EEG data.

However, it is important to note that these methods are relatively more invasive than emotion analysis based on text or speech, and their usage must comply with strict privacy and consent regulations. While these techniques are more intrusive and require user consent, analyzing physiological signals for emotion recognition has considerable potential for applications spanning various fields. These include but are not limited to health monitoring—where it can aid in diagnosing and treating mood disorders, stress management—by providing real-time biofeedback to users, and even the domain of personalized recommendations—where consumer emotional response to products can guide tailored marketing strategies.

#### **3.4 Multimodal emotion analysis**

While text is a critical channel for expressing emotions, it is not the sole medium through which emotions can be communicated or understood. Emotions are multidimensional and can be transmitted through a multitude of channels. Visual cues (like images or videos) and auditory signals (like tone or voice pitch) also carry crucial emotional information [28]. Multimodal emotion analysis incorporates these multiple data streams to derive a more holistic understanding of emotion.

Text-based models, including the most recent advanced transformer-based have indisputably revolutionized the field of emotion analysis concerning textual data. But, these models fall short in their capability to predict emotion expressed through visual or auditory mediums. In light of limitations identified by previous researchers [27, 29], which highlight the challenges of relying solely on text-based emotion analysis, implementing multimodal emotion analysis becomes critical. Multimodal emotion analysis, as detailed in [8, 9, 15, 30], is a method that offers a more precise and comprehensive overview of emotion by integrating insights from various data types such as text, audio, and video. For instance, during the evaluation of customer service calls, a customer might verbalize their satisfaction, yet underlying tones of frustration or disappointment might be discernable through their tone or hesitation. Likewise, in the analysis of video reviews, visual expressions prove essential in accurately conveying emotions, further underscoring the indispensable role of a multimodal approach in emotion analysis. Performing multimodal emotion analysis is a complex task that involves various steps and

processes. The idea is to combine information from different modes (like text, audio, and video) to make predictions.

It is worth noting that aligning multimodal data can be a significant challenge, especially in scenarios where the data is collected independently or in an unstructured way. However, there are some strategies to ensure the correct association:


The aforementioned techniques are revolutionizing the way we understand and analyze human emotions. However, it is worth noting that each technique has strengths and weaknesses and may be more suited to particular applications than others. Furthermore, they all grapple with challenges such as ambiguity, subjectivity, and cultural variations in emotional expression, echoing the need for continuous research, refinement, and innovation in the field of emotion analysis.

Advanced emotion analysis techniques serve as our compass, guiding us towards a deeper and more nuanced understanding of our collective emotional landscape. Embracing emotional complexity is not an end goal but a continuous journey, like our understanding and exploration of human emotion.

## **4. Methodology**

This analysis adopts a systematic approach to investigate human emotions within cloud providers'services. The methodology encompasses data collection, cleaning, preprocessing, exploratory data analysis, data splitting, model Fine-tuning, testing, and evaluation utilizing the transformer-based architecture as illustrated in (**Figure 1**). The following subsections provide a comprehensive outline of each phase:

## **4.1 Data collection**

We rely on Twitter's Rest APIs as our primary data source to build a comprehensive and representative dataset, providing access to many tweets about cloud computing services. Twitter's large user base and concise tweet format make it an ideal platform for capturing and analyzing human emotions.

We have deliberately collected tweets as our primary data source to capture the nuanced and often ambiguous expression of human emotions. By avoiding pre-made datasets with predefined emotion labels, we aim to observe how our model performs in real-world scenarios where emotions are often conveyed in a complex and

**Figure 1.** *Research methodology.*

uncertain manner. This approach allows us to assess the model's ability to handle emotional expression's inherent variability and subtleties in social media contexts.

Our data collection strategy focuses on retrieving English language tweets utilizing specific hashtags such as "Azure, azurecloud, azure, AWS, awscloud, amazoncloud, GoogleCloud, GCPCloud, googlecloud". These hashtags are widely used in cloud computing discussions, ensuring the relevance of the collected data. We also exclude retweets to prioritize original content and capture authentic user emotion.

#### **4.2 Data cleaning and preprocessing**

The data cleaning and preprocessing phase in our research played a pivotal role in preparing our dataset of 9200 tweets for the subsequent stages of emotion analysis. We processed the raw tweets to remove extraneous elements such as URLs, user handles, hashtags, and certain punctuation marks. To minimize semantic discrepancies, we transformed the entire dataset into lowercase. Duplicate tweets were also identified and removed at this stage.

A crucial phase of our preprocessing involved identifying prospective emotion classes by applying the K-means clustering algorithm [31]. To ascertain the optimal number of clusters, we used the sum of squared errors across various cluster counts and capitalized on the elbow method, as shown in (**Figure 2**).

The count of clusters was further substantiated by visualizing the groups generated by the K-means algorithm and analyzing the inflection point on the plot of the Sum of Squared Errors (SSE) against the number of clusters, as depicted in (**Figure 3**). This visualization distinctly represented data points and cluster centers; each data point was color-coded according to its assigned group. Upon thoroughly assessing these visualizations, coupled with the outcomes of the elbow method, we determined that three represented the optimal number of clusters.

Through these comprehensive preprocessing steps and the utilization of unsupervised learning techniques, we gleaned valuable insights about potential emotion classes within our dataset, structured the raw data, and refined it into a form that optimizes the effectiveness and accuracy of our machine learning model. These actions formed the foundation for our subsequent manual labeling process and emotion prediction efforts. However, to get explicit emotion labels like 'anger' and 'joy,' we manually read through the tweets and assign emotions to the tweets dataset.

*Perspective Chapter: Embracing the Complexity of Human Emotion DOI: http://dx.doi.org/10.5772/intechopen.112701*

**Figure 2.** *Elbow analysis in K-means clustering.*

**Figure 3.** *Multiple K value in K-means clustering.*

The data classification involved a harmonious blend of unsupervised learning and manual labeling. This mixed-methods approach allowed us to delineate complex emotion categories within our dataset and build a foundation for our emotion prediction model.

## **4.3 Data exploration**

Exploratory Data Analysis plays a pivotal role in comprehending the dataset and discerning the inherent characteristics of tweets about cloud providers'services.


**Table 1.**

*Summary table.*

Various visualization techniques were employed to explore the data effectively and gain valuable insights.

The following **Table 1** presents statistics, such as the total number of tweets, average text length, and the number of unique words, offering a concise overview of the dataset.

The word frequency, illustrated in (**Figure 4**), played a significant role in pinpointing common terms, offering key insights into the dominant linguistic patterns captured in the tweets. This depiction highlights the words that appear most frequently and contributes to a comprehensive understanding of the linguistic traits embodied within the dataset.

In parallel, the word cloud visualization (**Figure 5**) was instrumental in visually representing and illuminating prominent themes within the tweets dataset. The word cloud effectively highlighted the most significant terms by employing varying font sizes to denote word frequency or importance.

The subsequent **Table 2** summarizes the association between each tweet and its emotion. This provided an illustrative snapshot of the tweets dataset. This compilation, thus, forms a solid foundation for subsequent stages of our research, where these categories will be employed for further emotion analysis.

**Figure 4.** *Terms frequency.*


#### **Table 2.**

*Tweets with corresponding emotions.*

The bar chart, as portrayed in (**Figure 6**), was utilized to represent the diverse range of emotions in our dataset. Not only does this chart depict the distribution of each emotion, but it also shows their proportional representation relative to the entire data set. This allows for a clear visual comparison, highlighting the predominance or rarity of specific emotions.

The histogram, as visualized in (**Figure 7**), was systematically employed to uncover the underlying patterns and potential anomalies associated with the length of the tweets.

#### **4.4 Data splitting**

The cleaned dataset was split into training, validation, and test sets through stratified sampling, ensuring each set contained a representative proportion of samples for

**Figure 6.** *Emotions distribution.*

**Figure 7.** *The distribution of tweet text lengths.*

each target emotion. This is an important consideration, especially for imbalanced datasets, ensuring that the balance of each emotion in the training, validation, and test sets mirrors that in the original dataset.

Following the data segregation, an analysis was conducted to understand the distribution of emotions across the different subsets. The distribution was visualized using a grouped bar chart (**Figure 8**), which exhibited the proportion of each emotion in the training, validation, and test datasets.

The following **Table 3** presents a summary of the emotion distribution in the tweets dataset. Each row represents a specific emotion, its corresponding encoding, and the count of tweets associated with that emotion. The dataset consists of 4982 tweets labeled as "neutral" (encoding: 2), 2628 tweets labeled as "joy" (encoding: 1), and 1590 tweets labeled as "distress" (encoding: 0). This information provides an overview of the distribution of emotions within the dataset and serves as a foundation for further analysis and modeling.

## *Perspective Chapter: Embracing the Complexity of Human Emotion DOI: http://dx.doi.org/10.5772/intechopen.112701*

## **Figure 8.**

*Emotions distribution.*


**Table 3.**

*Summary of emotion distribution in tweets.*

### **4.5 Feature engineering and selection**

In the feature engineering step within our methodology, the unprocessed tweet corpus was converted into a structured format compatible with the RoBERTa-based model. This process involved tokenization of the tweets into subwords, adjusting these sequences to a fixed length, and creating attention masks. Each component is critical in ensuring our model can accurately interpret the data.

The tokenization stage uses a pre-trained RoBERTa tokenizer to convert each tweet into a sequence of subword tokens. Each token is represented as a unique integer identifier. This approach mitigates the limitation of a fixed vocabulary and helps to preserve meaningful linguistic nuances that could otherwise be lost.

The below **Table 4** shows the properties of the token sequences and a statistical analysis of the lengths of these sequences post-tokenization. The summary statistics indicated that, from the corpus of 9200 tweets, the average token sequence length is approximately 24.48 tokens, with a standard deviation of 12.55. The shortest tokenized tweet consists of only three tokens, while the longest extends to 81 tokens. Notably, 50% of the tweets have a token length of 22 or fewer tokens, revealing a substantial skewness in the distribution towards shorter tweets.

Since transformer-based models require input data in uniform length, the sequences were padded or truncated to a pre-defined maximum length of 64 tokens. Padding is indispensable when the token length is less than the maximum defined


**Table 4.**

*Statistics of token lengths.*

length, filling the residual positions with a designated padding token. Conversely, for sequences exceeding the maximum size, truncation ensures the sequence is limited to the initial 64 tokens.

Upon achieving uniform token sequences, attention masks were generated for each tweet. An attention mask, essentially a binary tensor, indicates the positions containing actual content (denoted by 1 s) versus the padded positions (represented by 0 s). This plays a pivotal role in focusing the model's attention on the substantive content of each sequence, disregarding the irrelevant padded elements during selfattention computations.

To visually explain the distribution of content and padding across tweets, we created a heatmap as shown in (**Figure 9**) of the attention masks. In this heatmap, the x-axis signifies the token positions across a tweet, while the y-axis corresponds to individual tweets. Each cell's color intensity indicates whether the corresponding position is filled with content (darker shades) or padding (lighter shades). This visualization outlines the areas of real content in each tweet sequence, demonstrating the effectiveness of our feature engineering methodology.

**Figure 9.** *Attention masks.*

## **4.6 Model fine-tuning**

The RoBERTa transformer-based architecture [32] was selected for its effectiveness in natural language processing tasks. The model was fine-tuned using the preprocessed dataset, optimizing its ability to accurately predict emotions associated with the tweets dataset regarding the cloud provider's services.

The model was trained over four epochs, concluding at 400 global steps with a final training loss of 0.47, as depicted in the following **Table 5**. Training loss consistently decreased, but an increase in validation loss after the fourth epoch signaled overfitting. The training process was halted after the fourth epoch to safeguard the model's capacity for generalization on unfamiliar data. Subsequently, the model was explicitly fine-tuned over these optimal four epochs. The research presents results from this optimal point, avoiding overfitting bias.

### **4.7 Model validation and testing**

The model testing process involves testing the model using the test dataset. The model's predictions are obtained by performing inference on the test dataset, and these predictions are converted into class labels using a label mapping dictionary. The actual labels are also transformed into their corresponding emotion labels.

The following **Table 6** displays a subset of the predictions to summarize the model's performance. Each table row represents a tweet from the test dataset, with the "Tweet" column showing a truncated version of the tweet text. The "Token IDs" column represents a truncated version of the tokenized representation of the tweet.


*Trained on a MacBook Pro with M2 Max processor (12-Core CPU, 38-Core GPU), and 32GB of unified memory. TrainOutput (global step = 400, training loss = 0.4781294107437134,total flos: 1125220975502400.0, epoch: 4.0).*

#### **Table 5.** *Model training.*

**Tweet Token IDs Predicted Actual** struggling with managing your cloud-comp … [0, 23543, 6149, 1527, 19], … distress distress certified with certifications yet? visi … [0, 25782, 3786, 19, 21045], … neutral neutral ready to transform your business with bi … [0, 16402, 7, 7891, 110], … joy joy enterprise customers are on the move to … [0, 11798, 22627, 916, 32], … neutral neutral wow! congratulations miles!! theyre l … [0, 34798, 27785, 24285, 1788], … joy joy hansis willhite earn academic all-distri … [0, 298, 1253, 354, 40], … joy neutral

**Table 6.** *Tweet predictions.* The "Predicted" column displays the model's predicted emotion label for each tweet, while the "Actual" column indicates the ground truth emotion label for comparison.

The table serves as a means to compare the predicted and actual emotion labels for a subset of the test dataset, providing insights into the model's performance in accurately classifying emotions based on the input tweets. It offers valuable information regarding the model's ability to discern and predict emotions within the context.

#### **4.8 Model evaluation**

The performance of this model was evaluated using several widely accepted metrics, including accuracy, precision, recall, and the F1 score.

As depicted in the subsequent **Table 7**, the model achieved an accuracy of 82.53%. This indicates that, across all predictions, approximately 82.53% of the model's predictions matched the actual classes. This is a tangible result because our problem has more than two classes. Precision for our model stood at 82.79%. Precision measures how many of the model's positive predictions were correct. In other words, when our model predicted an emotion, it was correct about 82.79% of the time. The model's recall score was also 82.53%, matching the accuracy. Recall measures how well the model can find all the relevant cases within a dataset. The same recall and accuracy suggest a balanced distribution of class labels in the dataset, and the model is equally good at predicting all classes. The F1 score of the model, a harmonic mean of precision and recall, was 82.29%. The F1 score is a better metric when there are imbalanced classes, as it considers both false positives and false negatives.

The model showed varying performance in terms of per-class results as displayed in **Table 8**. The matrix illustrates the model's performance in predicting each class and the instances where it was incorrect. For the 'distress' class, the model accurately predicted 153 instances out of the actual distress samples. However, it incorrectly classified 3 instances as 'joy' and 83 instances as 'neutral.' In the case of the 'joy' class, the model demonstrated a relatively higher accuracy, correctly identifying 335 instances. Nevertheless, it misclassified 1 instance as 'distress' and 58 instances as 'neutral.' Regarding the 'neutral' class, the model achieved accurate predictions for 651 instances. However, it erroneously classified 21 instances as 'distress' and 75 instances as 'joy.'


## **Table 7.**

*Model evaluation metrics.*


**Table 8.** *Confusion matrix.*

## *Perspective Chapter: Embracing the Complexity of Human Emotion DOI: http://dx.doi.org/10.5772/intechopen.112701*

**Figure 10.** *Terms frequency bar chart.*

The confusion matrix provides a comprehensive overview of the model's performance across different classes, revealing both correct predictions and misclassifications. This analysis offers valuable insights into the model's ability to distinguish between various emotional categories.

The confusion matrix (**Figure 10**) provides us with a perspective on model performance. Although the model has shown a reasonably good overall performance, it could be improved further, particularly in its ability to correctly predict 'distress' and 'neutral,' as indicated by the number of instances misclassified into these categories.

## **4.9 Model deployment**

Model deployment refers to making a trained model available in a production environment, where it can provide predictions to new input data. In the context of our study, the deployment of the emotion analysis model involves wrapping the model into an Application Programming Interface (API), which can serve as a standardized interface for other software components to communicate with the model. Specifically, the API receives raw tweet data as input, preprocesses the data in the same way as during the model training phase, passes the preprocessed data to the model, and finally outputs the model's emotion predictions. The deployment of the model as an API offers several benefits. Firstly, it facilitates the integration of the model into existing systems or workflows, as these systems can interact with the model simply by making requests to the API. Secondly, it allows the model to be hosted on a server and concurrently provide predictions as a service to multiple users or systems.

### **4.10 Continuous improvement**

For the continuous improvement of our model, we can leverage real-time feedback from users or fine-tune the model on new data. Users who disagree with the emotion prediction could submit the correct emotion, which can be stored alongside the original tweet. This valuable data can then be used for further fine-tuning our model. Furthermore, we should constantly monitor the model's performance in production,

as the input data distribution may change over time, which could affect the model's performance. Regular retraining or fine-tuning of the model with recent data will be essential. Finally, ensuring that the API's performance and uptime are satisfactory is essential, as this can directly impact the user experience. Following these practices ensures that our model continuously improves and stays robust and valuable over time.

## **5. Challenges, limitations and ethical considerations**

While the journey of deciphering human emotions through emotion analysis has proven fruitful, it has also been fraught with challenges and limitations [27, 29], encased in layers of ethical considerations [33, 34]. This section examines these aspects, highlighting their inherent complexity and the ongoing need for meticulous attention and innovation in addressing them.

#### **5.1 Challenges**

The primary challenge is human emotions' inherent ambiguity and subjectivity. Human language is replete with nuances, context-specific implications, and idiomatic expressions, making it challenging to assign a particular emotion accurately. For instance, sarcasm, an expressive form of emotion, often implies the opposite of the literal emotion, posing a significant challenge to emotion analysis algorithms. Another substantial challenge is dealing with the ever-evolving nature of language, especially in informal platforms like social media, where new slang and emoticons frequently appear. This dynamic environment necessitates continual learning and adaptation, pushing the boundaries of emotion analysis techniques.

#### **5.2 Limitations**

Despite rapid advancements, emotion analysis techniques are inherently limited in their ability to comprehend the full spectrum of human emotions due to their reliance on predefined categories and labels. While these techniques excel at identifying basic emotions such as joy, sadness, anger, and fear, they often falter when faced with more nuanced emotions such as sarcasm, irony, or mixed emotions. Moreover, most emotion analysis methods are primarily text-based, limiting their applicability in scenarios where emotions are conveyed through other means like tone, facial expressions, or body language. Even multimodal emotion analysis, which incorporates visual and auditory information, faces limitations due to the complexity and diversity of nonverbal emotional cues.

#### **5.3 Ethical considerations**

Emotion analysis, especially when applied at scale on social media and other digital platforms, raises several ethical questions. The first is the matter of privacy and consent. While public posts can be considered fair game, is it ethical to analyze a person's emotional state without explicit consent? Additionally, how the results of emotion analysis are used also poses ethical concerns. For example, using emotion analysis to manipulate public opinion, target vulnerable individuals, or perpetrate

#### *Perspective Chapter: Embracing the Complexity of Human Emotion DOI: http://dx.doi.org/10.5772/intechopen.112701*

discrimination is ethically questionable. Furthermore, the risk of reinforcing biases presents another ethical dilemma. If an emotion analysis model is trained on biased data, it can perpetuate harmful stereotypes, leading to unfair outcomes. For instance, the model could falsely associate certain dialects or speech patterns with negative emotions, leading to discriminatory practices.

While emotion analysis offers powerful tools for understanding human emotions, it is not without its challenges, limitations, and ethical considerations. Ambiguity and subjectivity, evolving language norms, and the difficulty of capturing the full range of human emotions underscore the complexities involved. Ethical issues, including privacy, consent, and potential misuse of analysis results, further complicate matters. Therefore, continued research, careful methodological refinement, and thoughtful ethical guidelines are crucial to advancing emotion analysis in a manner that respects and upholds our shared human values.

## **6. Conclusion**

In summary, this chapter has navigated through the nuanced universe of human feelings, employing cutting-edge emotion analysis methodologies. It underscores the layered nature of emotions and the crucial role of precise emotion detection spanning diverse applications. Forefront approaches, such as transformer-based models, multimodal emotion analysis that amalgamates text, audio, and visual data, context-aware emotion analysis that considers situational variables, and emotion recognition using physiological signals, have been under the spotlight with their contributions towards a comprehensive understanding of human emotions.

Our implementation of the transformer-based model on a tweets dataset achieved an accuracy of 82.53%, a precision of 82.79%, a recall of 82.53%, and an F1 score of 82.29%. These results underscore the efficacy of such models in understanding and predicting emotional categories. Their practical applications span sectors like personalized marketing, social media analytics, healthcare services, and customer relationship management, demonstrating the potential of emotion analysis to delve into the emotional dimensions of human behavior, facilitating more genuine connections and effective outcomes.

The discourse also highlights potential roadblocks, constraints, and ethical quandaries, such as interpretation difficulties, subjective bias, cultural diversities, and privacy-related issues. Further research should address these challenges, explore ways to reduce bias, and improve accuracy across diverse cultural contexts.

As we gaze into the future, emotion analysis will move towards a more integrated approach by incorporating emotional intelligence with artificial intelligence systems and tailoring techniques to individual needs. By weaving in emotional subtleties and accounting for cultural contexts, emotion analysis can offer a holistic insight into human emotions in our globally linked society. These advancements will be critical in grasping the complexity of emotions, which is pivotal for the progress of emotion analysis and the ethical and practical application of human emotions' power.

The expedition to decode the labyrinth of emotions fosters vast possibilities for more research, collaboration, and innovation. By tackling challenges, honing methodologies, and adhering to ethical norms, emotion analysis can sustain its evolution, paying heed to the complexities of human emotions while preserving our collective human values.

## **Author details**

Saeed Albarhami Thabit RIT, Dubai, UAE

\*Address all correspondence to: sat5006@rit.edu

© 2023 The Author(s). Licensee IntechOpen. This chapter is distributed under the terms of the Creative Commons Attribution License (http://creativecommons.org/licenses/by/3.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

## **References**

[1] Cambria E, Schuller B, Xia Y, Havasi C. New avenues in opinion mining and sentiment analysis. IEEE Intelligent Systems. 2013;**28**:15-21. ISSN 15411672. DOI: 10.1109/MIS.2013.30

[2] Bollen J, Mao H, Zeng X. Twitter mood predicts the stock market. Journal of Computational Science. 2011:1-8. ISSN 18777503;**2**. DOI: 10.1016/j. jocs.2010.12.007

[3] Liu B. Sentiment analysis and opinion mining. In: Synthesis Lectures on Human Language Technologies. Vol. 5. California, USA: Morgan & Claypool Publishers; 2012. ISSN 19474040. DOI: 10.2200/S00416ED1V01Y20 1204HLT016

[4] Shu L, Xie J, Yang M, Li Z, Li Z, Liao D, et al. A review of emotion recognition using physiological signals. Sensors. 2018;**18**:1-33. ISSN 14248220.

[5] Lovejoy CA, Buch V, Maruthappu M. Technology and mental health: The role of artificial intelligence. European Psychiatry. 2019;**55**:1-3. ISSN 17783585.

[6] Greaves F, Ramirez-Cano D, Millett C, Darzi A, Donaldson L. Harnessing the cloud of patient experience: Using social media to detect poor quality healthcare. BMJ Quality and Safety. 2013;**22**:183-186. ISSN 20445415.

[7] Vaswani A, Shazeer N, Parmar N, Uszkoreit J, Jones L, Gomez AN, et al. Attention is all you need. Advances in Neural Information Processing Systems. 2017;**2017**:1-9

[8] Soleymani M, Lichtenauer J, Pun T, Pantic M. A multimodal database for affect recognition and implicit tagging. IEEE Transactions on Affective

Computing. 2012;**3**:42-55. ISSN 19493045. DOI: 10.1109/T-AFFC.2011.25

[9] Poria S, Chaturvedi I, Cambria E, Hussain A. Convolutional mkl based multimodal emotion recognition and sentiment analysis. Proceedings - IEEE International Conference on Data Mining, ICDM. 2017:439-448. DOI: 10.1109/ICDM.2016.178

[10] Hazarika D, Poria S, Zadeh A, Cambria E, Morency LP, Zimmermann R. Conversational memory network for emotion recognition in dyadic dialogue videos. Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies - Proceedings of the Conference. 2018;**1**:2122-2132. DOI: 10.18653/v1/n18-1193

[11] Zaheer M, Guruganesh G, Dubey A, Ainslie J, Alberti C, Ontanon S, et al. Big bird: Transformers for longer sequences. Advances in Neural Information Processing Systems. 2020;**2020**:93-110

[12] Yin Z, Zhao M, Wang Y, Yang J, Zhang J. Recognition of emotions using multimodal physiological signals and an ensemble deep learning model. Computer Methods and Programs in Biomedicine. 2017;**140**:93-110. ISSN 18727565. DOI: 10.1016/j.cmpb.2016.12.005

[13] Bota PJ, Wang C, Fred ALN, Da Silva HP. A review, current challenges, and future possibilities on emotion recognition using machine learning and physiological signals. IEEE Access. 2019; **7**:140990-141020. ISSN 21693536

[14] Chen J, Wang C, Wang K, Yin C, Zhao C, Tao X, et al. Heu emotion: A large-scale database for multimodal

emotion recognition in the wild. Neural Computing and Applications. 2021;**33**: 8669-8685. ISSN 14333058. DOI: 10.1007/s00521-020-05616-w

[15] Zadeh A, Chen M, Cambria E, Poria S, Morency LP. Tensor fusion network for multimodal sentiment analysis. In: Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing. Conference on Empirical Methods in Natural Language Processing. 2017;**2017**: 1103-1114. DOI: 10.18653/v1/d17-1115

[16] Subramanian R, Wache J, Abadi MK, Vieriu RL, Winkler S, Sebe N. Ascertain: Emotion and personality recognition using commercial sensors. IEEE Transactions on Affective Computing. 2018;**9**:147-160. ISSN 19493045. DOI: 10.1109/TAFFC.2016.2625250

[17] Karamitsos I, Albarhami S, Apostolopoulos C. Tweet sentiment analysis (tsa) for cloud providers using classification algorithms and latent semantic analysis. Journal of Data Analysis and Information Processing. 2019;**07**:276-294. ISSN 2327-7211. DOI: 10.4236/jdaip.2019.74016

[18] De Choudhury M, Gamon M, Counts S, Horvitz E. Predicting depression via social media. Proceedings of the 7th International Conference on Weblogs and Social Media. 2013;**7**:128- 137. DOI: 10.1609/icwsm.v7i1.14432

[19] Fitzpatrick KK, Darcy A, Vierhile M. Delivering cognitive behavior therapy to young adults with symptoms of depression and anxiety using a fully automated conversational agent (woebot): A randomized controlled trial. JMIR Mental Health. 2017;**4**:1-9. ISSN 23687959. DOI: 10.2196/mental.7785

[20] Devlin J, Chang MW, Lee K, Toutanova K. Bert: Pre-training of deep bidirectional transformers for language understanding. Annual Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (NAACL-HLT 2019). 2019;**1**:4171-4186

[21] Brown TB, Mann B, Ryder N, Subbiah M, Kaplan J, Dhariwal P, et al. Language models are few-shot learners. Advances in Neural Information Processing Systems. 2020;**2020**:1-19

[22] Raffel C, Shazeer N, Roberts A, Lee K, Narang S, Matena M, et al. Exploring the limits of transfer learning with a unified text-to-text transformer. Journal of Machine Learning Research. 2020;**21**:1-46. ISSN 15337928

[23] Touvron H, Lavril T, Izacard G, Martinet X, Lachaux MA, Lacroix T et al. Llama: Open and efficient foundation language models. arXiv. 2023:1-12. eprint - 2302.13971

[24] Radford A, Narasimhan K, Salimans T, Sutskever I, et al. Improving language understanding by generative pre-training. OpenAI. 2018:1-8

[25] Appelhans BM Luecken LJ. Heart rate variability as an index of regulated emotional responding. Review of General Psychology. 2006;**10**:229-240. ISSN 10892680

[26] Kwon YH, Shin SB, Kim SD. Electroencephalography based fusion two-dimensional (2d)-convolution neural networks (CNN) model for emotion recognition system. Sensors (Switzerland). 2018;**18**:1-12. ISSN 14248220. DOI: 10.3390/s18051383

[27] Zhang J, Yin Z, Chen P, Nichele S. Emotion recognition using multi-modal data and machine learning techniques: A *Perspective Chapter: Embracing the Complexity of Human Emotion DOI: http://dx.doi.org/10.5772/intechopen.112701*

tutorial and review. Information Fusion. 2020;**59**:103-126. ISSN 15662535. DOI: 10.1016/j.inffus.2020.01.011

[28] Hubert Tsai YH, Bai S, Paul Pu Liang J, Kolter Z, Morency LP, Salakhutdinov R. Multimodal transformer for unaligned multimodal language sequences. In: Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics. Association for Computational Linguistics. 2020:6558- 6569. DOI: 10.18653/v1/p19-1656

[29] Poria S, Hazarika D, Majumder N, Mihalcea R. Beneath the tip of the iceberg: Current challenges and new directions in sentiment analysis research. IEEE Transactions on Affective Computing. 2023;**14**:108-132. ISSN 19493045. DOI: 10.1109/TAFFC. 2020.3038167

[30] Zadeh A, Liang PP, Vanbriesen J, Poria S, Tong E, Cambria E, et al. Multimodal Language Analysis in the Wild: Cmu-Mosei Dataset and Interpretable Dynamic Fusion Graph. Vol. 1. Copenhagen, Denmark: Association for Computational Linguistics (ACL); 2018. ISBN 9781948087322. pp. 2236-2246. DOI: 10.18653/v1/p18-1208

[31] MacQueen J et al. Some methods for classification and analysis of multivariate observations. In: *Proceedings of the Fifth Berkeley Symposium on Mathematical Statistics and Probability*. Vol. 1. Oakland, CA, USA: University of California Press; 1967. pp. 281-297

[32] Liu Y, Ott M, Goyal N, Du J, Joshi M, Chen D et al. Roberta: A robustly optimized bert pretraining approach. Preprint Identifier: arXiv: 1907.11692. 2019:1-13

[33] Brent Daniel Mittelstadt and Luciano Floridi. The ethics of big data: Current and foreseeable issues in biomedical contexts. Science and Engineering Ethics. 2016;**22**:303-341. ISSN 14715546

[34] Datta A, Sen S, Zick Y. Algorithmic transparency via quantitative input influence: Theory and experiments with learning systems. Proceedings - 2016 IEEE Symposium on Security and Privacy. 2016;**2016**:598-617. DOI: 10.1109/SP.2016.42

## *Edited by Jinfeng Li*

This cutting-edge book brings together experts in the field to provide a multidimensional perspective on sentiment analysis, covering both foundational and advanced methodologies. Readers will gain insights into the latest natural language processing and machine learning techniques that power sentiment analysis, enabling the extraction of nuanced emotions from text.

### Key Features:

	- Ethical and Privacy Considerations: Delve into the ethical challenges and privacy concerns inherent to sentiment analysis, with discussions on responsible AI usage.
	- Future Directions: Get a glimpse into the future of sentiment analysis, with discussions on emerging trends and unresolved challenges.

This book is an essential resource for researchers, practitioners, and students in fields like natural language processing, machine learning, and data science. Whether you're interested in understanding customer sentiment, monitoring social media trends, or advancing the state of the art, this book will equip you with the knowledge and tools you need to navigate the complex landscape of sentiment analysis.

## *Andries Engelbrecht, Artificial Intelligence Series Editor*

Published in London, UK © 2024 IntechOpen © your\_photo / iStock

Advances in Sentiment Analysis - Techniques, Applications, and Challenges

IntechOpen Series

Artificial Intelligence, Volume 22

Advances in

Sentiment Analysis

Techniques, Applications, and Challenges

*Edited by Jinfeng Li*