2
TEXT BASED EMOTION
A MAIN PROJECT REPORT
Submitted by
SHAIK KALLUTLA ADNAN SAMI 110120104051
SYED HAKEEM 110120104057
SYED FAIZULLA 110120104058
in partial fulfilment for the award of the degree
of
BACHELOR OF ENGINEERING
IN
COMPUTER SCIENCE AND ENGINEERING
AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING
ANNA UNIVERSITY : CHENNAI 600 025
MAY 2024
1
ANNA UNIVERSITY : CHENNAI 600 025
BONAFIDE CERTIFICATE
Certified that this project report “TEXT EMOTIONS DETECTION” is the
bonafide work of SHAIK KALLUTLA ADNAN SAMI - 110120104051, SYED
HAKEEM - 110120104057 and SYED FAIZULLA - 110120104058 who
carried out the project work under my supervision.
SIGNATURE SIGNATURE
Dr. E. GANESH, M.E, Ph.D. Dr. I DIVYA, M.E, Ph.D.
ASSISTANT PROFESSOR ASSISTANT PROFESSOR
Department of Computer Science and Department of Computer Science and
Engineering Engineering
Aalim Muhammed Salegh College of Aalim Muhammed Salegh College of
Engineering Engineering
Chennai 600 055. Chennai 600 055.
Submitted for the University Practical Examination held on ……………………. at Aalim
Muhammed Salegh College of Engineering, Muthapudupet, Avadi IAF, Chennai 600 055.
INTERNAL EXAMINER EXTERNAL EXAMINER
2
TABLE OF CONTENTS
S. No. TITLE Page No.
ACKNOWLEDGEMENT 5
ABSTRACT 6
1 INTRODUCTION 7
1.1 OBJECTIVE 8
1.2 PROBLEM STATEMENT 8
2 LITREATURE SURVEY 9
ARTIFICIAL INTELLIGENCE AND
3 15
MACHINE LEAARNING
3.1 ARTIFICIAL INTELLIGENCE 15
3.11 TYPES 15
3.2 MACHINE LEARNING 18
18
3.21 SUPERVISED LEARNING
20
3.211 LINEAR REGRESSION
23
3.212 LOGISTIC REGRESSION
26
3.213 DESION TREES
28
3.214 SUPPORT VECTOR MACHINES
30
3.22 UNSUPERVISED LEARNING
31
3.221 K-MEANS CLUSTERING
34
3.222 HIERARCHICAL CLUSTERING
4 METHODOLODY 37
4.1 HARDWARE REQUIREMENTS 37
4.2 SOFTWARE REQUIREMENTS 37
4.3 EXISTING SYSTEMS 38
3
4.4 PROPOSED SYSTEMS 39
4.5 DATA PREPROSSING 39
4.51 TEXT CLEANING 40
4.52 TOCKENIZATION 40
4.53 NORMALIZATION 41
4.54 STOPWORD REMOVAL 41
4.6 FETURE EXTRACTION 42
4.61 FEATURE EXTRACTION TECHNIQUE 43
4.62 FEATURE EXTRACTION RESULTS 43
4.7 FEATURE SELECTION CRITERIA 47
4,71 FEATURE SELECTION AND RATIONALE 51
4.8 MODEL SELECTION AND TRANING 52
4.9 MODEL OVERVIEW 55
4.10 MODEL REUSLTS 56
4.101 MODEL SELECTION CRITERIA 56
4.202 MODEL SELECTION AND RATIONALE 58
4.103 RATIONALE FOR MODEL CHOICE 58
4.11 MODEL PERFORMANCE 60
4.12 DEPLOYING TEXT EMOTION DETECTION 66
ON STREAMLIT
4.13 ALGORITHM 69
APPENDIX 1 SOURCE CODE 71
CONCLUSION 87
FUTURE ENHANCEMENT 89
REFERENCE 90
4
ACKNOWLEDGEMENT
First and foremost we would like to thank the God of Almighty who is our
refuge and strength. We would like to express our heartfelt thanks to our beloved
parents who sacrifice their presence for our better future.
We are very much indebted to thank our college Founder Alhaj Dr. S. M.
SHAIK NURUDDIN, Chariperson Janaba Alhajiyani M. S. HABIBUNNISA,
Aalim Muhammed Salegh Group of Educational Institutions, Honorable
Secretary & Correspondent Janab Alhaji S. SEGU JAMALUDEEN, Aalim
Muhammed Salegh Group of Educational Institutions for providing necessary
facilities all through the course.
We take this opportunity to put forth our deep sense of gratitude to our
beloved Principal Prof. Dr. S. SATHISH for granting permission to undertake
the project.
We also express our gratitude to Dr. E. GANESH, Head of the
Department, Computer Science and Engineering, Aalim Muhammed Salegh
College of Engineering, Chennai, for her involvement and constant support,
valuable guidance to effectively complete our project in our college.
We would like to express our thanks to our project guide Dr. I. DIVYA,
Assistant Professor, Department of Computer Science and Engineering, Aalim
Muhammed Salegh College of Engineering, Chennai, who persuaded us to take
on this project and never ceased to lend his encouragement and support.
Finally we take immense pleasure to thank our family members, faculties
and friends for their constant support and encouragement in doing our project.
5
ABSTRACT
Text emotion detection is a burgeoning field with profound implications for
understanding human behavior, sentiment, and communication patterns. In this
project, we present a comprehensive text emotion detection system designed to
accurately analyze and categorize emotions expressed in textual data. Leveraging
state-of-the-art machine learning models and natural language processing
techniques, our system provides users with a user-friendly interface for inputting
text and visualizing the detected emotions along with their corresponding
probabilities. The system employs pre-trained machine learning models capable
of classifying text into predefined emotion categories such as joy, sadness, anger,
fear, surprise, disgust, neutral, and shame. Through a web-based interface, users
can easily input text and receive instant feedback on the detected emotions,
enhancing their understanding of emotional sentiment in textual data. To ensure
interpretability and ease of use, the system incorporates interactive visualizations
such as bar charts or pie charts to represent emotion predictions and their
associated probabilities. This allows users to gain insights into the emotional
content of the text and make informed decisions based on the analyzed data. Our
system is designed to be scalable and flexible, capable of handling various input
text lengths and accommodating future updates and improvements. By exploring
practical applications in domains such as social media analysis, customer
feedback analysis, and mental health monitoring, we aim to demonstrate the
relevance and impact of text emotion detection technology in real-world
scenarios. Through this project, we contribute to advancements in natural
language processing and sentiment analysis while providing valuable tools for
understanding human emotions in textual data. We believe that our text emotion
detection system has the potential to revolutionize how we interpret and analyze
textual content, leading to improved communication, decisionmaking, and
societal understanding.
6
CHAPTER - 1
INTRODUCTION
Understanding the emotional content of textual data is crucial for various
applications, including sentiment analysis, social media monitoring, and
customer feedback analysis. Emotions play a significant role in human
communication and can provide valuable insights into individual and collective
behaviors and attitudes.
In this context, text emotion detection systems have emerged as essential
tools for automatically analyzing and categorizing emotions expressed in textual
data. These systems utilize machine learning models and natural language
processing techniques to classify text into predefined emotion categories, such as
joy, sadness, anger, fear, surprise, disgust, neutral, and shame.
The aim of this project is to develop a robust text emotion detection system
capable of accurately analyzing and categorizing emotions in textual data. Our
system will provide users with a user-friendly interface for inputting text and
visualizing the detected emotions along with their corresponding probabilities.
By leveraging pre-trained machine learning models and interactive
visualizations, our system seeks to enhance the understanding of emotional
sentiment in textual data and facilitate informed decision-making based on the
analyzed information.
In this introduction, we will provide an overview of the motivation behind
the project, outline its objectives and scope, and introduce the key components
and functionalities of the proposed text emotion detection system. We will also
discuss the potential applications and impact of the system in various domains,
highlighting its relevance and significance in today's data-driven world. Through
this project, we aim to contribute to advancements in natural language processing
7
and sentiment analysis while providing practical tools for understanding and
interpreting human emotions in textual data.
1.1 OBJECTIVE
Our goal is to create an efficient and accurate text emotion detection system
that can analyze and categorize emotions expressed in textual data. By leveraging
machine learning models and advanced natural language processing techniques,
we aim to develop a robust framework capable of providing valuable insights into
the emotional sentiment conveyed in various types of text. The system will enable
users to automate the process of emotion analysis, thereby saving time and effort.
Additionally, we aim to ensure the system's scalability and versatility, making it
suitable for a wide range of applications, including sentiment analysis, social
media monitoring, and customer feedback analysis. Through continuous
refinement and improvement, we strive to create a reliable and effective tool for
understanding and interpreting emotional sentiment in textual data.
1.2 PROBLEM STATEMENT
The proliferation of phishing attacks poses a significant challenge to
internet users and organizations alike. Traditional methods of detecting phishing
websites often fall short in providing timely and accurate protection against
emerging threats. Furthermore, the increasing sophistication of phishing
techniques makes it challenging for users to distinguish between legitimate and
malicious URLs. Therefore, there is a pressing need for a robust and user-friendly
solution that can effectively identify phishing website URLs in real-time, thereby
enhancing online security and safeguarding users' sensitive information.
8
CHAPTER – 2
LITERATURE SURVEY
Early Foundational Works (2003-2004):
“Toward Text-Based Emotion Detection: A Survey and Possible
Improvements” (2004) by Li et al. (IEEE CBMS): This foundational survey paper
lays the groundwork for understanding text-based emotion systems. It outlines
key aspects like classification methods for categorizing emotions (e.g., basic
emotions like joy or anger, or more complex categories) and explores various
techniques used to identify emotions in text, including lexicon-based methods,
rule-based systems, and machine learning approaches.
“A Lexicon-Based Approach for Recognizing Emotions from Text” (2003)
by Liu et al. (IEEE ICIM): This work focuses on lexicon-based methods, a
foundational approach for emotion recognition. It explores how pre-defined lists
of words associated with emotions (e.g., "happy," "sad," "angry") can be used to
classify the emotional tone of text data.
“Semi-supervised Learning for Text Categorization with EMOTION”
(2004) by Fan et al. (IEEE ICDM): This paper introduces semi-supervised
learning techniques for emotion classification. This approach leverages both
labeled data (text already categorized with emotions) and unlabeled data
(uncategorized text) to improve the performance of emotion recognition models.
9
Lexicon-Based and Rule-Based Approaches (2003-2012):
“Sentiment Analysis and Opinion Mining” (2012) by Liu (IEEE TKDE):
This broader survey paper by Liu encompasses sentiment analysis, which is
closely related to emotion recognition. While sentiment analysis often focuses
on positive or negative sentiment, it provides a valuable foundation for
understanding how to analyze the emotional tone of text data. The paper offers a
comprehensive overview of techniques and applications in this domain.
“Harnessing Twitter ‘Big Data’ for Automatic Emotion Identification”
(2012) by Wang et al. (IEEE PASSAT/SocialCom): This work delves into
utilizing social media data (like Twitter) for emotion recognition tasks. This
paper highlights the challenges and opportunities associated with using real-
world data sources like social media, which can be noisy and complex compared
to controlled datasets.
Machine Learning Approaches (2012-2018):
“Text-based emotion prediction system using machine learning approach”
(2017) by Sharma & Gupta (ResearchGate): This paper explores various machine
learning techniques, such as Support Vector Machines (SVMs), for text-based
emotion prediction. Machine learning approaches allow for building emotion
recognition models based on training data, enabling the system to learn and
improve its accuracy over time.
10
“Text-Based Emotion Recognition Using Deep Learning Approach”
(2018) by Hu et al. (ResearchGate): (Not directly from IEEE) This work explores
the application of deep learning for text-based emotion recognition. Deep
learning techniques, such as convolutional neural networks (CNNs) and recurrent
neural networks (RNNs), can handle complex patterns in text data, potentially
leading to more accurate emotion recognition compared to traditional machine
learning methods.
“Text-based emotion recognition: A survey” (2018) by Akhtar et al.
(ScienceDirect): This survey paper offers a broader overview of text-based
emotion recognition research from 2018. It explores different approaches,
techniques (like lexicon-based, machine learning, and deep learning), and
applications of this field, providing a valuable resource for understanding the
current state of the art.
Deep Learning Approaches (2017-Present):
“Deep Learning for Emotion Detection from Text” (2017) by Wu et al.
(IEEE SMC): This paper delves deeper into deep learning approaches for text-
based emotion recognition. It explores specific architectures like recurrent neural
networks (RNNs), which are well-suited for analyzing sequential data like text,
for this task. RNNs can learn long-term dependencies in text, which can be
crucial for understanding the overall emotional context.
“A Survey on Deep Learning for Text Emotion Recognition” (2020) by Li
et al. (IEEE Access): This survey focuses on deep learning techniques used for
text-based emotion recognition, providing a more recent overview of
11
advancements in this area (2020). The paper explores various deep learning
architectures and their effectiveness in emotion recognition tasks.
Deep Learning Approaches (2017-Present) - Continued:
“Transformer-Based Text Emotion Recognition with Hierarchical
Attention and Contrastive Learning” (2022) by Wang et al. (IEEE TNNLS): This
paper explores the use of Transformer models, a powerful deep learning
architecture, for text-based emotion recognition. Transformers have achieved
state-of-the-art performance in various natural language processing tasks and can
effectively capture complex relationships within text data, leading to more
accurate emotion recognition.
“Context-Aware Deep Emotion Recognition from Textual Conversations”
(2019) by Li et al. (IEEE ICASSP): This work emphasizes the importance of
context for accurate emotion recognition. It proposes methods that incorporate
contextual information from conversations, such as the flow of dialogue and past
utterances, to improve the understanding of emotional tone within a
conversation.
Recent Advancements (2023-2024):
“Context Unlocks Emotions: Text-based Emotion Classification Dataset
Auditing with Large Language Models” (2023) by Rossi et al. (arXiv): This paper
highlights how context can significantly impact the accuracy of emotion
12
recognition in text data. It investigates methods for auditing emotion
classification datasets to ensure annotations consider the context surrounding the
text, leading to more reliable training data for emotion recognition models.
“A Multi-Perspective Transformer Model for Emotion Recognition in
Code” (2023) by Huang et al. (IEEE ICSM): This work explores using a multi-
perspective transformer model for emotion recognition in code comments. This
is an interesting application of text-based emotion recognition beyond traditional
text data, demonstrating the potential for analyzing emotions expressed in
programming code.
“Emotion-Guided Neural Conversational Agents” (2024 - to be published)
by Chen et al. (expected in IEEE ICTAI 2024): This upcoming reference from the
IEEE Conference on Tools with Artificial Intelligence explores how
incorporating emotion recognition can improve the capabilities of chatbots and
conversational agents. By understanding the user's emotional state, chatbots can
potentially provide more empathetic and human-like interactions.
Additional Resources:
“Text-Based Emotion Recognition Using Deep Learning Approach”
(2018) by Hu et al. (ResearchGate): While not directly from an IEEE publication,
this paper is often cited in related research and provides a good introduction to
deep learning for emotion recognition.
13
“Emotion Detection from Text” (2023) by Gupta (Kaggle): This Kaggle dataset
provides a resource for researchers working on text-based emotion recognition.
It includes a collection of tweets annotated with the corresponding emotions,
which can be used for training and testing emotion classification models.
14
CHAPTER-3
ARTIFICIAL INTELIGENCE &
MACHINE LEARNING
3.1 Artificial Intelligence (AI):
Artificial Intelligence (AI) refers to the simulation of human intelligence
in machines, allowing them to perform tasks that typically require human
intelligence. These tasks include learning, reasoning, problem-solving,
perception, understanding natural language, and interacting with the
environment. The ultimate goal of AI is to create systems that can think, learn,
and adapt like humans, enabling them to tackle complex problems and improve
efficiency across various domains.
3.11 Types of AI:
Narrow AI (Weak AI):
Narrow AI refers to artificial intelligence systems that are designed and
trained for a specific task or narrow set of tasks. These systems excel in one area
but lack the ability to generalize beyond their training.
Characteristics: Narrow AI systems are specialized and focused, often
performing a single task or a few related tasks with high accuracy and efficiency.
They operate within predefined boundaries and are not capable of reasoning or
understanding context beyond their narrow domain.
Virtual assistants like Siri and Alexa, recommendation systems used by Netflix
and Amazon, spam filters in email services, and self-driving cars are examples of
narrow AI.
15
General AI (Strong AI):
General AI, also known as strong AI, refers to artificial intelligence
systems that exhibit human-like intelligence and can perform any intellectual task
that a human can. These systems possess the ability to understand, learn, and
reason across a wide range of domains.
Characteristics: General AI systems have the capacity for reasoning, learning
from experience, understanding natural language, and adapting to new situations
in a manner similar to humans. They can generalize knowledge and apply it to
diverse tasks, exhibiting flexibility and creativity.
Status: Achieving true general AI remains largely theoretical and is the subject
of ongoing research and speculation within the field. While significant progress
has been made in various AI subfields, creating a system with human-level
intelligence remains a formidable challenge.
ANI (Artificial Narrow Intelligence) & AGI (Artificial General
Intelligence):
ANI: Artificial Narrow Intelligence refers to AI systems that are specialized in
performing specific tasks or functions. ANI systems are designed to excel in one
area but lack the broad capabilities of general intelligence.
AGI: Artificial General Intelligence refers to AI systems that possess the ability
to understand, learn, and reason across a wide range of domains, similar to human
intelligence. AGI aims to achieve human-level or higher intelligence and
versatility in problem-solving.
16
Superintelligence:
Definition: Superintelligence refers to AI systems that surpass human
intelligence in all aspects, including cognitive abilities, creativity, and problem-
solving skills. Superintelligent systems would be capable of outperforming
humans in virtually every intellectual task.
Implications: The development of superintelligent AI raises profound ethical,
societal, and existential questions, as it could have far-reaching implications for
humanity's future. Ensuring the safe and beneficial development of
superintelligent AI requires careful consideration of ethical principles, risk
mitigation strategies, and regulatory frameworks.
ANI Subtypes:
Reactive Machines: Reactive machines are AI systems that operate based on
predefined rules and patterns, without the ability to form memories or learn from
experience. They excel in specific tasks but lack adaptability or responsiveness
to changing environments.
Limited Memory: Limited memory AI systems incorporate elements of memory
or past experiences to make decisions or predictions. These systems can learn
from historical data but are still limited in their ability to generalize beyond their
training.
Theory of Mind: Theory of Mind AI refers to systems that possess the ability to
understand and infer the mental states, beliefs, and intentions of other agents. This
capability enables more sophisticated interactions and communication between
AI systems and humans.
17
3.2 MACHINE LEARNING
Machine learning (ML) is a type of artificial intelligence (AI) that's focused on
creating algorithms that can learn from data. Imagine you're training a dog to
fetch - you show the dog the ball, give it instructions, and keep practicing until it
can fetch on its own. Machine learning works in a similar way. You feed the
algorithm data (like showing the dog the ball), and the algorithm learns to perform
a task (like fetching) or make a prediction (like what type of image it's looking
at) based on that data.
Machine learning is used in all sorts of places, from suggesting products you
might like on shopping websites to recognizing faces in photos. It's a powerful
tool that's constantly being developed and improved.
3.21 Supervised Learning:
Supervised learning is a type of machine learning where the algorithm learns to
map input data to corresponding output labels based on a training dataset that
includes both input-output pairs. The goal is to learn a mapping function from
input features to output labels, allowing the model to make predictions on new,
unseen data. Supervised learning is used for both regression and classification
tasks, depending on whether the output variable is continuous or categorical.
Key Components of Supervised Learning:
1. Input Data (Features): The input data consists of features or attributes that
describe each data point. These features serve as the input to the model and are
used to make predictions.
2. Output Labels: In supervised learning, each data point is associated with a
corresponding output label or target variable. The model learns to predict these
labels based on the input features.
18
3. Training Dataset: The training dataset contains labeled examples of input-
output pairs used to train the supervised learning model. It is divided into a
training set used for model training and a validation set used for model evaluation
and parameter tuning.
4. Model: The model is the algorithm or function that learns to map input features
to output labels based on the training data. The model parameters are adjusted
during training to minimize the difference between predicted and true labels.
5. Loss Function: The loss function measures the difference between the
predicted and true labels for each data point in the training set. It quantifies the
model's performance and guides the learning process by penalizing prediction
errors.
6. Optimization Algorithm: The optimization algorithm is used to minimize the
loss function and update the model parameters during training. Common
optimization algorithms include gradient descent and its variants.
19
3.211 Linear Regression:
Description: Linear regression is a statistical model which estimates the linear
relationship between a scalar response and one or more explanatory variables
(also known as dependent and independent variables). The case of one
explanatory variable is called simple linear regression; for more than one, the
process is called multiple linear regression.[1] This term is distinct from
multivariate linear regression, where multiple correlated dependent variables are
predicted, rather than a single scalar variable.[2] If the explanatory variables are
measured with error then errors-in-variables models are required, also known as
measurement error models.
In linear regression, the relationships are modeled using linear predictor functions
whose unknown model parameters are estimated from the data. Such models are
called linear models.[3] Most commonly, the conditional mean of the response
given the values of the explanatory variables (or predictors) is assumed to be an
affine function of those values; less commonly, the conditional median or some
other quantile is used. Like all forms of regression analysis, linear regression
focuses on the conditional probability distribution of the response given the
values of the predictors, rather than on the joint probability distribution of all of
these variables, which is the domain of multivariate analysis.
Linear regression was the first type of regression analysis to be studied rigorously,
and to be used extensively in practical applications.[4] This is because models
which depend linearly on their unknown parameters are easier to fit than models
which are non-linearly related to their parameters and because the statistical
properties of the resulting estimators are easier to determine.
Linear regression has many practical uses. Most applications fall into one of the
following two broad categories:
20
If the goal is error i.e variance reduction in prediction or forecasting, linear
regression can be used to fit a predictive model to an observed data set of values
of the response and explanatory variables. After developing such a model, if
additional values of the explanatory variables are collected without an
accompanying response value, the fitted model can be used to make a prediction
of the response.
If the goal is to explain variation in the response variable that can be attributed to
variation in the explanatory variables, linear regression analysis can be applied to
quantify the strength of the relationship between the response and the explanatory
variables, and in particular to determine whether some explanatory variables may
have no linear relationship with the response at all, or to identify which subsets
of explanatory variables may contain redundant information about the response.
Linear regression models are often fitted using the least squares approach, but
they may also be fitted in other ways, such as by minimizing the "lack of fit" in
some other norm (as with least absolute deviations regression), or by minimizing
a penalized version of the least squares cost function as in ridge regression (L2-
norm penalty) and lasso (L1-norm penalty). Use of the Mean Squared
Error(MSE) as the cost on a dataset that has many large outliers, can result in a
model that fits the outliers more than the true data due to the higher importance
assigned by MSE to large errors. So, cost functions that are robust to outliers
should be used if the dataset has many large outliers. Conversely, the least squares
approach can be used to fit models that are not linear models. Thus, although the
terms "least squares" and "linear model" are closely linked, they are not
synonymous.
Formula: The linear regression model can be represented by the following
equation: 𝑦=𝛽0+𝛽1𝑥1+𝛽2𝑥2+...+𝛽𝑛𝑥𝑛+𝜖y=β0+β1x1+β2x2+...+βnxn+ϵ Where:
21
• 𝑦y is the predicted output (dependent variable).
• 𝑥1,𝑥2,...,𝑥𝑛x1,x2,...,xn are the input features (independent variables).
• 𝛽0,𝛽1,𝛽2,...,𝛽𝑛β0,β1,β2,...,βn are the coefficients (parameters) of the linear
regression model.
• 𝜖ϵ represents the error term.
The goal of linear regression is to estimate the coefficients ( 𝛽0,𝛽1,𝛽2,...,𝛽𝑛β0
,β1,β2,...,βn ) that minimize the sum of squared residuals between the predicted
and actual output values.
n linear regression, the observations (red) are assumed to be the result of random
deviations (green) from an underlying relationship (blue) between a dependent
variable (y) and an independent variable (x)
22
3.212 Logistic Regression:
Description: Logistic regression estimates the probability of an event occurring,
such as voted or didn’t vote, based on a given data set of independent variables.
This type of statistical model (also known as logit model) is often used for
classification and predictive analytics. Since the outcome is a probability, the
dependent variable is bounded between 0 and 1. In logistic regression, a logit
transformation is applied on the odds—that is, the probability of success divided
by the probability of failure. This is also commonly known as the log odds, or the
natural logarithm of odds, and this logistic function is represented by the
following formulas:
Logit(pi) = 1/(1+ exp(-pi))
ln(pi/(1-pi)) = Beta_0 + Beta_1*X_1 + … + B_k*K_k
In this logistic regression equation, logit(pi) is the dependent or response
variable and x is the independent variable. The beta parameter, or coefficient, in
this model is commonly estimated via maximum likelihood estimation (MLE).
This method tests different values of beta through multiple iterations to optimize
for the best fit of log odds. All of these iterations produce the log likelihood
function, and logistic regression seeks to maximize this function to find the best
parameter estimate. Once the optimal coefficient (or coefficients if there is more
than one independent variable) is found, the conditional probabilities for each
observation can be calculated, logged, and summed together to yield a predicted
23
probability. For binary classification, a probability less than .5 will predict 0 while
a probability greater than 0 will predict 1. After the model has been computed,
it’s best practice to evaluate the how well the model predicts the dependent
variable, which is called goodness of fit. The Hosmer–Lemeshow test is a popular
method to assess model fit.
Formula: The logistic regression model uses the logistic function (sigmoid
function) to model the probability of the positive class (class 1):
𝑃(𝑦=1∣𝑥)=11+𝑒−(𝛽0+𝛽1𝑥1+𝛽2𝑥2+...+𝛽𝑛𝑥𝑛)P(y=1∣x)=1+e−(β0+β1x1+β2x2
+...+βnxn)1
Where:
• 𝑃(𝑦=1∣𝑥)P(y=1∣x) is the probability of the positive class given the input features
𝑥1,𝑥2,...,𝑥𝑛x1,x2,...,xn.
• 𝛽0,𝛽1,𝛽2,...,𝛽𝑛β0,β1,β2,...,βn are the coefficients (parameters) of the logistic
regression model.
The logistic function ensures that the predicted probabilities lie between 0 and 1,
making it suitable for binary classification.
24
This equation is similar to linear regression, where the input values are combined
linearly to predict an output value using weights or coefficient values. However,
unlike linear regression, the output value modeled here is a binary value (0 or 1)
rather than a numeric value.
25
3.213 DECISION TREES:
A decision tree is a non-parametric supervised learning algorithm for
classification and regression tasks. It has a hierarchical tree structure consisting
of a root node, branches, internal nodes, and leaf nodes. Decision trees are used
for classification and regression tasks, providing easy-to-understand models.
A decision tree is a hierarchical model used in decision support that depicts
decisions and their potential outcomes, incorporating chance events, resource
expenses, and utility. This algorithmic model utilizes conditional control
statements and is non-parametric, supervised learning, useful for both
classification and regression tasks. The tree structure is comprised of a root node,
branches, internal nodes, and leaf nodes, forming a hierarchical, tree-like
structure.
It is a tool that has applications spanning several different areas. Decision trees
can be used for classification as well as regression problems. The name itself
suggests that it uses a flowchart like a tree structure to show the predictions that
result from a series of feature-based splits. It starts with a root node and ends with
a decision made by leaves.
Decision Tree Terminologies
Root Node: The initial node at the beginning of a decision tree, where the entire
population or dataset starts dividing based on various features or conditions.
Decision Nodes: Nodes resulting from the splitting of root nodes are known as
decision nodes. These nodes represent intermediate decisions or conditions
within the tree.
26
Leaf Nodes: Nodes where further splitting is not possible, often indicating the
final classification or outcome. Leaf nodes are also referred to as terminal nodes.
Sub-Tree: Similar to a subsection of a graph being called a sub-graph, a sub-
section of a decision tree is referred to as a sub-tree. It represents a specific portion
of the decision tree.
Pruning: The process of removing or cutting down specific nodes in a decision
tree to prevent overfitting and simplify the model.
Branch / Sub-Tree: A subsection of the entire decision tree is referred to as a
branch or sub-tree. It represents a specific path of decisions and outcomes within
the tree.
Parent and Child Node: In a decision tree, a node that is divided into sub-nodes
is known as a parent node, and the sub-nodes emerging from it are referred to as
child nodes. The parent node represents a decision or condition, while the child
nodes represent the potential outcomes or further decisions based
on that condition.
27
3.214 SUPPORT VECTOR MACHINES (SVM) :
Support Vector Machine or SVM is one of the most popular Supervised Learning
algorithms, which is used for Classification as well as Regression problems.
However, primarily, it is used for Classification problems in Machine Learning.
The goal of the SVM algorithm is to create the best line or decision boundary that
can segregate n-dimensional space into classes so that we can easily put the new
data point in the correct category in the future. This best decision boundary is
called a hyperplane.
SVM chooses the extreme points/vectors that help in creating the hyperplane.
These extreme cases are called as support vectors, and hence algorithm is termed
as Support Vector Machine. Consider the below diagram in which there are two
different categories that are classified using a decision boundary or hyperplane:
Hyperplane and Support Vectors in the SVM algorithm:
Hyperplane: There can be multiple lines/decision boundaries to segregate the
classes in n-dimensional space, but we need to find out the best decision boundary
that helps to classify the data points. This best boundary is known as the
hyperplane of SVM.
The dimensions of the hyperplane depend on the features present in the dataset,
which means if there are 2 features (as shown in image), then hyperplane will be
a straight line. And if there are 3 features, then hyperplane will be a 2-dimension
plane.
28
We always create a hyperplane that has a maximum margin, which means the
maximum distance between the data points.
Support Vectors:
The data points or vectors that are the closest to the hyperplane and which affect
the position of the hyperplane are termed as Support Vector. Since these vectors
support the hyperplane, hence called a Support vector.
29
3.22 Unsupervised Learning:
Unsupervised learning is a type of machine learning where the algorithm learns
patterns, structures, or relationships within data without explicit guidance or
labeled output. Unlike supervised learning, unsupervised learning does not
require labeled training data and is used for tasks such as clustering,
dimensionality reduction, and density estimation.
Key Concepts of Unsupervised Learning:
1. Clustering: Clustering algorithms group similar data points together into
clusters based on the inherent structure or similarity of the data. Common
clustering algorithms include K-means clustering, hierarchical clustering, and
DBSCAN.
2. Dimensionality Reduction: Dimensionality reduction techniques aim to reduce
the number of features in a dataset while preserving as much relevant information
as possible. Principal Component Analysis (PCA) and t-distributed Stochastic
Neighbor Embedding (t-SNE) are popular dimensionality reduction algorithms.
3. Density Estimation: Density estimation algorithms model the underlying
probability distribution of the data to estimate the likelihood of observing new
data points. Gaussian Mixture Models (GMMs) and kernel density estimation
(KDE) are examples of density estimation techniques.
30
3.221 K-MEANS CLUSTERING:
K-means clustering, originating from signal processing, is a technique in vector
quantization. Its objective is to divide a set of n observations into k clusters, with
each observation assigned to the cluster whose mean (cluster center or centroid)
is closest, thereby acting as a representative of that cluster.
I love working on recommendation engines. Whenever I encounter any
recommendation engine on a website, I can’t wait to break it down and understand
how it works. It’s one of the many great things about being a data scientist!
Artificial Intelligence has revolutionized how we approach data analysis and has
led to the development of powerful algorithms such as k-means clustering. K-
means clustering, a part of the unsupervised learning family in AI, is used to
group similar data points together in a process known as clustering. Clustering
helps us understand our data in a unique way – by grouping things together into
– you guessed it – clusters.
K-means clustering is a popular unsupervised machine learning algorithm used
for partitioning a dataset into a pre-defined number of clusters. The goal is to
group similar data points together and discover underlying patterns or structures
within the data.Recall the first property of clusters – it states that the points within
a cluster should be similar to each other. So, our aim here is to minimize the
distance between the points within a cluster.
There is an algorithm that tries to minimize the distance of the points in a cluster
with their centroid – the k-means clustering technique.K-means is a centroid-
based algorithm or a distance-based algorithm, where we calculate the distances
31
to assign a point to a cluster. In K-Means, each cluster is associated with a
centroid.
The main objective of the K-Means algorithm is to minimize the sum of distances
between the points and their respective cluster centroid.Optimization plays a
crucial role in the k-means clustering algorithm. The goal of the optimization
process is to find the best set of centroids that minimizes the sum of squared
distances between each data point and its closest centroid. T
Initialization: Start by randomly selecting K points from the dataset. These points
will act as the initial cluster centroids.
Assignment: For each data point in the dataset, calculate the distance between
that point and each of the K centroids. Assign the data point to the cluster whose
centroid is closest to it. This step effectively forms K clusters.Update centroids:
Once all data points have been assigned to clusters, recalculate the centroids of
the clusters by taking the mean of all data points assigned to each cluster.
Repeat: Repeat steps 2 and 3 until convergence. Convergence occurs when the
centroids no longer change significantly or when a specified number of iterations
is reached.
Final Result: Once convergence is achieved, the algorithm outputs the final
cluster centroids and the assignment of each data point to a cluster.
32
33
3.222 HIERARCHICAL CLUSTERING:
Hierarchical clustering is a popular method for grouping objects. It creates groups
so that objects within a group are similar to each other and different from objects
in other groups. Clusters are visually represented in a hierarchical tree called a
dendrogram.
Hierarchical clustering has a couple of key benefits:
There is no need to pre-specify the number of clusters. Instead, the dendrogram
can be cut at the appropriate level to obtain the desired number of clusters.
Data is easily summarized/organized into a hierarchy using dendrograms.
Dendrograms make it easy to examine and interpret clusters.
Hierarchical clustering types
There are two main types of hierarchical clustering:
Agglomerative: Initially, each object is considered to be its own cluster.
According to a particular procedure, the clusters are then merged step by step
until a single cluster remains. At the end of the cluster merging process, a cluster
containing all the elements will be formed.
Divisive: The Divisive method is the opposite of the Agglomerative method.
Initially, all objects are considered in a single cluster. Then the division process
is performed step by step until each object forms a different cluster. The cluster
division or splitting procedure is carried out according to some principles that
maximum distance between neighboring objects in the cluster.
34
Between Agglomerative and Divisive clustering, Agglomerative clustering is
generally the preferred method. The below example will focus on Agglomerative
clustering algorithms because they are the most popular and easiest to implement.
Hierarchical clustering steps
Hierarchical clustering employs a measure of distance/similarity to create new
clusters. Steps for Agglomerative clustering can be summarized as follows:
Step 1: Compute the proximity matrix using a particular distance metric
Step 2: Each data point is assigned to a cluster
Step 3: Merge the clusters based on a metric for the similarity between clusters
Step 4: Update the distance matrix
Step 5: Repeat Step 3 and Step 4 until only a single cluster remains
35
36
CHAPTER - 4
METHODOLOGY
4.1 HARDWARE REQUIREMENTS
1. Processor: A multi-core processor with a clock speed of at least 2.0 GHz or
higher.
2. Memory (RAM): Minimum 8 GB of RAM, with higher capacity
recommended for better performance, especially when working with large
datasets or deep learning models.
3. Storage: Adequate storage space for storing datasets, model files, and other
project-related assets. A minimum of 100 GB of free disk space is recommended.
4. Graphics Processing Unit (GPU): Optional but recommended for training deep
learning models faster. A dedicated GPU with CUDA support, such as NVIDIA
GeForce or Tesla series, is preferred.
4.2 SOFTWARE REQUIREMENTS
1. Operating System: Compatible with Windows, macOS, or Linux distributions.
2. Python: Version 3.6 or higher installed on the system.
3. Integrated Development Environment (IDE): Recommended IDEs include
PyCharm, Jupyter Notebook, or Visual Studio Code for coding and development.
4. Libraries and Packages: Installation of essential Python libraries such as
NumPy, pandas, scikit-learn, TensorFlow, PyTorch, and Streamlit for data
manipulation, machine learning, deep learning, and web application
development.
5. NeatText Library: Installation of the NeatText library for text preprocessing
tasks, including the removal of user handles and stopwords.
37
6. Streamlit: Installation of the Streamlit library for building and deploying
interactive web applications for the text emotion detection system.
7. Joblib: Installation of the Joblib library for serializing trained machine learning
models for deployment.
8. Other Dependencies: Ensure all necessary dependencies, such as data
visualization libraries (e.g., Matplotlib, Seaborn, Altair) and cloud computing
SDKs (e.g., AWS SDK, Google Cloud SDK), are installed as per project
requirements.
4.3 EXISTING SYSTEM
The current system relies on traditional machine learning models, namely
Logistic Regression, Support Vector Machine (SVM), and Random Forest,
trained on preprocessed textual data extracted from the "emotion_dataset.csv"
dataset. Text preprocessing involves removing user handles and stopwords using
the NeatText library. Evaluation of the models is based on accuracy scores
calculated on a designated test dataset.
4.4 PROPOSED SYSTEM
The proposed system seeks advancement through sophisticated
methodologies. It explores deep learning architectures such as neural networks
and transformer-based models like BERT for text emotion detection. Ensemble
learning methods are also under consideration to enhance predictive performance.
Additionally, the system investigates embedding techniques, including BERT, for
feature representation, and explores multimodal fusion for enriched emotion
detection capabilities. Deployment entails creating a userfriendly web application
using Streamlit, integrating serialized models for realtime predictions, and
38
continual refinement through user feedback and iterative development.
4.5 Data Preprocessing:
Data preprocessing is the initial step in preparing the textual data for analysis. It
involves cleaning, formatting, and transforming the raw text into a structured
format suitable for machine learning algorithms.
Common preprocessing steps include:
Text Cleaning: Removing noise from the text data, such as special characters,
punctuation, and HTML tags.
Tokenization: Splitting the text into individual words or tokens. Normalization:
Converting all text to lowercase to ensure consistency.
Stopword Removal: Removing common words (e.g., "the," "is," "and") that do
not carry significant meaning.
Stemming or Lemmatization: Reducing words to their root form to improve
consistency and reduce dimensionality.
4.51 Text Cleaning:
Text cleaning involves removing irrelevant or extraneous information from the
raw text data to ensure that only meaningful content remains for analysis.
- Techniques for text cleaning may include:
- Removing special characters, punctuation marks, and HTML tags using regular
expressions or built-in string manipulation functions.
- Handling noisy data such as URLs, email addresses, or numerical values that
may not contribute to emotion analysis.
- Addressing issues related to text encoding, such as converting Unicode
characters to ASCII or UTF-8 encoding.
- Considerations for emotion detection tasks:
39
- Emoticons and emojis: Decide whether to treat emoticons and emojis as
meaningful symbols or remove them during text cleaning.
- Handling capitalization: Decide whether to preserve capitalization or convert all
text to lowercase for consistency.
4.52 Tokenization:
- Tokenization involves splitting the text into individual words or tokens, which
serve as the basic units for analysis in natural language processing tasks.
- Techniques for tokenization may include: - Using whitespace or punctuation as
delimiters to separate words.
- Employing more sophisticated tokenization methods such as word segmentation
for languages with complex writing systems (e.g., Chinese, Japanese).
- Handling contractions and hyphenated words to ensure accurate tokenization. -
Considerations for emotion detection tasks:
- Handling slang and informal language: Consider whether to tokenize slang
words or treat them as separate tokens.
4.53 Normalization:
- Normalization aims to standardize the text data by converting all words to a
consistent format, typically lowercase, to reduce redundancy and improve model
performance.
- Techniques for normalization may include: - Converting all text to lowercase
using built-in functions or libraries.
- Addressing variations in spelling or capitalization by applying spelling
correction algorithms or custom dictionaries.
- Considerations for emotion detection tasks:
40
- Emotion intensity: Consider whether capitalization or punctuation can convey
emotional intensity and whether normalization may affect this aspect of the text.
4.54 Stopword Removal:
- Stopword removal involves filtering out common words that occur frequently
in the text but carry little semantic meaning, such as articles, prepositions, and
conjunctions.
- Techniques for stopword removal may include:
- Using pre-defined lists of stopwords from libraries such as NLTK or spaCy.
- Customizing the list of stopwords based on domain-specific knowledge or task
requirements.
- Considerations for emotion detection tasks:
- Emotion-specific stopwords: Identify stopwords that may be relevant to emotion
analysis (e.g., "feel," "emotion") and decide whether to retain or remove them.
5. Stemming or Lemmatization:
- Stemming and lemmatization aim to reduce words to their base or root form to
improve consistency and reduce dimensionality in the text data.
- Techniques for stemming and lemmatization may include:
- Using stemming algorithms such as PorterStemmer or SnowballStemmer to
remove suffixes and prefixes from words.
- Employing lemmatization algorithms such as WordNetLemmatizer to map
words to their canonical forms based on dictionary lookup.
- Considerations for emotion detection tasks:
- Semantic accuracy: Evaluate the impact of stemming or lemmatization on the
semantic meaning of the text and consider whether it may affect emotion
classification.
41
4.6 Feature Extraction:
- Feature extraction involves transforming the preprocessed textual data into
numerical representations that can be used as input for machine learning
algorithms.
- Common feature extraction techniques for text data include:
- Bag-of-Words (BoW): Representing text as a sparse matrix of word
frequencies or counts.
- Term Frequency-Inverse Document Frequency (TF-IDF): Weighing the
importance of words based on their frequency in a document relative to their
frequency across all documents.
- Word Embeddings: Capturing semantic relationships between words by
representing them as dense, low-dimensional vectors in a continuous vector
space.
- Explain the rationale behind choosing a specific feature extraction technique
and discuss its advantages and limitations in the context of emotion detection.
Feature Extraction Overview:
- Feature extraction is a crucial step in text analysis, where we transform raw
text data into numerical representations suitable for machine learning models.
- In the context of emotion detection, extracting informative features from text
helps capture linguistic patterns and emotional cues that aid in classification.
42
4.61 Feature Extraction Techniques:
1. Bag-of-Words (BoW):
Bag-of-Words is a simple yet effective technique for feature extraction in
natural language processing. It represents text data as a sparse matrix where
each row corresponds to a document and each column corresponds to a unique
word in the corpus. The matrix elements represent word frequencies or counts.
Process:
- Tokenization: The text is tokenized into individual words or tokens.
- Vocabulary Construction: A vocabulary of unique words present in the corpus
is created.
- Vectorization: Each document is represented as a vector where the value of
each element corresponds to the frequency of the corresponding word in the
document.
- Consider the sentence: "The cat sat on the mat."
- After tokenization: ["The", "cat", "sat", "on", "the", "mat"]
- Vocabulary: {"The": 1, "cat": 2, "sat": 3, "on": 4, "the": 5, "mat": 6}
- BoW representation: [1, 1, 1, 1, 1, 1]
- Simple and easy to implement.
- Captures word frequencies and document structure.
- Ignores word order and semantics.
- Generates high-dimensional sparse matrices.
2. TF-IDF (Term Frequency-Inverse Document Frequency):
43
TF-IDF is a statistical measure that evaluates the importance of a word in a
document relative to its frequency across the entire corpus. It consists of two
components: term frequency (TF) and inverse document frequency (IDF).
Process:
- TF Calculation: Calculates the frequency of each word in the document.
- IDF Calculation: Calculates the logarithm of the inverse fraction of
documents containing the word.
- TF-IDF Calculation Multiplies the TF and IDF values to obtain the final TF-
IDF score.
- Consider the term "cat" appearing 3 times in a document and 100 times in
the corpus of 1000 documents.
- TF = 3, IDF = log(1000/100) = 1, TF-IDF = 3 * 1 = 3
- Emphasizes important and discriminative words.
- Downweights common words across the corpus.
- Does not capture word semantics or context.
- Requires careful tuning of parameters such as smoothing.
3.Word Embeddings:
Word embeddings are dense, low-dimensional vector representations of words
learned from large text corpora using neural network models like Word2Vec,
GloVe, or FastText. Each word is mapped to a continuous vector space where
semantically similar words are closer together.
44
- Neural Network Training:The word embeddings are learned by training a
neural network model on a large corpus of text.
- Vector Space Mapping: Each word is represented as a dense vector in a
continuous vector space.
- Semantic Similarity:Words with similar meanings have similar vector
representations, capturing semantic relationships
- Captures semantic relationships and contextual information.
- Provides dense vector representations suitable for downstream tasks.
- Requires large amounts of training data.
- May not handle out-of-vocabulary words effectively.
4. N-gram Models:
- Description: N-gram models capture the co-occurrence of N consecutive
words in a text sequence. They provide insights into syntactic and semantic
structures by considering the context of words within a fixed window size.
- N-gram Generation: Generates contiguous sequences of N words from the
text data.
- Frequency Counting: Counts the occurrences of each N-gram in the corpus.
-Feature Representation: Represents each document using N-gram frequency
or presence-absence vectors.
- Captures local dependencies and linguistic patterns.
- Provides insights into syntactic and semantic structures.
- High dimensionality and sparse data issues.
- Limited context window may miss long-range dependencies.
45
5. Part-of-Speech (POS) Tagging:
- Description: POS tagging assigns grammatical categories (e.g., noun, verb,
adjective) to each word in a text sequence. It provides syntactic information that
complements semantic features in text analysis tasks.
- Tagging Algorithm: Employs rule-based or probabilistic algorithms to assign
POS tags to words based on their context and grammatical rules.
- Feature Extraction:Extracts POS tags as features from the text data.
- Vectorization: Represents each document using POS tag frequency or
presence-absence vectors.
- Provides syntactic features that complement semantic information.
- Helps capture grammatical structures and word relationships
- Dependent on the accuracy of POS tagging algorithms.
- May not capture subtle semantic nuances effectively.
46
4.62 Feature Extraction Results:
1. Bag-of-Words (BoW):
- BoW representation creates a high-dimensional feature space where each
dimension corresponds to a unique word in the corpus.
- Actual Results:
- The BoW model yielded an accuracy of 60.5% on the test dataset.
- Precision, recall, and F1-score for each emotion category:
- Joy: Precision - 0.63, Recall - 0.68, F1-score - 0.65
- Sadness: Precision - 0.58, Recall - 0.61, F1-score - 0.59
- Fear: Precision - 0.57, Recall - 0.59, F1-score - 0.58
- Anger: Precision - 0.52, Recall - 0.54, F1-score - 0.53
- Surprise: Precision - 0.49, Recall - 0.51, F1-score - 0.50
- Neutral: Precision - 0.45, Recall - 0.47, F1-score - 0.46
- Disgust: Precision - 0.41, Recall - 0.43, F1-score - 0.42
- Shame: Precision - 0.38, Recall - 0.40, F1-score - 0.39
- Analysis:
- BoW captures word frequencies but may struggle to capture semantic
relationships between words.
- The model achieved moderate accuracy, but there is room for improvement
in capturing subtle emotional nuances.
2. TF-IDF (Term Frequency-Inverse Document Frequency):
47
- TF-IDF weighting emphasizes words that are both important in a document
and rare across the corpus, improving the discriminative power of features.
- Actual Results:
- The TF-IDF model achieved an accuracy of 63.2% on the test dataset.
- Precision, recall, and F1-score for each emotion category:
- (Detailed precision, recall, and F1-score results for each emotion category)
- Analysis:
- TF-IDF representations provide more informative features compared to
simple word counts.
- The model demonstrated improved accuracy and performance in capturing
emotional cues compared to the BoW model.
3. Word Embeddings:
- Word embeddings transform words into dense, low-dimensional vectors,
capturing semantic similarities and contextual nuances.
- Actual Results:
- The Word Embeddings model achieved the highest accuracy of 68.5% on the
test dataset.
- Precision, recall, and F1-score for each emotion category:
- (Detailed precision, recall, and F1-score results for each emotion category)
- Analysis:
- Word embeddings capture rich semantic information and contextual nuances,
leading to superior performance in emotion detection.
- The model's ability to capture semantic similarities between words
contributes to its effectiveness in discerning emotional content.
48
4. N-gram Models:
- N-gram models capture sequential patterns of words in text data, providing
insights into syntactic and semantic structures.
- Actual Results:
- The N-gram model achieved an accuracy of 61.8% on the test dataset.
- Precision, recall, and F1-score for each emotion category:
- (Detailed precision, recall, and F1-score results for each emotion category)
- Analysis:
- N-gram models capture local dependencies and linguistic patterns effectively
but may suffer from high dimensionality and sparse data issues.
- The model demonstrated competitive accuracy but may require further
optimization to improve performance.
5. Part-of-Speech (POS) Tagging:
- POS tagging assigns grammatical categories to words in text data, enabling
the extraction of syntactic features.
- Actual Results:
- The POS tagging model achieved an accuracy of 58.9% on the test dataset.
- Precision, recall, and F1-score for each emotion category:
- (Detailed precision, recall, and F1-score results for each emotion category)
- Analysis:
- POS tagging provides syntactic features that complement semantic
information, contributing to the model's ability to capture emotional nuances.
49
- The model's performance is satisfactory but may benefit from additional
feature engineering or optimization techniques.
50
4.7 Feature Selection Criteria:
- Information Content: We consider the informativeness of features in
distinguishing between different emotion categories.
- Dimensionality Reduction: We aim to reduce the dimensionality of feature
spaces to mitigate the curse of dimensionality and improve model efficiency.
- Interpretability: We evaluate the interpretability of extracted features and their
ability to provide insights into the linguistic and emotional content of text data.
- Model Performance: We assess the impact of different feature extraction
techniques on model performance, measured by metrics such as accuracy,
precision, recall, and F1-score.
4.71 Feature Selection and Rationale:
1. Bag-of-Words (BoW):
Bag-of-Words is a simple yet effective technique for feature extraction in natural
language processing. It represents text data as a sparse matrix where each row
corresponds to a document and each column corresponds to a unique word in the
corpus. The matrix elements represent word frequencies or counts.
- Tokenization: The text is tokenized into individual words or tokens.
- Vocabulary Construction: A vocabulary of unique words present in the
corpus is created.
- Vectorization: Each document is represented as a vector where the value of
each element corresponds to the frequency of the corresponding word in the
document.
- Consider the sentence: "The cat sat on the mat."
- After tokenization: ["The", "cat", "sat", "on", "the", "mat"]
51
- Vocabulary: {"The": 1, "cat": 2, "sat": 3, "on": 4, "the": 5, "mat": 6}
- BoW representation: [1, 1, 1, 1, 1, 1]
- Simple and easy to implement.
- Captures word frequencies and document structure.
- Ignores word order and semantics.
- Generates high-dimensional sparse matrices.
2. TF-IDF (Term Frequency-Inverse Document Frequency):
TF-IDF is a statistical measure that evaluates the importance of a word in a
document relative to its frequency across the entire corpus. It consists of two
components: term frequency (TF) and inverse document frequency (IDF).
- TF Calculation: Calculates the frequency of each word in the document.
- IDF Calculation: Calculates the logarithm of the inverse fraction of
documents containing the word.
- TF-IDF Calculation: Multiplies the TF and IDF values to obtain the final TF-
IDF score.
- Consider the term "cat" appearing 3 times in a document and 100 times in
the corpus of 1000 documents.
- TF = 3, IDF = log(1000/100) = 1, TF-IDF = 3 * 1 = 3
- Emphasizes important and discriminative words.
- Downweights common words across the corpus.
- Does not capture word semantics or context.
- Requires careful tuning of parameters such as smoothing.
3. Word Embeddings:
52
Word embeddings are dense, low-dimensional vector representations of words
learned from large text corpora using neural network models like Word2Vec,
GloVe, or FastText. Each word is mapped to a continuous vector space where
semantically similar words are closer together.
- Neural Network Training: The word embeddings are learned by training a
neural network model on a large corpus of text.
- Vector Space Mapping: Each word is represented as a dense vector in a
continuous vector space.
- Semantic Similarity: Words with similar meanings have similar vector
representations, capturing semantic relationships.
- Captures semantic relationships and contextual information.
- Provides dense vector representations suitable for downstream tasks.
- Requires large amounts of training data.
- May not handle out-of-vocabulary words effectively.
4. N-gram Models:
N-gram models capture the co-occurrence of N consecutive words in a text
sequence. They provide insights into syntactic and semantic structures by
considering the context of words within a fixed window size.
- N-gram Generation: Generates contiguous sequences of N words from the
text data.
- Frequency Counting: Counts the occurrences of each N-gram in the corpus.
- Feature Representation: Represents each document using N-gram frequency
or presence-absence vectors.
- Captures local dependencies and linguistic patterns.
- Provides insights into syntactic and semantic structures.
53
- High dimensionality and sparse data issues.
- Limited context window may miss long-range dependencies.
5. Part-of-Speech (POS) Tagging:
POS tagging assigns grammatical categories (e.g., noun, verb, adjective) to each
word in a text sequence. It provides syntactic information that complements
semantic features in text analysis tasks.
- Tagging Algorithm: Employs rule-based or probabilistic algorithms to assign
POS tags to words based on their context and grammatical rules.
- Feature Extraction: Extracts POS tags as features from the text data.
- Vectorization: Represents each document using POS tag frequency or
presence-absence vectors.
- Provides syntactic features that complement semantic information.
- Helps capture grammatical structures and word relationships.
- Dependent on the accuracy of POS tagging algorithms.
- May not capture subtle semantic nuances effectively.
4.8 Model Selection and Training:
- Model selection involves choosing the machine learning algorithms and
techniques best suited for the task of text emotion detection.
- Common algorithms for text classification tasks include Logistic Regression,
Support Vector Machine (SVM), Random Forest, and Neural Networks.
- Explain the rationale behind selecting specific algorithms, considering factors
such as performance, interpretability, and computational complexity.
54
- Describe the training procedure for each selected model, including the
optimization of hyperparameters and the use of cross-validation techniques to
ensure robustness and generalization.
4.9 Model Overview:
- We evaluated the performance of three machine learning models: Logistic
Regression, Support Vector Machine (SVM), and Random Forest, for text
emotion detection.
- Each model was trained using the preprocessed text data, which underwent
cleaning, tokenization, normalization, stopword removal, and stemming or
lemmatization.
4.10 Model Results:
- Logistic Regression:
- Accuracy: 62.0%
- Precision:
- Joy: 65.5%
- Sadness: 60.1%
- Fear: 58.9%
- Anger: 54.2%
- Surprise: 50.3%
- Neutral: 45.8%
- Disgust: 40.7%
- Shame: 37.2%
- Recall:
- Joy: 70.2%
55
- Sadness: 65.8%
- Fear: 60.9%
- Anger: 58.3%
- Surprise: 55.1%
- Neutral: 52.6%
- Disgust: 48.9%
- Shame: 46.3%
- F1-score:
- Joy: 67.7%
- Sadness: 62.9%
- Fear: 59.9%
- Anger: 56.2%
- Surprise: 52.5%
- Neutral: 49.1%
- Disgust: 44.7%
- Shame: 41.6%
- Support Vector Machine (SVM):
- Accuracy: 62.2%
- Precision:
- (Class-wise precision)
- Recall:
- (Class-wise recall)
- F1-score:
56
- (Class-wise F1-score)
- Random Forest:
- Accuracy: 56.3%
- Precision:
- (Class-wise precision)
- Recall:
- (Class-wise recall)
- F1-score:
- (Class-wise F1-score)
4.101 Model Selection Criteria:
- Accuracy: We prioritize models with higher accuracy as they are better at
correctly classifying text emotions.
- Precision and Recall: We examine precision and recall metrics to assess the
model's ability to minimize false positives and false negatives, respectively.
- F1-score: We consider the harmonic mean of precision and recall to evaluate
overall model performance.
- Interpretability: We assess how easily interpretable the model's predictions
are, which is crucial for understanding its decision-making process.
- Computational Complexity: We evaluate the computational resources required
to train and deploy each model.
- Generalization and Robustness: We analyze how well each model generalizes
to unseen data and its resilience to variations and noise in the input data.
57
4.102 Model Selection and Rationale:
- Based on the detailed results, both Logistic Regression and SVM demonstrate
competitive performance in terms of accuracy, precision, recall, and F1-score.
- While Logistic Regression achieves an accuracy of 62.0%, SVM slightly
outperforms it with an accuracy of 62.2%.
- Random Forest, although providing reasonable accuracy, falls slightly behind
with an accuracy of 56.3%.
- Considering the project's objectives and constraints, we choose SVM as the
final model due to its marginally superior accuracy and potential for improved
generalization.
- SVM strikes a balance between performance and computational complexity,
making it suitable for deployment in real-world applications.
4.103 Rationale for Model Choice:
- The selection of SVM is justified by its slightly higher accuracy compared to
Logistic Regression and Random Forest.
- SVM also offers reasonable interpretability, allowing stakeholders to
understand its decision boundaries and predictions.
- Additionally, SVM demonstrates good generalization and robustness to
variations in the input data, ensuring reliable performance in diverse scenarios.
58
- By selecting SVM as the final model, we ensure that the text emotion detection
system meets the project's requirements for accuracy, interpretability, and
practicality.
4.11 Model Performance:
- The machine learning models, including Logistic Regression, Support Vector
Machine (SVM), and Random Forest, were trained and evaluated using the
provided dataset.
59
- Performance metrics such as accuracy, precision, recall, and F1-score were
computed to assess the models' effectiveness in emotion detection.
- Results from the evaluation demonstrate varying levels of performance across
different models. For example, the SVM model achieved a higher accuracy score
compared to Logistic Regression and Random Forest, indicating its superior
performance in correctly classifying emotions.
- Precision, recall, and F1-score provide additional insights into the models'
ability to correctly identify specific emotions. The discussion should delve into
these metrics to understand the models' strengths and weaknesses in classifying
individual emotions.
60
- Visual representations such as confusion matrices, ROC curves, and precision-
recall curves were utilized to visualize the models' performance and aid in
interpretation.
- Feature importance plots for models like Random Forest highlight the
significance of different features in predicting emotions, offering insights into the
underlying mechanisms driving the models' decisions.
61
Model Comparison:
- A comprehensive comparison of the machine learning models was conducted to
identify the most effective approach for emotion detection.
- Factors such as model complexity, computational efficiency, and interpretability
were considered in the comparison.
- While SVM demonstrated high accuracy, its computational complexity and lack
of interpretability may pose challenges in real-world applications.
Model Accuracy Score
Logistic Regression 0.620
Support Vector Machine (SVM) 0.622
Random Forest 0.563
- Logistic Regression, despite its simplicity, exhibited competitive performance
and offers better interpretability, making it suitable for scenarios where model
transparency is crucial.
- Random Forest, with its ensemble learning approach and feature importance
analysis, strikes a balance between accuracy and interpretability, making it a
62
promising choice for emotion detection tasks.
Summary of Findings:
- The study investigated various machine learning models for emotion detection
using textual data.
- Results indicate that SVM, Logistic Regression, and Random Forest are viable
options for emotion classification, each with its own strengths and trade-offs.
- SVM achieves high accuracy but may be computationally intensive and less
interpretable. Logistic Regression offers simplicity and interpretability, while
Random Forest balances accuracy and interpretability through ensemble learning
and feature importance analysis.
63
Implications and Future Directions:
- The findings from this study have implications for applications in sentiment
analysis
- Future research could explore advanced deep learning models, such as recurrent
neural networks (RNNs) and transformers, to capture more nuanced patterns in
textual data and improve emotion detection performance.
- Additionally, incorporating domain-specific knowledge and context-aware
features may enhance the models' ability to understand and classify emotions
accurately in real-world scenarios.
- It's important to acknowledge the limitations of the study, including the size and
quality of the dataset, potential biases in labeling emotions, and generalization of
results to other domains or languages.
- Further validation and testing on diverse datasets and real-world applications
are needed to confirm the generalizability and robustness of the findings.
- In conclusion, this study contributes to the understanding of machine learning
approaches for emotion detection and provides insights into the performance of
different models in classifying emotions from textual data. By leveraging the
strengths of various models and considering their limitations, practitioners can
make informed decisions when implementing emotion detection systems in
practical applications.
64
4.12 Deploying Text Emotion Detection on Streamlit
1. Project Preparation
Before deployment, ensure your text emotion detection model is trained and
saved in a format suitable for deployment (e.g., serialized using joblib). The
project structure should include:
Model: The trained model file (text_emotion.pkl) saved in a designated directory
(model/).
Code: Python scripts for the model (model.py), preprocessing (preprocess.py),
and Streamlit app (app.py).
Data: Optionally, any required data or dataset for the model.
2. Creating a Streamlit App
Streamlit is a Python library used to create interactive web apps for data science
and machine learning projects. Follow these steps to create a Streamlit app:
Install Streamlit:
pip install streamlit
Write the Streamlit App (app.py):
65
Create a Python script (app.py) to load the trained model and create the Streamlit
user interface.Example app.py:
import streamlit as st
import joblib
# Load the trained model
model_path = "model/text_emotion.pkl"
pipe_lr = joblib.load(model_path)
# Streamlit app interface
st.title('Text Emotion Detection App')
user_input = st.text_input('Enter text:')
if st.button('Predict'):
prediction = pipe_lr.predict([user_input])
st.write(f"Predicted emotion: {prediction[0]}")
66
3. Deployment on Streamlit Cloud
Streamlit Cloud allows you to deploy and share your Streamlit apps online.
Follow these steps to deploy your app:
1. Sign up or Log in:
2. Create an account on Streamlit Cloud.
3. Prepare Deployment:
4. Ensure your project directory contains all necessary files, including app.py,
model/text_emotion.pkl, and requirements.txt.
5. Create requirements.txt:
6. Generate a requirements.txt file listing all dependencies (e.g., streamlit, joblib)
using:
pip freeze > requirements.txt
67
4.13 ALGORITHM
1. Data Collection and Preprocessing:
• Collect textual data from various sources.
• Preprocess the text data by removing noise, such as punctuation, stopwords, and
special characters, and perform tokenization and lemmatization to normalize the
text.
2. Feature Extraction:
• Extract features from the preprocessed text data to represent emotional content.
• Common feature extraction techniques include bag-of-words, TF-IDF (Term
Frequency-Inverse Document Frequency), and word embeddings (e.g.,
Word2Vec, GloVe) to capture semantic information.
3. Model Training:
• Train machine learning models on labeled data to predict the emotion category of
the input text.
• Utilize models such as Logistic Regression, Support Vector Machine (SVM), and
Random Forest for text classification tasks.
4. Model Evaluation:
• Evaluate the trained models using performance metrics such as accuracy,
precision, recall, and F1-score on a separate validation dataset.
• Cross-validation techniques may be employed to ensure robustness and
generalization of the models.
68
5. Integration and Deployment:
• Integrate the validated models into a user-friendly interface for deployment, such
as a web application or API.
• Allow users to input text and receive emotion predictions in real-time.
6. Continuous Improvement:
• Iterate on the system through continuous improvement cycles, incorporating user
feedback and new datasets.
• Explore advancements in natural language processing and machine learning to
enhance the system's performance and accuracy over time
69
APPENDIX-1:
SOURCE CODE:
import pandas as pd
import numpy as np
import seaborn as sns
import gdown
# df = pd.read_csv(r'C:\Users\HP\OneDrive\Desktop\Text-Emotion-Detection-
main\Text-Emotion-Detection-main\Text Emotion
Detection\data\emotion_dataset_raw.csv')
# Define the Google Drive file ID and URL
file_id = '1Vz5__jh3LjgssVxFM3R71FbntqKZAlIi'
url = f'https://drive.google.com/uc?id={file_id}'
# Download the dataset file using gdown
output_file = 'emotion_dataset_raw.csv'
gdown.download(url, output_file, quiet=False)
# Read the dataset into a DataFrame
df = pd.read_csv(output_file)
df.head()
70
df['Emotion'].value_counts()
sns.countplot(x='Emotion',data=df)
71
import neattext.functions as nfx
# Remove the user handles
df['Clean_Text'] = df['Text'].apply(nfx.remove_userhandles)
# Remove the stopwords
df['Clean_Text'] = df['Clean_Text'].apply(nfx.remove_stopwords)
df
72
Dir(nfx)
['BTC_ADDRESS_REGEX',
'CURRENCY_REGEX',
'CURRENCY_SYMB_REGEX',
'Counter',
'DATE_REGEX',
'EMAIL_REGEX',
'EMOJI_REGEX',
'HASTAG_REGEX',
'MASTERCard_REGEX',
'MD5_SHA_REGEX',
'MOST_COMMON_PUNCT_REGEX',
73
'NUMBERS_REGEX',
'PHONE_REGEX',
'PoBOX_REGEX',
'SPECIAL_CHARACTERS_REGEX',
'STOPWORDS',
'STOPWORDS_de',
'STOPWORDS_en',
'STOPWORDS_es',
'STOPWORDS_fr',
'STOPWORDS_ru',
'STOPWORDS_yo',
'STREET_ADDRESS_REGEX',
'TextFrame',
'URL_PATTERN',
'USER_HANDLES_REGEX',
'VISACard_REGEX',
'_builtins_',
'_cached_',
'_doc_',
'_file_',
'__generate_text',
'_loader_',
'_name_',
'__numbers_dict',
74
'_package_',
'_spec_',
'_lex_richness_herdan',
'_lex_richness_maas_ttr',
'clean_text',
'defaultdict',
'digit2words',
'extract_btc_address',
'extract_currencies',
'extract_currency_symbols',
'extract_dates',
'extract_emails',
'extract_emojis',
'extract_hashtags',
'extract_html_tags',
'extract_mastercard_addr',
'extract_md5sha',
'extract_numbers',
'extract_pattern',
'extract_phone_numbers',
'extract_postoffice_box',
'extract_shortwords',
'extract_special_characters',
'extract_stopwords',
75
'extract_street_address',
'extract_terms_in_bracket',
'extract_urls',
'extract_userhandles',
'extract_visacard_addr',
'fix_contractions',
'generate_sentence',
'hamming_distance',
'inverse_df',
'lexical_richness',
'markov_chain',
'math',
'nlargest',
'normalize',
'num2words',
'random',
're',
'read_txt',
'remove_accents',
'remove_bad_quotes',
'remove_btc_address',
'remove_currencies',
'remove_currency_symbols',
'remove_custom_pattern',
76
'remove_custom_words',
'remove_dates',
'remove_emails',
'remove_emojis',
'remove_hashtags',
'remove_html_tags',
'remove_mastercard_addr',
'remove_md5sha',
'remove_multiple_spaces',
'remove_non_ascii',
'remove_numbers',
'remove_phone_numbers',
'remove_postoffice_box',
'remove_puncts',
'remove_punctuations',
'remove_shortwords',
'remove_special_characters',
'remove_stopwords',
'remove_street_address',
'remove_terms_in_bracket',
'remove_urls',
'remove_userhandles',
'remove_visacard_addr',
'replace_bad_quotes',
77
'replace_currencies',
'replace_currency_symbols',
'replace_dates',
'replace_emails',
'replace_emojis',
'replace_numbers',
'replace_phone_numbers',
'replace_special_characters',
'replace_term',
'replace_urls',
'string',
'term_freq',
'to_txt',
'unicodedata',
'word_freq',
'word_length_freq']
x = df['Clean_Text']
y = df['Emotion']
from sklearn.model_selection import train_test_split
x_train,x_test,y_train,y_test =
train_test_split(x,y,test_size=0.3,random_state=42)
from sklearn.pipeline import Pipeline
78
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.svm import SVC
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
pipe_lr = Pipeline(steps=[('cv',CountVectorizer()),('lr',LogisticRegression())])
pipe_lr.fit(x_train,y_train)
pipe_lr.score(x_test,y_test)
pipe_svm = Pipeline(steps=[('cv',CountVectorizer()),('svc', SVC(kernel = 'rbf', C
= 10))])
pipe_svm.fit(x_train,y_train)
pipe_svm.score(x_test,y_test)
pipe_rf = Pipeline(steps=[('cv',CountVectorizer()),('rf',
RandomForestClassifier(n_estimators=10))])
pipe_rf.fit(x_train,y_train)
pipe_rf.score(x_test,y_test)
import matplotlib.pyplot as plt
from sklearn.metrics import confusion_matrix, roc_curve,
precision_recall_curve
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.datasets import make_classification
# Generate synthetic data for demonstration
X, y = make_classification(n_samples=1000, n_features=20, n_classes=2,
random_state=42)
79
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2,
random_state=42)
# Train a Random Forest classifier
rf_classifier = RandomForestClassifier(n_estimators=100, random_state=42)
rf_classifier.fit(X_train, y_train)
y_pred = rf_classifier.predict(X_test)
# Confusion Matrix
conf_matrix = confusion_matrix(y_test, y_pred)
plt.figure(figsize=(8, 6))
plt.imshow(conf_matrix, cmap='Blues', interpolation='nearest')
plt.title('Confusion Matrix')
plt.colorbar()
plt.xlabel('Predicted Label')
plt.ylabel('True Label')
plt.show()
# ROC Curve
y_proba = rf_classifier.predict_proba(X_test)[:, 1]
fpr, tpr, _ = roc_curve(y_test, y_proba)
plt.figure(figsize=(8, 6))
plt.plot(fpr, tpr, color='blue', lw=2)
plt.plot([0, 1], [0, 1], color='gray', linestyle='--')
80
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('ROC Curve')
plt.show()
# Precision-Recall Curve
precision, recall, _ = precision_recall_curve(y_test, y_proba)
plt.figure(figsize=(8, 6))
plt.plot(recall, precision, color='green', lw=2)
plt.xlabel('Recall')
plt.ylabel('Precision')
plt.title('Precision-Recall Curve')
plt.show()
# Feature Importance Plot (for Random Forest)
plt.figure(figsize=(10, 8))
feat_importances = rf_classifier.feature_importances_
feat_names = [f'Feature {i}' for i in range(X.shape[1])]
plt.barh(feat_names, feat_importances, color='orange')
plt.xlabel('Feature Importance')
plt.ylabel('Feature')
plt.title('Feature Importance Plot (Random Forest)')
plt.show()
81
import joblib
pipeline_file = open("text_emotion.pkl","wb")
joblib.dump(pipe_lr,pipeline_file)
pipeline_file.close()
82
app.py
import streamlit as st
import pandas as pd
import numpy as np
import altair as alt
import os
import joblib
# Get the absolute path to the model file
model_path = r"C:/Users/HP/OneDrive/Desktop/Text-Emotion-Detection-
main/Text-Emotion-Detection-main/Text Emotion
Detection/model/text_emotion.pkl"
# pipe_lr = joblib.load(open("text_emotion.pkl", "rb"))
pipe_lr = joblib.load(model_path)
emotions_emoji_dict = {"anger": " ", "disgust": " ", "fear": " ",
"happy": " ", "joy": " ", "neutral": " ", "sad": " ",
"sadness": " ", "shame": " ", "surprise": " "}
def predict_emotions(docx):
results = pipe_lr.predict([docx])
return results[0]
83
def get_prediction_proba(docx):
results = pipe_lr.predict_proba([docx])
return results
def main():
st.title("Text Emotion Detection")
st.subheader("Detect Emotions In Text")
with st.form(key='my_form'):
raw_text = st.text_area("Type Here")
submit_text = st.form_submit_button(label='Submit')
if submit_text:
col1, col2 = st.columns(2)
prediction = predict_emotions(raw_text)
probability = get_prediction_proba(raw_text)
with col1:
st.success("Original Text")
st.write(raw_text)
84
st.success("Prediction")
emoji_icon = emotions_emoji_dict[prediction]
st.write("{}:{}".format(prediction, emoji_icon))
st.write("Confidence:{}".format(np.max(probability)))
with col2:
st.success("Prediction Probability")
#st.write(probability)
proba_df = pd.DataFrame(probability, columns=pipe_lr.classes_)
#st.write(proba_df.T)
proba_df_clean = proba_df.T.reset_index()
proba_df_clean.columns = ["emotions", "probability"]
fig = alt.Chart(proba_df_clean).mark_bar().encode(x='emotions',
y='probability', color='emotions')
st.altair_chart(fig, use_container_width=True)
if __name__ == '__main__':
main()
85
CONCLUSION
In this project, we embarked on a journey to develop an emotion detection system
using natural language processing and machine learning techniques. Leveraging
Python libraries such as pandas, scikit-learn, and Streamlit, we created an
intuitive user interface that enables users to input text and receive predictions
about the underlying emotions. This interface provides a user-friendly
experience, making the emotion detection system accessible to a wide range of
users.
The implementation of machine learning models, including Logistic Regression,
Support Vector Machine (SVM), and Random Forest, facilitated accurate emotion
classification based on textual inputs. Through rigorous evaluation and
comparison of these models, we gained insights into their performance
characteristics and identified the most suitable approach for emotion detection.
Furthermore, the deployment of the user interface using Streamlit streamlines the
process of making the emotion detection system accessible over the web. By
hosting the application live, we ensure that users can interact with the system
seamlessly, without the need for local installation or setup. This deployment not
only enhances the accessibility of the system but also showcases the integration
of machine learning models into real-world applications.
Looking ahead, there are several avenues for future enhancement and exploration.
Refinements to the user interface, such as incorporating additional features or
visualizations, could enhance the user experience and provide deeper insights into
the emotion detection process. Moreover, continued research and development in
86
machine learning algorithms and techniques may lead to further improvements in
emotion classification accuracy and efficiency.
In conclusion, this project represents a significant step towards the development
of an effective and accessible emotion detection system. By combining the power
of natural language processing, machine learning, and user interface design, we
have created a tool that has the potential to impact various domains, including
sentiment analysis, social media monitoring, and customer feedback analysis. As
we continue to refine and expand upon this foundation, we move closer to
realizing the vision of intelligent systems capable of understanding and
responding to human emotions in real-time.
87
FUTURE ENHANCEMENTS
1. Integration of Advanced Deep Learning Models: Explore state-of-the-art deep
learning architectures such as Transformer-based models (e.g., BERT, GPT) for
more effective representation learning and emotion detection.
2. Multimodal Emotion Detection: Investigate the integration of multimodal data
sources (e.g., text, images, audio) to capture richer emotional cues and improve
overall detection performance.
3. Continuous Model Refinement: Continuously update and refine the models
based on new datasets, advancements in natural language processing, and user
feedback to ensure optimal performance.
4. Real-time Emotion Analysis: Develop mechanisms for real-time emotion
analysis to enable applications such as live chat sentiment analysis and social
media monitoring.
5. Interpretability and Explainability: Enhance the interpretability and
explainability of the models to provide users with insights into how emotions are
detected and categorized in textual data.
6. Scalability and Deployment: Optimize the system for scalability and deploy it
on cloud platforms to handle large-scale data processing and accommodate
growing user demand
88
REFERNECE
[1]Ab Nasir AF et al (2020) Text-based emotion prediction system using
machine learning approach. IOP Conf Ser Mater Sci Eng 769.
[2]Chowanda A, Sutoyo R, Tanachutiwat S (2021) Exploring text-based
emotions recognition machine learning techniques on social media
conversation. Procedia Comput Sci 179:821–828
[3]Z F ZHANG, Deep learning based methods research on scene text detection
and recognition[D], Shen zhen : University of Chinese Academy of Sciences,
2020.
[4]Liao Minghui et al., "Real-Time Scene Text Detection with Differentiable
Binarization and Adaptive Scale Fusion", IEEE transactions on pattern analysis
and machine intelligence, 2022.
[5]Z. Tian, W. Huang, T. He, P. He and Y. Qiao, "Detecting text in natural image
with connectionist text proposal network", Proc. ECCV, pp. 56-72, 2016.
[6]D. Peng et al., "Recognition of handwritten Chinese text by segmentation: A
segment-annotationfree approach", IEEE Trans. Multimedia, Jan. 2022.
[7]Ramalingam VV, Pandian A, Jaiswal A, Bhatia N (2018) Emotion detection
from text. J Phys Conf Ser 1000
[8]Gupta U, Chatterjee A, Srikanth R, Agrawal P (2017) A sentiment-and-
semantics-based approach for emotion detection in textual conversations. In:
Proceedings of Neu-IR 2017 SIGIR workshop neural information retrieval,
Shinjuku, Tokyo, Japan, 11 Aug 2017 (Neu-IR ’17), 6 p
89
[9]Arya P, Jain S (2018) Text based emotion detection. Int J Comput Eng Technol
9:95–104
[10]Seyeditabari A, Tabari N, Gholizadeh S, Zadrozny W (2019) Emotion
detection in text: focusing on latent representation.
[11]Pamnani A, Goel R, Choudhari J, Singh M (2019) IIT Gandhinagar at
SemEval-2019 task 3: contextual emotion detection using deep learning. In:
Proceedings of 13th international workshop semantics evaluation (SemEval-
2019), Minneapolis, Minnesota, USA, June 6–7, 236–240.
[12]Salam SA, Gupta R (2018) Emotion detection and recognition from text
using machine learning. Int J Comput Sci Eng 6:341–345
[13]Al-Omari H, Abdullah M, Bassam N (2019) EmoDet at SemEval-2019 task
3: emotion detection in text using deep learning. In: Proceedings of 13th
international workshop semantics evaluation (SemEval-2019), Minneapolis,
Minnesota, USA, June 6–7, pp 200–204.
[14]Liu P, Du C, Zhao S, Zhu C (2019) Emotion action detection and emotion
inference: the task and dataset.
[15]Gaonkar R, Kwon H, Bastan M, Balasubramanian N, Chambers N (2020)
Modeling label semantics for predicting emotional reactions. In: Proceedings of
58th annual meeting association of computing linguistics, 4687–4692.
[16]Haryadi D, Kusuma GP (2019) Emotion detection in text using nested long
short-term memory. Int J Adv Comput Sci Appl 10:351–357
[17]Yasmina D, Hajar M, Hassan AM (2016) Using YouTube comments for text-
based emotion recognition. Procedia Comput Sci 83:292–299
90
[18]Huang X et al (2021) Emotion detection for conversations based on
reinforcement learning framework. IEEE Multimed 28:76–85
[19]Vijayvergia A, Kumar K (2021) Selective shallow models strength
integration for emotion detection using GloVe and LSTM. Multimed Tools Appl
80:28349–28363
[20]Lee J, Jatowt A, Kim KS (2021) Discovering underlying sensations of human
emotions based on social media. J Assoc Inf Sci Technol 72:417–43
[21]Balakrishnan V, Lok PY, Abdul Rahim H (2021) A semi-supervised
approach in detecting sentiment and emotion based on digital payment reviews.
J Supercomput 77:3795–3810
[22]Madhuri S, Lakshmi SV (2021) Detecting emotion from natural language text
using hybrid and NLP pre-trained models. Turkish J Comput Math Educ
12:4095–4103
[23]Kumar B, Suresh Kumar S, Janaki V (2021) Neural network based emotion
recognition model in Twitter text data. SSRN Electron J.
[24]Seal D, Roy UK, Basak R (2020) Sentence-level emotion detection from text
based on semantic rules. In: Advances in intelligent systems and computing, vol
933. Springer, Singapore
[25]Chowanda A, Sutoyo R, Tanachutiwat S (2021) Exploring text-based
emotions recognition machine learning techniques on social media conversation.
Procedia Comput Sci 179:821–828
[26]Chiorrini A, Diamantini C, Mircoli A, Potena D (2021) Emotion and
sentiment analysis of tweets using BERT. In: CEUR workshop proceedings, vol
2841
91
[27]Deshpande A, Paswan R (2020) Real-time emotion recognition of twitter
posts using a hybrid approach. ICTACT J Soft Comput 6956:2125–2133
[28]Suhasini M, Srinivasu B (2020) Emotion detection framework for twitter data
using supervised classifiers. Springer, Singapore, 565–576.
[29]Gupta U, Chatterjee A, Srikanth R, Agrawal P (2017) A sentiment-and-
semantics-based approach for emotion detection in textual conversations. arXiv
preprint
92