0% found this document useful (0 votes)
355 views49 pages

Sentiment Analysis

Uploaded by

Mr Ghost
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
355 views49 pages

Sentiment Analysis

Uploaded by

Mr Ghost
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

PREDICTING STOCK MARKET MOVEMENT BY

ANALYZING SENTIMENT IN NEWS HEADLINES


A Major Project Report Submitted in Partial Fulfillment for the Award of the Degree of
Bachelor of Technology in Computer Science and Engineering/Information Technology

Submitted to

Dr. A.P.J. ABDUL KALAM TECHNICAL UNIVERSITY, LUCKNOW

Submitted by:
Siddhant Mishra (2000100100174)
Saumya Pandey (2000100100158)
Ritika Singh (2000100100146)

UNDER THE SUPERVISION OF


Mr. Rajeev Dixit
Assistant Professor

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


UNITED COLLEGE OF ENGINEERING AND RESEARCH, PRAYAGRAJ
MAY 2024

1
CANDIDATE’S DECLARATION

We hereby certify that the project entitled “Predicting stock market movements by analyzing sentiment in
news headlines.” submitted by us in partial fulfillment of the requirement for the award of the degree of B.
Tech (Computer Science & Engineering) submitted to Dr. A.P.J. Abdul Kalam Technical University,
Lucknow, at United College of Engineering and Research, Prayagraj is an authentic record of our own
work carried out during a period from June 2023 to May 2024 under the guidance of Mr. Rajeev Dixit
(Assistant Professor, Department of Computer Science & Engineering). The matter presented in this
project has not formed the basis for the award of any other degree, diploma, fellowship, or any other
similar title.

Siddhant Mishra
(2000100100174)

Saumya Pandey
(2000100100158)

Ritika Singh
( 2000100100146)

Place: Prayagraj
Date:

2
CERTIFICATE

This is to certify that the project is titled “Predicting stock market movement by analyzing sentiment in
news headlines.” is the bona fide work carried out by Siddhant Mishra (2000100100174) ,Saumya Pandey
(2000100100158) and Ritika Singh (2000100100146) in partial fulfillment of the requirement for the
award of the degree of the B. Tech. (Computer Science & Engineering) submitted to Dr. A.P.J Abdul
Kalam Technical University, Lucknow at United College of Engineering and Research, Prayagraj is an
authentic record of their own work carried out during a period from June, 2023 to May, 2024 under the
guidance of Mr. Rajeev Dixit (Assistant Professor, Department of Computer Science & Engineering). The
Major Project Viva-Voce Examination has been held on __________________.

Signature of the Guide _________________________________


[Mr. Rajeev Dixit]

Signature of Project Coordinator ________________________


[Mr. Shyam Bahadur Verma]

Signature of the Head of Department _____________________


[Dr. Vijay Kumar Dwivedi]

Place: Prayagraj
Date:

3
ABSTRACT

This final-year project report delves into the intricacies of predicting stock market movement by analyzing
sentiment in news headlines. It marks the culmination of a journey that began with sourcing a dataset from
Kaggle, meticulously followed by rigorous data cleaning and training procedures to ensure the data's
readiness for analysis.

Our project aims to help people predict stock market movements using sentiment analysis in the news.

This involves using natural language processing (NLP) techniques to analyze the sentiment of news
(positive, negative, or neutral) related to the stock market in general.

By gauging the sentiment expressed in these news headlines, we aim to develop a predictive model that
can potentially provide insights into future movements.

The idea is to make a model using Python, Machine Learning (Natural Language Processing ) and other
methodologies.

Unravel Sentiment-stock Relationship: The project uncovers insights into the relationship between news
sentiment and stock market movements. This could include identifying periods when sentiment strongly
affects price movements and periods when it doesn't.

Visualization of Results: Demonstrate the model's performance on the basis of sentiment. These
visualizations can help convey the effectiveness of the model to stakeholders.

Our report dives deep into the methodology behind our project, shedding light on the hurdles we
encountered and the strategies we employed to surmount them. Moreover, we meticulously dissect the
performance of our model, showcasing its accuracy.

4
ACKNOWLEDGEMENT

We express our sincere gratitude to Dr. A.P.J. Abdul Kalam Technical University, Lucknow, for giving us
the opportunity to work on the major project during our final year of B.Tech. (CSE), which is an important
aspect in the field of engineering.

We would like to thank Prof. H.P. Shukla, Principal, and Dr. Vijay Kumar Dwivedi, Head of Department,
CSE, at the United College of Engineering and Research, Prayagraj, for their kind support.

We also owe our sincerest gratitude to Mr. Rajeev Dixit for his valuable advice and healthy criticism
throughout our project, which helped us immensely to complete our work successfully.

We would also like to thank everyone who has knowingly and unknowingly helped us throughout our
work. Last but not least, a word of thanks to the authors of all those books and papers that we have
consulted during our project work as well as for preparing the report.

5
List of Figures

S. No Figure Caption Page No.

0 Gantt Chart 7

Framework for Predicting Stock Movement


1.1 13
How Machine Learning Works
1.2 16
LSTM Model
1.3 17

2.1 Flow Chart 30

2.2 LSTM layers Flow Chart 31

2.3 0-Level Data Flow Diagram 31

2.4 1-Level Data Flow Diagram 32

2.5 2-level Data Flow Diagram 32

3.5 Testing (Fig 3.5.1, 3.5.2 and 3.5.3) 39,40

4.1 Output 42

7.1 Plagiarism Report 50

6
Gantt Chart

Fig.0 Gantt Chart

7
CONTENTS

TITLE PAGE i
Declaration ii
CERTIFICATE iii
ABSTRACT iv
ACKNOWLEDGEMENT v
List of Figures vi
Gantt Chart vii
Content viii

CHAPTER 1 - Introduction:
1.1 Problem Definition 10

1.2 Project Overview/Specifications 11


1.3 Hardware Specification 18
1.4 Software Specification 19

CHAPTER 2 - LITERATURE REVIEW: 20


2.1 EXISTING SYSTEM 22
2.2 PROPOSED SYSTEM 22
2.3 FEASIBILITY STUDY 23

CHAPTER 3 - SYSTEM ANALYSIS & DESIGN:


3.1 Requirement Specification 26
3.2 Diagrams 29
1. Flow Chart 29
2. LSTM Layers Flow Chart 30
3. 0-Level Data Flow Diagram 30
8
4. 1-Level Data Flow Diagram 31
5. 2- Level Data Flow Diagram 31
3.3 Design and Test Steps / Criteria 32
3.4 Algorithms 34
1. Data Processing Algorithm 34
2. Long Term Short Memory Algorithm 35
3. Optimization Algorithm 37
4. Regularization Algorithm 37
3.5 Testing Process (Test Cases to be included) 38

CHAPTER 4 -RESULT/OUTPUT 40

CHAPTER 5 - CONCLUSION/RECOMMENDATION 42

CHAPTER 6 - REFERENCES 45

CHAPTER 7 -Appendices 46

Plagiarism Report 49

9
CHAPTER I

INTRODUCTION

1.1 Problem Definition:


The objective of this project is to empower investors with a tool that leverages sentiment analysis of
financial news headlines to predict stock market movements. In today's dynamic and interconnected
financial landscape, where news spreads rapidly and influences market sentiment, it's crucial for investors
to have access to tools that can analyze and interpret the vast amount of textual data available. By
harnessing the power of natural language processing (NLP) techniques, we aim to extract valuable insights
from news headlines and integrate them into a machine learning model for predicting stock price
movements.

The challenge at hand is multifaceted. Firstly, we need to preprocess the textual data effectively to remove
noise, handle outliers, and extract relevant information. This involves techniques such as tokenization,
removing stop words, stemming, and possibly entity recognition to identify key entities such as company
names and financial indicators. Additionally, we must address the inherent ambiguity and subjectivity
present in natural language, ensuring that our sentiment analysis accurately captures the nuanced emotions
expressed in financial news.

Next, we need to design an appropriate deep learning architecture that can effectively learn from the
sequential nature of textual data. LSTM (Long Short-Term Memory) networks, known for their ability to
capture long-range dependencies in sequential data, are a natural choice for modeling textual data.
However, we must carefully tune the architecture and hyperparameters to avoid overfitting and
underfitting.

Training the model on historical data poses its own set of challenges. We need to curate a comprehensive
dataset of financial news headlines. This dataset should span a significant time period and cover diverse
market conditions to ensure the model learns robust patterns and trends. Furthermore, we must consider the
impact of external factors such as macroeconomic indicators, geopolitical events, and market sentiment.

10
Finally, evaluating the model's performance requires careful consideration. Traditional metrics may not be
sufficient in this context, as predicting stock market movements is inherently challenging and subject to
noise. Instead, we may employ metrics such as accuracy to assess the model's ability to correctly predict
upward and downward movements in stock prices.

By successfully addressing these challenges, our ultimate goal is to build a reliable predictive tool that can
assist investors in making more informed decisions. By integrating sentiment analysis of financial news
headlines into their trading strategies, investors can gain valuable insights into market sentiment.

1.2 Project Overview:

This project endeavors to harness the power of sentiment analysis techniques applied to a diverse array of
textual data sources for news headlines to predict the movements of the stock market. In today's data-rich
environment, where information flows incessantly from various channels, deciphering the sentiment
embedded within textual data holds immense potential for uncovering valuable insights into market
dynamics.

At the core of this initiative lies the quantification of sentiment polarity and strength within the collected
textual data. By employing natural language processing (NLP) techniques, we aim to extract nuanced
sentiments expressed in news articles, social media conversations, and financial reports. This involves not
only identifying positive, negative, and neutral sentiments but also gauging the intensity and context of the
emotions conveyed, allowing for a more nuanced understanding of market sentiment.

Through meticulous analysis of sentiment trends over time, we seek to unveil patterns and correlations
between sentiment dynamics and stock market movements. By leveraging advanced machine learning
algorithms, including but not limited to deep learning models such as recurrent neural networks (RNNs)
and transformers, we aim to develop predictive models that can seamlessly integrate sentiment signals.
These models will be trained on vast datasets spanning diverse market conditions, ensuring robustness and
adaptability across different market scenarios.

The predictive models generated through this project will not only forecast future stock price trajectories
but also provide insights into the underlying drivers of market sentiment. By discerning the collective
mood of market participants reflected in textual data, investors and traders can gain a deeper understanding
of market dynamics and anticipate potential shifts in sentiment. Armed with these insights, they can make
more informed decisions, whether it's identifying investment opportunities, managing risks, or optimizing
trading strategies.

11
Moreover, this endeavor aims to democratize access to market sentiment analysis, making it accessible to a
broader audience of investors and traders. Through a user-friendly interface and interactive visualization
tools, we aim to empower individuals with actionable insights derived from sentiment analysis, enabling
them to navigate the complexities of the stock market with greater confidence and precision.

In summary, this project represents a convergence of technologies, including NLP, machine learning, and
data analytics, to unlock the predictive power of sentiment analysis in forecasting stock price movements.
By bridging the gap between textual data and market dynamics, we aspire to revolutionize
decision-making in the realm of financial markets, ushering in a new era of data-driven insights and
informed investment strategies.

1.2.1 What are Stocks


Stocks, often referred to as equities or shares, are foundational instruments in the realm of finance,
embodying ownership stakes in companies and granting shareholders rights to a portion of the company's
assets and profits. Traded on various stock exchanges globally, their values are subject to the ebb and flow
of market forces, shaped by a myriad of factors spanning from macroeconomic trends to individual
investor sentiments.

The allure of investing in stocks lies in the potential for two primary forms of returns: capital appreciation
and dividend income.
Capital appreciation occurs when the market value of a stock increases over time, allowing investors to
profit from the spread between their purchase and sale prices.
Dividend income, on the other hand, represents a share of the company's profits distributed periodically to
shareholders, providing a steady stream of income irrespective of stock price fluctuations.

However, the pursuit of these returns is not without its perils. Investing in stocks carries inherent risks,
ranging from market volatility and economic downturns to company-specific challenges and unforeseen
events. The possibility of losing the principal investment looms over every stock transaction, underscoring
the importance of prudent risk management and informed decision-making.

Despite these risks, stocks remain indispensable components of financial markets, serving as vital conduits
for capital allocation, wealth creation, and economic growth. They offer investors a diverse array of
opportunities to participate in the success stories of companies across various industries and sectors, from
technology and healthcare to finance and consumer goods.

12
Moreover, stocks play a pivotal role in fostering innovation, entrepreneurship, and corporate governance.
By providing companies with access to capital, stocks enable them to finance expansion initiatives,
research and development endeavors, and strategic acquisitions. Additionally, the presence of shareholders
incentivizes management teams to act in the best interests of the company and its stakeholders, promoting
transparency, accountability, and long-term value creation.

In essence, stocks represent more than mere financial instruments; they embody the aspirations,
achievements, and aspirations of businesses and investors alike, weaving together the fabric of the global
economy and shaping the trajectory of financial markets for generations to come.

Fig1.1 Framework for Predicting Stock Movement

The value of stocks in the real world is determined by a complex interplay of market dynamics, investor
sentiment, and fundamental factors like company performance and economic conditions.

Stock prices fluctuate based on factors such as revenue growth, GDP growth, and industry trends,
influenced by news events and market sentiment. Understanding these dynamics is crucial for investors
navigating the financial markets.

Overall, stocks are a key component of the financial markets, providing investors with opportunities to
participate in the growth and profitability of companies across various sectors and industries.

1.2.2 Types of Stocks

Stocks can be classified into various types based on different criteria. Here are some common types of
stocks:

1. Common Stock: represents ownership in a company with voting rights at shareholders' meetings.
Owners of common stock are entitled to a share of the company's profits, typically through
dividends, and may benefit from capital appreciation if the stock price increases.

13
2. Preferred Stock: This class of stock typically offers investors higher priority for dividends and
assets than common stockholders. Preferred shareholders often receive fixed dividends but usually
do not have voting rights in company decisions.
3. Blue-Chip Stocks: These are shares of well-established companies with a reputation for stable
earnings and reliable performance. Blue-chip stocks are often considered less risky than others and
are favored by conservative investors seeking long-term growth and income.
4. Growth Stocks: Growth stocks belong to companies expected to grow at a faster rate than the
overall market. While they may not offer dividends, investors are attracted to them for their
potential for significant capital appreciation over time.
5. Value Stocks: Value stocks are those believed to be trading at a lower price relative to their
intrinsic value. Investors in value stocks typically seek companies that are undervalued by the
market and have strong fundamentals, such as low price-to-earnings ratios or high dividend yields.
6. Income Stocks: Income stocks are shares of companies that consistently pay dividends to their
shareholders. These stocks are often favored by income-oriented investors seeking regular cash
flow from their investments.
7. Small-Cap, Mid-Cap, and Large-Cap Stocks: These classifications are based on the market
capitalization of the issuing company.

Small-cap stocks represent smaller companies with market capitalizations typically below $2
billion. Mid-cap stocks are those of medium-sized companies, usually valued between $2 billion
and $10 billion.

Large-cap stocks belong to well-established companies with market capitalizations typically


exceeding $10 billion. Each category presents different levels of risk and growth potential for
investors.

1.2.3 Ways of Stock Trading


Two of the most common trading types in the Indian stock market are:

1. Intraday: This strategy involves buying and selling shares on the same trading day. Intraday
traders aim to capitalize on short-term price movements, often leveraging technical analysis and
market trends to make quick buying and selling decisions. One of the key features of intraday
trading is that positions are not held overnight, meaning there is no transfer of shares to the
investor's Demat account. Instead, trades are settled on the same day, and any profits or losses are

14
realized by the end of the trading session. It's essential for intraday traders to monitor market
movements closely and adhere to strict risk management practices to mitigate potential losses.
Additionally, if a position is not closed before the market closes or expires, brokers may
automatically square it off, usually incurring a fee.

2. Delivery: Unlike intraday trading, delivery trading involves purchasing stocks with the intention of
holding them for an extended period, ranging from days to years. When investors buy stocks in
delivery trades, the shares are transferred to their Demat accounts and remain in their possession
until they choose to sell them. This approach is typically favored by long-term investors who seek
to profit from the potential appreciation of stock prices over time or who prioritize receiving
dividends from their investments. Delivery trading allows investors to take advantage of
fundamental analysis and company performance metrics to make informed investment decisions.
Unlike intraday trading, there is no pressure to close positions within the same trading day,
providing investors with greater flexibility and a reduced trading frequency.

1.2.4 Machine Learning


Machine learning, a branch of artificial intelligence, revolutionizes the way computers process information
and make decisions by enabling them to learn from data without explicit programming. Through the
analysis of vast datasets, machine learning algorithms identify patterns, correlations, and insights that
humans may overlook, thereby facilitating predictions and informed decision-making.

Supervised learning, a fundamental approach in machine learning, involves training models on labeled
datasets, where the correct output is provided for each input. These models learn to generalize from the
provided examples, enabling them to make predictions or classifications based on new, unseen data.

Conversely, unsupervised learning algorithms work with unlabeled data, aiming to identify inherent
structures or patterns without predefined categories. This type of learning is particularly useful for tasks
such as clustering.

Reinforcement learning introduces a dynamic element to machine learning, wherein agents learn through
trial and error by interacting with an environment. Through a process of exploration and exploitation, these
agents optimize their actions to maximize cumulative rewards, making reinforcement learning suitable for
tasks like game playing, robotics, and autonomous systems.

The versatility of machine learning extends across various industries and domains, with applications
ranging from healthcare to finance, marketing, and beyond. For instance, in healthcare, machine learning
15
algorithms analyze medical records and imaging data to assist in disease diagnosis and treatment planning.
In finance, these algorithms facilitate fraud detection, risk assessment, and algorithmic trading. Marketing
benefits from machine learning through personalized recommendations, targeted advertising, and customer
segmentation.

In essence, machine learning reshapes data analysis, decision-making, and problem-solving paradigms,
empowering computers to tackle intricate tasks that were once considered beyond their capabilities. As the
field continues to evolve, its potential for driving innovation and addressing societal challenges remains
boundless.

Fig 1.2 How Machine Learning Works

1.2.5 Long Short Term Memory (LSTM)

LSTM, or Long Short-Term Memory, represents a specialized architecture within recurrent neural
networks (RNNs). Unlike traditional RNNs, LSTM networks excel at capturing long-range dependencies
and maintaining information over extended time intervals. This capability is crucial for understanding
sequential data, such as text, where context plays a significant role.

The essence of LSTM lies in its unique structure, consisting of different layers designed to regulate the
flow of information. These layers include the input gate, forget gate, output gate, and memory cell, each
16
serving a distinct purpose in managing the flow of information through the network.

By strategically controlling the flow of information, LSTM networks can selectively retain or discard
information from previous time steps, allowing them to effectively capture patterns and dependencies in
sequential data. This ability makes LSTMs particularly well-suited for tasks such as natural language
processing, time series prediction, and speech recognition, where understanding long-range dependencies
is critical for achieving high performance.

Fig 1.3 LSTM Model

17
1.3 Hardware Specifications

Processor: Intel Core i5-10300H ( 2.50 GHz ) with Nvidia GeForce GTX 1650
Installed RAM: 8.00 GB (5.88 GB usable)
System Type: 64-bit operating system, x64-based processor
Operating System: Windows 11 Home Single Language, Version 23H2, OS build 22631.3527
Experience: Windows Feature Experience Pack

18
1.4 Software Specifications

1.4.1 Dataset Platform:


Kaggle: Utilized for accessing and sourcing datasets relevant to the project's objectives.

1.4.2 Machine Learning Development Platform:


Google Colab: Employed for testing and executing machine learning code. It provides a cloud-based
environment with GPU support, facilitating efficient model training and experimentation.

1.4.3 Application to process dataset files:


Google Sheets/Excel: Google Sheets is a web-based application that enables users to create,
update, and modify datasets in CSV (comma separated Values) files and share the data online in
real time.

1.4.4 Integrated Development Environment (IDE) for Frontend Development:


Visual Studio Code (VSCode): Utilized for creating the form interface using HTML, CSS, and
JavaScript. VSCode offers a lightweight yet powerful environment with robust features for web
development.

1.4.5 Web Browsers:


Chrome and Brave: Used to visualize and use our machine learning model. Both Chrome and Brave are
modern web browsers known for their speed, security, and compatibility with web technologies.

19
CHAPTER II
LITERATURE SURVEY

Financial markets are renowned for their inherent volatility, which presents investors with a significant
degree of uncertainty and risk. In response to this challenge, this paper introduces a novel approach by
leveraging Long Short-Term Memory (LSTM) and sentiment analysis models to predict the impact of
news headlines on market movements.

The proposed methodology harnesses the power of LSTM networks, a specialized architecture within
recurrent neural networks (RNNs), renowned for their ability to capture long-range dependencies in
sequential data. By employing LSTM, the model can effectively process and analyze historical data,
enabling it to discern intricate patterns and relationships that influence market dynamics.

Through the synergistic combination of LSTM and sentiment analysis, this approach offers a robust
methodology for forecasting market behavior, enabling investors to make more informed decisions.

Research Paper Methodology Author Result


S.No.

1. Forecasting Stock Market Support Vector Ren, Wu, and Liu Achieved up to
Movement Direction Machine and user- (2018) 89.93%
Using generated Internet accuracy in
Sentiment Analysis and content (e.g., forecasting the
Support Vector Machine tweets) movement
direction after
introducing
sentiment
variables.

2. Analysis of Stock Price LSTM S. Sabarinath LSTM model


Prediction Using ML (IJRASET) with 87%
Techniques

3. Stock Trend Prediction Random forest, Naive Kalyani Joshi 95.8% for
System using News Bayes and SVM SVM Model
Sentiment Analysis

20
4. Stock Price Movement CountVectorizer and Ronil Patil 85.1%
Based On News Headline Random Forest

5. Analyzing Stock Price Natural Language Toolkit Sahaj Sentiment


News Sentiment with Godhani Prediction model
Machine Learning using NLTK

6. Sentiment Analysis for Random Forest James Briggs 91%


Stock Price Prediction accuracy

7. Stock Sentiment Analysis LSTM Krish C Naik 84.13%

8. Stock market prediction Machine Learning, Khan et al. The study


using machine learning Deep Learning, (2020) achieved
classifiers and social Feature Selection, prediction
media news Spam Tweet accuracies up to
Reduction, 80.53% with
Ensemble social media data
Classifiers. and 75.16%
with financial
news.

These are the list of papers we referenced and comparative summary of Machine Learning and Sentiment
Analysis in financial market prediction literature

21
2.1 Existing System:

Predicting stock market movements using sentiment analysis on news headlines is not only a fascinating
area of research but also one that holds immense practical significance in financial markets. The ability to
gauge market sentiment from textual data and use it to forecast stock market fluctuations can provide
investors and traders with a valuable edge in decision-making.

Historically, traditional statistical methods relied heavily on manual analysis or rule-based systems to
interpret sentiment from news headlines.

However, these approaches were often limited in scalability and struggled to capture the nuances of
sentiment accurately. With the advent of machine learning, particularly supervised learning models like
Random Forest, sentiment analysis has seen significant advancements. These models can effectively
classify news headlines into positive, negative, or neutral sentiments by learning from labeled data, thus
offering more scalable and accurate solutions.

Despite these advancements, challenges persist in accurately predicting stock market movements using
sentiment analysis. Issues such as data quality, including noise or bias in news data, pose significant
hurdles. Additionally, the inherent unpredictability of financial markets adds another layer of complexity to
the task.

Looking forward, future research directions may involve exploring more advanced deep learning
techniques, such as attention mechanisms and reinforcement learning, to further enhance the accuracy of
sentiment analysis. Moreover, integrating external factors like market indicators, economic data, and
geopolitical events could provide additional context and improve the predictive capabilities of models.

Given the interdisciplinary nature of this field, collaborations between experts in finance, natural language
processing, and machine learning will be essential.

2.2 Proposed System:


To extend the application potential of our existing system, we aim to leverage its capabilities for analyzing
sentiment within news articles, a critical factor influencing stock market trends.

Our proposed system for predicting stock market movements through sentiment analysis of news headlines
represents a significant advancement over current methodologies. It not only addresses the limitations of
existing approaches but also integrates recent advancements in machine learning and natural language

22
processing.

At the core of our proposed system lies the utilization of advanced sentiment analysis techniques and
sophisticated learning architectures, notably Long Short-Term Memory (LSTM). These models excel at
capturing the nuanced linguistic subtleties present in news headlines. By harnessing such capabilities, our
system endeavors to discern subtle sentiment patterns more accurately, thereby enhancing its efficacy.

Crucially, our system prioritizes model interpretability, ensuring that users can comprehend the underlying
rationale behind predictions. This transparency empowers users to make well-informed decisions based on
the insights provided by the model, thereby enhancing its practical utility.

In essence, our proposed system offers a comprehensive and adaptable approach to stock market
prediction. Through the integration of advanced sentiment analysis techniques and the incorporation of
diverse data sources, it aims to furnish actionable insights that facilitate informed decision-making in
financial markets.

Moreover, our system's versatility enables seamless extension into the analysis of specific factors such as
company performance, economic indicators, and political developments. By incorporating additional
contextual elements, the system can provide a more holistic understanding of the multifaceted factors
influencing stock market dynamics, thereby enriching its predictive capabilities and value proposition for
stakeholders.

2.3 Feasibility Study

2.3.1 Technical Feasibility

The technical feasibility of implementing the proposed project on Predicting stock market movement by
analyzing sentiment in news headlines using Long Short-Term Memory (LSTM) is deeply rooted in the
availability of robust and well-established technologies. The project's foundation rests upon mature
machine learning libraries such as Pandas, TextBlob, NLTK (Natural Language Toolkit), Keras, and
Scikit-learn, all of which are readily accessible within the Python ecosystem. These libraries offer a rich set
of tools and functionalities for data preprocessing, sentiment analysis, and LSTM model development,
making the implementation process not only feasible but also highly efficient.

The choice of Python as the primary programming language further enhances the project's technical
feasibility. Python is renowned for its simplicity, versatility, and extensive library support, making it a
preferred language for data science and machine learning tasks. Moreover, the availability of
23
comprehensive documentation, numerous tutorials, and vibrant online communities ensures that
developers have access to ample resources and support to overcome any technical challenges encountered
during implementation.

In addition to backend technologies, the project's frontend interface creation is facilitated by the use of
HTML, CSS, and JavaScript. These web development technologies provide a flexible and intuitive
platform for designing user-friendly interfaces that interact seamlessly with the underlying machine
learning models. With a plethora of frontend frameworks and libraries available, developers have the
freedom to choose the most suitable tools for crafting engaging and responsive user interfaces.

Overall, the technical feasibility of the proposed project is underpinned by the wealth of accessible
resources, the maturity of the chosen technologies, and the robustness of the selected methodologies. By
leveraging these tools effectively, the project stands poised to deliver valuable insights into anomaly
detection through sentiment analysis, thereby contributing to advancements in the field of data-driven
decision-making.

2.3.2 Economic Feasibility


Economic feasibility is a critical aspect to consider, particularly for us students who have limited financial
resources. The project's viability is greatly enhanced by leveraging open-source tools and frameworks,
which significantly reduce the cost of software licenses. By utilizing Python along with libraries like
Pandas, TextBlob, NLTK, Keras, and Scikit-learn, all of which are open-source projects, the need for
expensive proprietary software is eliminated, making the project economically feasible for students. This
accessibility to free and open tools ensures that financial constraints do not impede the project's
development and implementation.

Moreover, the availability of Kaggle datasets for training the machine learning model further minimizes
costs associated with data acquisition. Kaggle provides a vast repository of high-quality datasets across
various domains, allowing students to access relevant data without incurring additional expenses. This
accessibility to data facilitates robust model training and validation processes without the need for costly
data procurement.

Overall, the project maintains a high level of economic feasibility by capitalizing on open-source resources
and minimizing expenses related to software licenses and data acquisition. This affordability makes the
project accessible to students with budget constraints, enabling them to pursue innovative research and
gain valuable experience in data science and machine learning fields without financial barriers.

24
2.3.3 Operational Feasibility

Operational feasibility evaluates how well a project aligns with existing operational processes and
workflows, especially within the financial sector. The proposed system, which centers on sentiment
analysis of news headlines, integrates seamlessly with industry practices and standards. Leveraging
machine learning techniques, the system provides a scalable and efficient solution for predicting stock
movements, addressing a critical need within the financial sector. Consequently, from an operational
standpoint, the project exhibits high feasibility and compatibility with industry requirements.

Moreover, the proposed system offers several operational advantages. Firstly, it automates the process of
analyzing news sentiment, reducing manual effort and potential errors associated with human
interpretation. This automation streamlines workflow processes, enabling financial professionals to focus
on higher-value tasks such as strategic decision-making.

Secondly, the scalability of the system allows it to accommodate varying volumes of news data, ensuring
robust performance even during periods of heightened market activity. This scalability is essential for
handling the dynamic and unpredictable nature of financial markets, where large volumes of news can
impact stock movements within short timeframes.

Furthermore, the system's ability to provide timely insights into market sentiment enhances
decision-making agility. By promptly identifying sentiment trends in news headlines, financial
professionals can adjust their investment strategies and risk management approaches in response to
changing market conditions.

Overall, the proposed system meets operational feasibility requirements within the financial sector. Its
seamless integration with industry practices, scalability, automation capabilities, and timely insights make
it a valuable asset for financial institutions seeking to leverage technology for informed decision-making
and risk management.

25
CHAPTER III
SYSTEM ANALYSIS AND DESIGN

3.1 Requirement Specifications

3.1.1 Functional Requirements:

Data cleaning and normalization:


● The system must preprocess the Kaggle dataset, handling missing values, outliers, and padding
numerical features to ensure data quality.
● Preprocessing the text data, including tokenization, removing stopwords, and stemming.

Handling User Input:


● The system should handle the provided dataset without making any changes that are not defined by
the user, except for the preprocessing.

Building an LSTM model architecture for sentiment analysis:


● Building an LSTM model architecture for sentiment analysis.
● Training the model on the preprocessed data.
● The system should load the pre-trained Long Short Term Memory model alongside the dataset to
enable the classification of headlines for sentiment analysis.

Result Display:
● Evaluating the model's performance using accuracy, confusion matrix, and classification report.
● Visualizing the confusion matrix.

3.1.2 Non-Functional Requirements:

Performance:

26
● The system should efficiently process user input and deliver classification results promptly,
ensuring a responsive user experience.
Accuracy:
● The machine learning model must exhibit high accuracy while minimizing false positives to
enhance trust and reliability.
Security:
● Robust security measures should be implemented to safeguard user data ensuring confidentiality
and integrity.
Scalability:
● The system must be designed to handle a growing volume of datasets without compromising
performance or accuracy, ensuring scalability for future demands.
Usability:
● Interpretability should be easy, allowing users to input datasets effortlessly and comprehend
classification results with clarity.
Maintainability:
● The system's codebase should be well-documented and modularly designed to facilitate future
updates, enhancements, and maintenance tasks, ensuring long-term sustainability.

3.1.3 Data Requirements:

Dataset:
● Access to a comprehensive dataset containing News headlines related to the stock market for some
given period of time with relevant features such as Date, Description, and Label is essential for
training the machine learning model.

Training Data:
● A subset of the dataset will be utilized for training the machine learning model, while the remaining
data will serve for testing and validation purposes to ensure model accuracy and generalization.
Data Preprocessing:
● Prior to model training, the system must perform rigorous data cleaning and normalization
procedures to ensure the dataset's quality and consistency, thereby enhancing the effectiveness of
the machine learning model.

27
3.1.4 Technical Requirements:

Python
● The code is written in Python, leveraging its ecosystem for data analysis, natural
language processing, and machine learning.
Pandas
● Used for reading and manipulating the CSV data, as well as organizing it into
DataFrames.
TextBlob
● Utilized for sentiment analysis and text processing tasks.
NLTK (Natural Language Toolkit)
● Provides tools and resources for text processing, including tokenization, stopwords
removal, and stemming.
Keras
● A high-level neural networks API, used here for building and training the LSTM
model.
Scikit-learn
● Provides utilities for preprocessing data, splitting datasets, and evaluating model
performance.
Matplotlib and Seaborn
● Used for data visualization, including plotting confusion matrices and model
architectures.
Google Colab
● The code is structured for execution in a Google Colab environment, which provides
free access to GPUs for faster model training.

28
3.2 Diagrams

3.2.1 Flow Chart

Fig 2.1 Flow Chart

29
3.2.2 LSTM Layers

Fig 2.2 LSTM Layers Flow Chart

3.2.3 0-Level DFD

Fig 2.3 Level - 0 DFD

30
3.2.4 1-Level DFD

Fig 2.4 LEVEL - 1 DFD

3.2.5 2-Level DFD

Fig 2.5 Level - 2 DFD

31
3.3 Design and Test Steps

3.3.1 System Design:

Problem Definition:
● Clearly define the problem statement, which is sentiment analysis of financial news data.
● Specify the goal of the analysis, such as predicting sentiment (positive, negative, or neutral) based
on news descriptions.

Data Collection and Understanding:


● Identify sources for financial news data, such as Kaggle.
● Collect a diverse dataset of financial news articles along with their corresponding sentiment labels.
● Understand the structure of the data, including the format of news articles, sentiment labels.

Data Preprocessing:
● Clean the text data by removing any irrelevant information, such as special characters, HTML tags,
or punctuation.
● Tokenize the text data by splitting it into individual words or tokens.
● Remove stop words (commonly occurring words that do not carry significant meaning) from the
text.
● Apply stemming or lemmatization to reduce words to their base forms.

Model Selection and Architecture:


● Choose an appropriate machine learning model for sentiment analysis.
● Such as LSTM (Long Short-Term Memory), which are well-suited for sequential data like text.
● Design the architecture of the model, including the number of layers, type of activation functions,
and regularization techniques.

Model Training:
● Split the dataset into training, validation, and testing sets.
● Train the sentiment analysis model on the training data using appropriate optimization algorithms
and loss functions.
● Monitor the model's performance.

Model Evaluation:
32
● Evaluate the trained model's performance on the testing set using metrics such as accuracy and
confusion matrix.
● Analyze the model's predictions using confusion matrices to understand its strengths and
weaknesses.
Model Deployment:
● Deploy the trained sentiment analysis model in a production environment, such as a web
application.
● Monitor the model's performance over time and consider retraining it periodically with new data to
maintain accuracy.

3.3.2 Testing Steps:

Data Preparation:
● Prepare a separate testing dataset that was not used during model training or validation.

Data Preprocessing:
● Preprocess the testing data using the same techniques applied during training, including cleaning,
tokenization, stop word removal, and stemming or lemmatization.

Feature Engineering:
● Convert the preprocessed testing data into numerical features using the same techniques applied
during training, such as word embeddings.

Model Evaluation:
● Use the trained sentiment analysis model to make predictions on the testing dataset.
● Evaluate the model's performance using standard evaluation metrics such as accuracy.
● Analyze the confusion matrix to understand the distribution of true positive, true negative, false
positive, and false negative predictions.

Error Analysis:
● Examine misclassified examples to identify patterns or trends in prediction errors.
● Determine whether certain types of news articles are more challenging for the model to classify
accurately.

Performance Comparison:
● Compare the performance of the sentiment analysis model with baseline models or existing systems
33
to assess its effectiveness and potential improvements.

Usability Testing:
● Gather feedback from users to evaluate the system's ease of use and intuitiveness. Identify any
usability issues and make necessary improvements to enhance the user experience, such as
improving form layout or adding tooltips for clarity.

Maintainability Testing:
● Assess the system's maintainability by reviewing its codebase, documentation, and modularity.
Ensure that the system is well-documented and structured to facilitate future updates and
maintenance tasks, allowing for seamless integration of new features or enhancements.

3.4 Algorithms

3.4.1 Data Preprocessing Algorithms:

1. Utilize Pandas to read the CSV file containing financial news data.
2. Define a function (analyze_sentiment) to analyze the sentiment of each news description using
TextBlob.
3. Calculate the polarity of the text using TextBlob's sentiment analysis, where the polarity ranges
from -1 (very negative) to 1 (very positive).
4. Assign a label of 1 for positive or neutral sentiment and 0 for negative sentiment.
5. Remove punctuations and other unnecessary characters.
6. Tokenize each text description using NLTK's word_tokenize function.
7. Remove stopwords using NLTK's stopwords corpus.
8. Apply stemming to reduce words to their root or base form using NLTK's Porter Stemmer.
9. Tokenize the preprocessed text data into sequences of integers using Keras' Tokenizer.
10. Pad the sequences to ensure uniform length using Keras' pad_sequences.
11. Split the preprocessed data into training and testing sets using sklearn's train_test_split function.

Pseudo Code:
def analyze_sentiment(description):
blob = TextBlob(description)
sentiment_score = blob.sentiment.polarity

34
if sentiment_score >= 0:
return 1 # Positive or neutral sentiment
else:
return 0 # Negative sentiment

def add_sentiment_label(df):
df['Label'] = df['Description'].apply(analyze_sentiment)
return df[['Date', 'Label', 'Description']]

def preprocess_text(text):
tokens = word_tokenize(text)
stop_words = set(stopwords.words('english'))
filtered_tokens = [word for word in tokens if word.lower() not in stop_words]
stemmer = PorterStemmer()
stemmed_tokens = [stemmer.stem(token) for token in filtered_tokens]
processed_text = ' '.join(stemmed_tokens)
return processed_text

X_processed = df['Combined'].apply(preprocess_text)

X_train, X_test, y_train, y_test = train_test_split(X_padded, df['Label'],


test_size=0.2, random_state=42)

3.4.2 Long Term Short Memory Algorithm:

● Model Definition:
1. We have defined a Sequential model, indicating that layers will be added sequentially.
2. The first layer is an Embedding layer, which is commonly used for processing text data. It
converts integer indices into dense vectors of fixed size.
3. A SpatialDropout1D layer follows the Embedding layer. Spatial dropout randomly sets input
features to zero, which helps prevent overfitting.
4. Next, we have added three LSTM layers with decreasing number of units (neurons) and
increasing dropout rates.
5. The LSTM layers are recurrent neural network layers particularly suited for sequence data.
6. After the LSTM layers, we have added a Dense layer with 32 units and ReLU activation
35
function, followed by a Dropout layer with a dropout rate of 0.5 to further prevent overfitting.
7. Finally, there's a Dense layer with 1 unit and sigmoid activation function, which outputs the
probability of the input belonging to the positive class in a binary classification problem.
● Model Compilation:
1. We have compiled the model using the Adam optimizer and specified accuracy as the metric to
monitor during training.
● Training:
1. The model is trained using the fit method on the training data X_train and y_train.
2. With the number of epochs to 20 and the batch size to 64.
3. Validation data is specified using the validation_split argument, which splits a fraction of the
training data as validation data.
4. Early stopping is implemented with a patience of 10 epochs to monitor the validation loss and
stop training if it doesn't improve for 10 consecutive epochs.

Pseudo Code:
model = Sequential()
model.add(Embedding(input_dim=len(tokenizer.word_index)+1, output_dim=128,
input_length=X_padded.shape[1]))
model.add(SpatialDropout1D(0.2))
model.add(LSTM(64, dropout=0.2, recurrent_dropout=0.2, kernel_regularizer='l2',
return_sequences=True))
model.add(LSTM(32, dropout=0.2, recurrent_dropout=0.2, kernel_regularizer='l2',
return_sequences=True))
model.add(LSTM(16, dropout=0.2, recurrent_dropout=0.2, kernel_regularizer='l2'))
model.add(Dense(32, activation='relu', kernel_regularizer='l2'))
model.add(Dropout(0.5))
model.add(Dense(1, activation='sigmoid'))

optimizer = Adam(learning_rate=0.0001)
model.compile(loss='binary_crossentropy', optimizer=optimizer, metrics=['accuracy'])

early_stopping = EarlyStopping(monitor='val_loss', patience=10, restore_best_weights=True)

history = model.fit(X_train, y_train, epochs=20, batch_size=64, validation_split=0.1,


callbacks=[early_stopping])
36
3.4.3 Optimization Algorithm:
● Adam Optimizer:
1. The Adam optimizer is used for training the neural network model. Adam is an adaptive learning
rate optimization algorithm that combines the advantages of both adaptive methods and
stochastic gradient descent (SGD), making it efficient for training deep neural networks.
Pseudo Code:
from keras.optimizers import Adam
# Initialize Adam optimizer with specific learning rate
optimizer = Adam(learning_rate=0.0001)

3.4.4 Regularization Algorithm:


● L2 Regularization:
1. It is applied to the LSTM layers to prevent overfitting this adds a term to the loss function
based on the squared magnitude of the weights, discouraging overly complex models.
Code:

model.add(LSTM(64, dropout=0.2, recurrent_dropout=0.2, kernel_regularizer='l2',


return_sequences=True))
model.add(LSTM(32, dropout=0.2, recurrent_dropout=0.2, kernel_regularizer='l2',
return_sequences=True))
model.add(Dense(32, activation='relu', kernel_regularizer='l2'))

37
3.5 Testing Process:
Test Case 1: Loading Model

Fig 3.5.1: Dataset loads successfully without any errors.


Test Case 2: Training Test

Fig 3.5.2: Model loads successfully and trains on data set without any errors

38
Test Case 3: Prediction Test

Fig 3.5.3: Model successfully predicts with an accuracy of 78.9%

39
CHAPTER-IV
RESULT

RESULT
Key Points
● The project utilizes the LSTM algorithm, a type of recurrent neural network (RNN), to predict
stock market movements based on sentiment analysis of news headlines. LSTM is particularly
suited for sequence prediction tasks like this, as it can capture dependencies and patterns in
sequential data over time.

● Before feeding the data into the LSTM model, the input dataset undergoes labeling and
preprocessing. Labeling involves assigning sentiment labels to each news headline, indicating
whether it expresses positive, negative, or neutral sentiment. Preprocessing involves tasks like
tokenization, removing stopwords, stemming, and converting text data into numerical sequences
that the model can understand.

● The trained LSTM model, along with the preprocessed dataset, is loaded into memory. This step
ensures that the model is ready to receive input data and make predictions.

● Once the input data is received from the user, it is passed to the trained machine learning model.
The model then analyzes the attributes of the input data, such as sentiment scores derived from the
news headlines.

● The LSTM model analyzes the sentiment scores and other attributes of the input data to make
predictions on stock market movements. These predictions indicate whether the market is
expected to go up, down, or remain neutral based on the sentiment expressed in the news
headlines. By leveraging the sentiment analysis of news headlines, the model provides insights
into potential market trends and helps investors make informed decisions.

40
OUTPUT

41
CHAPTER-V
CONCLUSION

In conclusion, the fusion of sentiment analysis and machine learning techniques to predict stock market
movements signifies a pivotal moment in the evolution of investment strategies. Through the utilization of
Long Short Term Memory (LSTM) algorithms, we've unlocked the potential to extract nuanced insights
from the vast expanse of news headlines, empowering stakeholders to make more informed and proactive
decisions in the dynamic world of finance.

Our journey towards this achievement has been characterized by meticulous data labeling, preprocessing,
and model training. These efforts have culminated in the creation of a robust framework capable of
discerning subtle sentiment patterns embedded within news articles. The foundation we've established,
reinforced by LSTM's adeptness at capturing dependencies, underscores our commitment to precision and
reliability in forecasting market trends.

In essence, our endeavor transcends mere technical achievement; but it embodies a pattern shift in the
approach to financial analysis and decision-making. By harmonizing the art of sentiment analysis with the
science of machine learning, we've forged a tool offering a beacon of clarity amidst the turbulence of
market volatility.

As we continue to push the boundaries of innovation and exploration, our commitment to empowering
individuals and organizations remains unwavering. Together, we embark on a journey of discovery, fueled
by curiosity, driven by data, and guided by the relentless pursuit of excellence.

Recommendations and Future Scope

As we gaze towards the horizon, we envision a landscape brimming with opportunities for further
refinement and expansion. Integrating additional data sources, such as social media sentiment and
real-time market news, holds immense potential for enhancing the predictive capabilities of our model.
Furthermore, the incorporation of advanced feature engineering techniques and ensemble learning methods
could propel our predictions to unprecedented levels of accuracy and granularity.

42
There are numerous avenues for enhancing and extending the capabilities of the current model:

1. Incorporating Additional Features: Beyond sentiment analysis, integrating other pertinent features such
as market indicators, company financial data, or economic indicators could significantly enhance
prediction accuracy. By incorporating a broader range of data sources, the model can capture more
comprehensive insights into market dynamics.

2. Deep Reinforcement Learning: Introducing reinforcement learning techniques would allow the model to
learn and adapt its strategies based on feedback from market movements over time. This adaptive learning
approach could lead to more dynamic and responsive predictions, particularly in rapidly changing market
conditions.

3. Attention Mechanisms: Implementing attention mechanisms within the LSTM model could enable it to
focus on the most relevant parts of news headlines, thereby potentially improving prediction accuracy. By
prioritizing key information within the text, attention mechanisms can enhance the model's ability to
extract meaningful signals from noisy data.

4. Time-Series Analysis: Extending the model to analyze time-series data would enable it to capture
temporal dependencies and patterns in both news sentiment and stock market movements. By considering
the sequential nature of data, the model can better understand how sentiment evolves over time and its
impact on market trends.

5. Ensemble Methods: Combining multiple models, such as LSTM with other machine learning algorithms
like Random Forest or Gradient Boosting could create an ensemble model that leverages the strengths of
each individual model. Ensemble methods have the potential to improve prediction accuracy and
robustness by aggregating diverse perspectives.

6. Real-Time Prediction: Developing the capability to make real-time predictions by continuously updating
the model with the latest news headlines and market data is crucial. By leveraging streaming data sources
and implementing efficient updating mechanisms, the model can provide timely insights for investors and
traders.

7. Interpretability: Enhancing model interpretability by providing insights into which features or news
sentiments are most influential in driving the predictions is essential. Transparent and interpretable models
instill confidence in users and facilitate more informed decision-making.
43
8. Deployment and Integration: Deploying the model as part of a trading strategy or investment platform
and integrating it with existing financial systems would facilitate seamless adoption by users. By
embedding the model within familiar interfaces and workflows, it becomes more accessible and actionable
for investors and traders.

9. Robustness and Generalization: Continuously evaluating and improving the model's robustness and
generalization ability across different market conditions and time periods is crucial. Stress-testing the
model under various scenarios and incorporating feedback loops for continuous improvement ensures its
effectiveness and reliability in diverse contexts.

By pursuing these avenues for enhancement and extension, the predictive model can evolve into a
sophisticated tool for providing invaluable insights and support in navigating the complexities of the stock
market.

44
CHAPTER-VI
REFERENCES

● Sentiment Analysis for Stock Price Prediction By James Briggs published on Towards Data
Science

● Stock-Sentiment-Analysis by krishnaik06

● Kaggle datasets https://www.kaggle.com/datasets/

● Analysis of Stock Price Prediction Using ML Techniques by IJRASET (International Journal for
Research in Applied Science and Engineering Technology)

● B. Johan, H. Mao, X. Zeng, Twitter mood predicts the stock market. J. Comput. Sci. 2(1), 1–8
(2011)

● Keras documentation https://keras.io/api/models/

● Forecasting Stock Market Movement Direction Using Sentiment Analysis and Support Vector
Machine by Ren, Wu, and Liu (2018)

● Stock Sentiment Analysis by Krish C Naik

● Analysis of Stock Price Prediction Using ML Techniques by S. Sabarinath (IJRASET)

45
CHAPTER - VII
Appendices

A. Dataset Description

The dataset used in this project consists of financial news headlines along with their corresponding dates.
Each entry in the dataset represents a single news headline and its publication date. The dataset was
collected from various sources and covers a wide range of financial news topics.

Key Features:
- Date: The publication date of the news headline.
- Description: The text content of the news headline.

Source:
The dataset was sourced from multiple financial news websites, aggregators, and databases. Due to the
sensitive nature of financial data, the specific sources are not disclosed to maintain confidentiality and data
integrity.

Summary Statistics:
- Total number of entries: 48,810
- Date range: From February 10, 2003, to May 26, 2020

B. Libraries used

1. pandas: Used for data manipulation and analysis, particularly for handling structured data like CSV
files.

2. TextBlob: A library for processing textual data, providing simple API for tasks like sentiment analysis,
part-of-speech tagging, and noun phrase extraction.

3. nltk (Natural Language Toolkit): A library for natural language processing (NLP) tasks, providing

46
modules for tokenization, stemming, stopwords removal, and other text processing tasks.

4. keras: An open-source neural network library written in Python, capable of running on top of other deep
learning frameworks like TensorFlow and Theano. It provides a high-level API for building and training
neural networks.

5. scikit-learn: A machine learning library for Python, providing simple and efficient tools for data mining
and data analysis. It includes various tools for classification, regression, clustering, dimensionality
reduction, and preprocessing.

6. matplotlib: A plotting library for creating static, animated, and interactive visualizations in Python. It is
commonly used for data visualization tasks.

7. seaborn: A data visualization library based on matplotlib, providing a high-level interface for drawing
attractive and informative statistical graphics.

These libraries are commonly used in Python for tasks related to data preprocessing, machine learning, and
data visualization, particularly in the context of natural language processing (NLP) and deep learning.

C. Model Training
The sentiment analysis model was trained on the preprocessed dataset using the following training
parameters:
- Epochs: 20
- Batch Size: 64
- Validation Split: 0.1 (10% of training data used for validation)
- Callbacks: EarlyStopping callback with a patience of 10 epochs to monitor validation loss and restore the
best weights.

During training, the model's performance was monitored on both training and validation sets to ensure
generalization and prevent overfitting. The training process involved optimizing the model's parameters to
minimize the binary cross-entropy loss function using the Adam optimizer.

D. Model Evaluation

After training, the sentiment analysis model was evaluated on a separate test dataset to assess its
performance. The evaluation metrics used included:
47
1. Accuracy: The proportion of correctly predicted labels out of all predictions made.
2. Confusion Matrix: A tabular representation of true positive, false positive, true negative, and false
negative predictions.
3. Classification Report: Providing precision, recall, F1-score, and support for each class, along with macro
and weighted averages.

These evaluation metrics helped assess the model's ability to classify news headlines into positive and
negative sentiment categories effectively.

E. Visualization

Visualization techniques were employed to analyze the model's performance and understand its behavior.
Confusion Matrix Heatmap: Visual representation of the confusion matrix using a heatmap to identify
patterns of correct and incorrect predictions.

These visualizations aided in interpreting the model's results and understanding its underlying structure and
functionality.

48
Plagiarism Report

Fig 7.1 Plagiarism Report

49

You might also like