0% found this document useful (0 votes)
33 views

Project Report

Uploaded by

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

Project Report

Uploaded by

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

Development of ML/DL Frameworks for

Trend Prediction and Optimization of Nifty


Sectoral Indices
Project Report Submitted in Partial Fulfilment of the
Requirements for the Degree of

Bachelor of Technology

in

Computer Science & Engineering


Submitted by

Harsh Pal: (Roll No. 200102151)


Shivani Kumari: (Roll No. 200102050)
Harsh Singh: (Roll No. XXXXXX)

Under the Supervision of

Dr. Anil Kumar Dahiya


Assistant Professor

<Btech CSE>
<May, 2024>
Declaration

We declare that this written submission represents my ideas in my own words and where
others' ideas or words have been included, I have adequately cited and referenced the original
sources. I also declare that I have adhered to all principles of academic honesty and integrity
and have not misrepresented or fabricated or falsified any idea/data/fact/source in
my submission. I understand that any violation of the above will be cause for disciplinary
action by the University and can also evoke penal action from the sources which have thus
not been properly cited or from whom proper permission has not been taken when needed.
The plagiarism check report is attached at the end of this document.

Name of the Student _____________________ Signature and Date _________________

Name of the Student _____________________ Signature and Date__________________

Name of the Student _____________________ Signature and Date__________________


Acknowledgements

We would like to express our sincere gratitude to Dr. Anil Kumar Dahiya (Supervisor) for
their invaluable guidance, support, and encouragement throughout this research endeavor.
Their expertise and insights have been instrumental in shaping the direction of this project.
We would also like to thank DIT University for providing the necessary resources and
facilities for conducting this research. Additionally, we extend our appreciation to Dr. Rakesh
Kumar Pandey sir who have contributed to this project in various capacities.
Finally, we are grateful to our families , friends and teachers for their unwavering support and
encouragement throughout this journey. Their understanding and encouragement have been a
constant source of motivation for us.
Table of Contents

1. Abstract
2. List of Tables
3. List of Figures
4. List of Symbols and Abbreviations
5. Chapters
5.1 Introduction
5.2 Project Research Methodology
5.3 Model Paradigm
5.4 Results and Discussion
5.5 Summary and Conclusions
5.6 Scope for Future Work
6. References
7. Appendix
Abstract

This report presents a comprehensive study on the development of machine learning (ML)
and deep learning (DL) frameworks for trend prediction and optimization of Nifty50 sectoral
indices. The research integrates sentiment analysis derived from social media platforms to
enhance the predictive accuracy of stock market trends. The key objective of a successful
stock market prediction strategy is to not only generate the highest possible returns but also to
minimize inaccuracies in stock price estimations. In trading, utilizing sentiment analysis
helps investors make well-informed choices about where to put their money. However,
forecasting stock prices is a complex task due to their susceptibility to a wide array of
influences, including shifts in investor mood, economic and political landscapes, leadership
transitions, and more. Predictions based solely on past data or textual content tend to be
unreliable. To improve accuracy, there's a growing focus on integrating the sentiment from
news sources with existing stock price information. A deep learning method has been
developed to track the trends of Nifty50 stocks, utilizing data scraped from social media
platforms like Twitter, Facebook, StockTwits, and YouTube. This data was cleaned and
analyzed to obtain subjectivity and polarity scores, reflecting positive, neutral, or negative
sentiments. By integrating these sentiment scores with market data, a novel approach was
formed to predict Nifty50 returns using the deep learning model.
List of Tables

1. Summary of SVM Performance with and without GWO


2. Summary of Logistic Regression Performance with and without GWO
3. Summary of Random Forest Classifier Performance with and without GWO
4. Summary of Gradient Boosting Classifier Performance with and without GWO
List of Figures

1. Schematic Flow Diagram for Predicting Trends in Nifty50 Indices


2. Confusion Matrix for SVM without GWO
3. Confusion Matrix for SVM with GWO
4. Confusion Matrix for LR without GWO
5. Confusion Matrix for LR with GWO
6. Confusion Matrix for RFC without GWO
7. Confusion Matrix for RFC with GWO
8. Confusion Matrix for GBC without GWO
9. Confusion Matrix for GBC with GWO
List of Symbols and Abbreviations

- SVM: Support Vector Machine


- GWO: Grey Wolf Optimization
- LR: Logistic Regression
- RFC: Random Forest Classifier
- GBC: Gradient Boosting Classifier
- Nifty50: Nifty Sectoral Indices
Chapter 1: Introduction

1.1 Background
Over the years, communication technologies be evolving and high-speed internet access has
been becoming more ubiquitous, social medial platforms such as blogs, Facebook, and
Twitter be gaining significant popularity and effectiveness as channels for interaction and
information sharing. These platforms have be revolutionizing how people communicate and
collaborate, leading to the proliferation of user-generated content. However, manual analysis
of the vast amount of data be generated on these platforms has been becoming prohibitively
expensive, prompting the development of automated systems like Sentiment Analysis.
Sentiment Analysis be swiftly determining the overall sentiment of news stories, providing a
valuable tool amidst the growing popularity of these strategies, making it easier to
understanding evolving trends in the stock market and potentially yielding profitable returns
with minimal effort. The evolution of communication technologies be revolutionizing the
way individuals interact and share information globally. With the widespread adoption of
high-speed internet, social medial platforms such as Facebook, Twitter, and blogs be became
integral parts of daily life. These platforms facilitate real-time communication and
collaboration, allowing users to sharing ideas, opinions, interests, and personal experiences
with a diverse global audience.
Sentiment Analysis be emerged as a critical tool in analyzing the vast volume of user-
generated content on social medial platforms. By swiftly determining the overall sentiment of
news stories, social media posts, and online discussions, Sentiment Analysis provide valuable
insights into public opinion and sentiment trends. This automated approach has be becoming
increasingly indispensable amidst the growing popularity of social media strategies in various
domains, including stock market analysis. The integration of social media in stock market
analysis be gaining traction in recent years as researchers and investors recognize the
potential of sentiment analysis in predicting market trends. Social medial platforms be serve
as rich sources of information, offering real-time insights into investor sentiment, market
sentiment, and emerging trends. By leveraging sentiment analysis techniques, researchers and
investors can be gained a deeper understanding of market dynamics and making more
informed decisions.

1.2 Significance of Stock Market Prediction


The realm of stock market analysis stand as a dynamic and pivotal area of inquiry, where the
quest for forecasting its behaviors is critically vital in the contemporary era. The stock
market, characterized by its dynamic and uncertainty nature, poses significant challenges for
accurate prediction. To tackling this complexity, a combination of specialized statistical
methodologies and artificial intelligence become indispensable, guiding toward more precise
outcomes. The convergence of machine learning (ML) and deep learning (DL) techniques
hold the promise of delivering robust predictions characterized by reduced margins of error.
These advanced computational approaches, by analyzing historical data and identifying
underlying patterns, enable stakeholders to making more informed decisions with a higher
degree of confidence. The stock market be characterized by its dynamism and uncertainty,
making accurate prediction methods be essential for investors. Market fluctuations be
influenced by a myriad of factors, including economic indicators, geopolitical events, and
investor sentiment. Predicting these fluctuations be requiring a comprehensive understanding
of market dynamics and the ability to analyzing vast amounts of data.

1.3 Advancements in AI and ML


The advent of AI and ML technologies be revolutionized the field of stock market prediction.
These technologies enable the analysis of vast datasets, identification of complex patterns,
and generation of predictive models with unprecedented accuracy. Deep learning algorithms,
in particular, have showed remarkable promise in capturing intricate relationships within
financial data and making robust predictions. The continuous advancement of AI and ML
techniques hold the potential to further enhance the precision and reliability of stock market
forecasts, ushering in a new era of data-driven decision-making in finance.
Moreover, the application of AI and ML in stock market prediction has lead to the
development of sophisticated algorithms capable of processing diverse data sources in real-
time. This real-time processing capability enable investors and financial institutions to
reacting swiftly to market changes and adjusting their investment strategies accordingly.
Additionally, the scalability of AI and ML algorithms allow for the analysis of large volumes
of data, including market trends, news articles, and social media sentiment, facilitating more
comprehensive and nuanced predictions. As AI and ML continue to evolution, they are poised
to play an increasingly central role in shaping the future of stock market analysis and
investment strategies.

1.4 Literature Review


The quest for accurate stock market predictions has spurred a plethora of research endeavors,
each exploring diverse methodologies to enhancing forecasting accuracy. Deep learning
models have became a prominent approach, with studies showcasing their efficacy in
capturing complex patterns within financial data. For instance, Jayanth Balaji's exploration of
14 different deep learning models demonstrated their potential in forecasting stock prices,
underscoring the versatility and robustness of deep learning techniques. Similarly, Tsong Wuu
Lin's focus on leveraging Artificial Neural Networks (ANN) highlighted the capability of
ANN in optimizing profitability, shedding light on the effectiveness of neural network-based
approaches in financial modeling.
Furthermore, autoregressive models have garnered attention for their robustness in stock
market forecasting, offering valuable insights into time series analysis and yielding precise
predictions. The ARIMA model, in particular, has been noted for its effectiveness in
sentiment analysis and predicting time series data, emphasizing the diverse methodologies
researchers employ to tackling the dynamic challenge of stock market prediction.
Additionally, sentiment analysis has emerged as a powerful tool for forecasting stock market
trends, with social media analytics playing a crucial role in providing real-time insights into
investor sentiment. The rapid advancement of the Internet, particularly social media
platforms, has facilitated the mirroring of investor sentiment in online textual content,
necessitating efficient approaches to deriving insights from vast volumes of textual data.
Techniques such as sentiment analysis, opinion mining, natural language processing, and data
mining are employed to extract perspectives, feelings, and opinions from text-based content,
contributing to the development of more accurate predictive models.

1.5 Project Objectives


This project aims to developing ML/DL frameworks for trend prediction and optimization of
Nifty Sectoral Indices. The objectives include:
 Analyzing the effectiveness of sentiment analysis from social media platforms in
predicting stock market trends.
 Developing ML/DL models to integrating sentiment analysis with market data for
improved stock price prediction.
 Evaluating the performance of the developed frameworks in predicting Nifty Sectoral
Indices trends.
 Providing insights into the potential applications and limitations of ML/DL
frameworks in stock market analysis.
Furthermore, the project seeks to developing sentiment analysis models capable of
quantifying the sentiment of news articles and social media posts accurately. These models
will leveraging natural language processing techniques to extract insights from textual data
and classify sentiment as positive, negative, or neutral. Subsequently, the sentiment analysis
results will be integrated with historical market data to predicting trends in Nifty sectoral
indices. The performance of the developing models will be evaluated using various metrics,
including accuracy, precision, recall, and F1 score. Additionally, the project aims to
optimizing investment strategies based on the predictions generated by the machine learning
and deep learning frameworks. This optimization process will involve adjusting portfolio
allocations, timing buy and sell decisions, and implementing risk management strategies to
maximizing returns and minimizing losses. Ultimately, the project endeavors to empowering
investors with more accurate predictions and actionable insights, thereby facilitating
informed decision-making in the dynamic landscape of the stock market.
Chapter 2: Project Research Methodology

The project's research methodologies encompass a systematic approach to gather, preprocess,


and analyze data urgently needed for the development of machine learning models aimed at
predicting trends in Nifty50 stock indices. The methodologies start with the collection of
secondary data sourced from Yahoo Finance and the four prominent social media platforms:
Twitter, StockTwits, Facebook, and YouTube. These platforms serve as extremely rich
repositories of market-related information and sentiments expressed by various stakeholders,
including market experts, traders, and investors. The data collected from these sources span a
period of four years from 2018 to 2021, providing a comprehensively dataset to analyse. Each
social media platform offers unique insights into market sentiments, with Twitter providing
immediate updates and conversations, StockTwits offering focused discussions tailored for
traders, Facebook facilitating discussions within financial groups and pages, and YouTube
providing expert analyses through video content. Data collection from these platforms
involves utilizing appropriate tools, such as the Twitter API, Octoparse, Facepager, and video
transcripts for YouTube content.
Following data collection, the next phase involves rigorously data preprocessing to ensure the
quality and suitability of the dataset for model development. This includes addressing
problems such as collinearity among predictor variables, the removal of outlier detection,
feature engineering, and standardization. Colliniarity is assessed using correlation matrices,
with highly correlated attributes being addressed through feature engineering techniques.
Outliers are detected and removed using Z-scores to improve the dataset's robustness.
Standardization is employed to ensure evenness in feature scales, preventing any dominating
feature from the modelling process. Finally, the preprocessed datasets are split into training
and testing sets, with 70% of the data allocated for model training and the remaining 30% for
evaluation. This facilitates the development and evaluation of machine learning models for
trend prediction of Nifty50 stocks. Generally, the project's research methodology provides a
structured framework for obtaining, processing, and analyzing data to achieve the objectives
of predicting stock market trends effectively.

2.1 Data Gathering


The data gathering phases of the project involved collecting secondary data from Yahoo
Finance and four prominent social media platforms: Twitter, StockTwits, Facebook, and
YouTube. These platforms were chosen due to their significance as sources of market-related
information and sentiments expressed by various stakeholders. The collected data span a
period of four years from 2018 to 2021, providing a comprehensively dataset to analyze.
Each social media platform offers unique insights into market sentiments, with Twitter
providing immediate updates and discussions, StockTwits offering focused discussions
tailored for traders, Facebook facilitating discussions within financial groups and pages, and
YouTube providing expert analyses through video content. The collected data was aggregated
and organized day-wise to align with market return dates, facilitating sentiment score
calculation and subsequent analysis. This robust dataset forms the foundation for the
development of machine learning models aimed at predicting trends in Nifty50 stock indices.
2.1.1 Twitter data:
Twitter, significantly utilizing social media platform, was utilized to gather real-time updates
and discussions concerning Nifty50 stocks. Leveraging the Twitter API, relevant tweets and
discussions were extracted, providing valuable insights into market sentiments and trends.
Incorporating the latest market sentiments into the analysis enhanced the accuracy of trend
predictions for Nifty50 stocks.
2.1.2 StockTwits data:
StockTwits, a specialized platform for stock market discussions, provided valuable insights
into Nifty50 stocks. Through Octoparse, relevant discussions and sentiments were extracted,
offering unique perspectives from traders and investors. This data enriched the project's
understanding of market dynamics, improving the accuracy of trend predictions for Nifty50
stocks.
2.1.3 Facebook data:
Facebook provided discussions and sentiments regarding Nifty50 stocks. Utilizing Facepager,
relevant posts and comments from financial groups and pages were extracted for analysis.
This platform offered diverse opinions within dedicated financial communities, enriching the
project's understanding of market dynamics and improving trend prediction accuracy for
Nifty50 stocks.
2.1.4 YouTube data:
YouTube served as a valuable source of insights through video content related to Nifty50
stocks. Transcripts of relevant videos were obtained for analysis. This platform offered expert
analyses and discussions, providing additional perspectives on market sentiments and trends.
By collecting and analyzing data from YouTube, the project enhanced its understanding of
market dynamics, contributing to the accuracy of trend predictions for Nifty50 stocks..
After meticulously gathering data from various sources, the collected feeds were aggregated
and aligned day-wise to correspond with market returns dates for sentiment score calculation.
This comprehensive approach ensured that the dataset encapsulated a diverse range of
opinions and sentiments expressed across different social media platforms, providing a rich
and nuanced understanding of market dynamics. The curated dataset serves as a valuable
resource for subsequent analysis and modeling, enabling the development of robust machine
learning frameworks for trend prediction and optimization of Nifty Sectoral Indices.
2.2 Data Preprocessing
Data preprocessing is a crucial step in preparing the dataset for analysis and model
development. It involves several techniques aimed at enhancing the quality and suitability of
the data for machine learning tasks. These techniques include addressing collinearity among
predictor variables, performing feature engineering to create new informative features,
detecting and removing outliers to improve model robustness, standardizing the data to
ensure uniformity in feature scales, and splitting the dataset into training and testing sets for
model development and evaluation. Through these preprocessing steps, the dataset is refined
and optimized, laying a solid foundation for the subsequent stages of the project.

2.2.1 Addressing Collinearity:


One of the initial challenges encountered during data preprocessing was addressing
collinearity among predictor variables, which could potentially impact both the performance
and interpretability of the machine learning models. To assess collinearity, Kendall's and
Spearman's rank correlation coefficients were computed, revealing a significant correlation
among attributes such as 'Open', 'High', 'Low', and 'Adjusted Close'. This high collinearity
suggested redundancy in the dataset, which could lead to instability in model estimation and
difficulty in interpretation. To mitigate the issue of collinearity, a novel approach was adopted
wherein a new feature, termed 'New\_feature', was engineered to represent the average of
these highly correlated attributes. By creating this composite feature, the redundant
information present in the original attributes was effectively consolidated, thereby reducing
multicollinearity within the dataset. This preprocessing step not only enhanced the robustness
of subsequent machine learning models but also facilitated more meaningful interpretations
of their results.

2.2.2 Feature Engineering:


Feature engineering is a pivotal step in data preprocessing aimed at enhancing the predictive
power of machine learning models. In this project, feature engineering involved the creation
of a new composite feature, termed 'New_feature', to address collinearity among predictor
variables. By computing the average of highly correlated attributes such as 'Open', 'High',
'Low', and 'Adjusted Close', the redundant information present in the original attributes was
effectively consolidated. This approach not only reduced multicollinearity within the dataset
but also improved the interpretability and stability of subsequent machine learning models.
Additionally, feature engineering enabled the extraction of more relevant and informative
features from the raw data, thereby enhancing the overall predictive performance of the
models for trend prediction of Nifty50 stocks.

2.2.3 Outlier Detection and Removal:


Another critical aspect of data preprocessing is the detection and removal of outliers, which
can adversely affect the performance and reliability of machine learning models. To identify
outliers in the dataset, Z-score were computed to measure the deviation of each data point
from the mean in terms of standard deviations. The formula used for calculating Z-scores is
given by:
Z=( X−μ)/σ
Where: X is the data point , μ is the mean of the sample & σ is the standard deviation of the
sample
Data points exceeding a threshold of 3 standard deviations were considered outliers and
subsequently removed from the dataset. This process resulted in a refined dataset containing
20,589 samples with 5 attributes. By removing outliers, the dataset was cleansed of any
erroneous or anomalous observations, ensuring the integrity and reliability of subsequent
machine learning analyses.

2.2.4 Standardization:
Standardization is a crucial preprocessing step aimed at ensuring uniformity in feature scales,
thereby preventing any particular feature from dominating the modeling process. In this
project, the preprocessed dataset underwent standardization using the StandardScaler. By
scaling the features to have a mean of 0 and a standard deviation of 1, the data was
normalized and brought to a common scale, facilitating more stable and effective model
training. This standardization process ensured that each feature contributed proportionately to
the model's learning process, thereby preventing biases and improving the overall
performance of the machine learning models for trend prediction of Nifty50 stocks.
2.2.5 Data Splitting:
Data splitting is a critical step in machine learning model development, enabling the
evaluation of model performance on unseen data. In this project, the preprocessed dataset was
divided into training and testing sets using a common ratio of 70% for training and 30% for
testing. This partitioning facilitated the development of machine learning models on the
training data while allowing for the independent validation of model performance on the
testing data. By separating the dataset into distinct training and testing subsets, the risk of
overfitting was mitigated, ensuring that the models generalized well to unseen data.
Additionally, this approach enabled robust model evaluation and provided insights into the
effectiveness of the developed models for trend prediction of Nifty50 .
2.3 Machine Learning

2.4 Grey Wolf Optimization


Chapter 3: Model Paradigm
Chapter 4: Results and Discussion
Chapter 5: Conclusion
Chapter 6: Scope for Future Work
References
Appendix
Machine Learning-
Machine learning techniques offer a systematic approach to analyzing large volumes of
historical market data and identifying patterns that may influence future trends. By
employing ML algorithms, we aim to enhance our understanding of the underlying dynamics
driving Nifty50 movements and develop predictive models capable of forecasting market
trends with greater accuracy .

a)Support vector Machine: SVMs were developed in the 1990s by Vladimir N. Vapnik and
his colleagues, and they published this work in a paper titled "Support Vector Method for
Function Approximation, Regression Estimation, and Signal Processing"1 in 1995 . Support
Vector Machines (SVMs) play a pivotal role in accurately predicting dataset, owing to their
robustness and adaptability to complex market dynamics . SVMs excel in discerning intricate
patterns by effectively separating data points into distinct classes using hyperplanes. This
capability allows SVMs to capture both linear and nonlinear relationships, making them
versatile for modeling diverse behaviors. The SVM algorithm is widely used in machine
learning as it can handle both linear and nonlinear classification tasks. However, when the
data is not linearly separable, kernel functions are used to transform the data to higher-
dimensional space to enable linear separation. This application of kernel functions can be
known as the “kernel trick”, and the choice of kernel function, such as linear kernels,
polynomial kernels, radial basis function (RBF) kernels, or sigmoid kernels, depends on data
characteristics and the specific use case . So, to separate the multi-dimensional data we use
hyperplane. To define a hyperplane for two-dimensional data which can be linearly separable
by a line. Now we are renaming x with x1 , y with x2 then we get:

ax_1- x_2+b=0 (2)


if we define
x = (x1 , x2) and ω = (a ,1 ) ω.x+b=0 (3)

Once we have the hyperplane, we can then use the hyperplane to make predictions. We define
the hypothesis function h as:

h={(+1 if ω.x+b≥0@-1if ω.x+b<0)┤ (4)

The point above or on the hyperplane will be classified as class +1, and the point below the
hyperplane will be classified as class -1.
b)Logistic Regression: Logistic regression, pioneered by David Cox, models the relationship
between multiple independent variables and a dependent variable, specifically suited for
situations with binary outcomes and continuous predictors. Unlike traditional regression
methods, logistic regression is adept at classifying observations into distinct categories,
relaxing assumptions like normality of independent variables and absence of multicollinearity
[33] , [34]. The logistic regression equation is represented as:

P(Y=1/X)=1/(1+e^(-w⋅x-b) ) (5)

Training a Logistic Regression model involves the estimation of parameters w and b from the
training data. This estimation typically revolves around maximizing the likelihood of
observing the training labels given the input features [35]. Formally, this is expressed as
maximizing the likelihood function

L(w,b): L(w,b)=π_(i=1)^N P((Y_i )/x_i ;w,b) (6)

where : N represents the number of training samples Y_i denotes the true label of the i-th
training sample x_i signifies the feature vector of the i-th training sample.

Parameter estimation, commonly conducted through optimization techniques like gradient


descent or Newton's method, endeavors to derive the optimal w and b values that best fit the
training data [36]. For the optimal output, logistic regression is performed on the provided
dataset to predict the trend of Nifty50. Techniques such as feature selection (e.g.,
forward/backward selection, Lasso regression), regularization (e.g., Ridge, Lasso regression),
and performance metrics (e.g. Akaike Information Criterion or Bayesian Information
Criterion) are employed to enhance predictive accuracy and interpretability. These methods
collectively optimize model performance and aid in selecting the most parsimonious and
accurate logistic regression model for NIFTY50 trend prediction.[35].

c)Random Forest Classifier: Random Forest, introduced by Leo Breiman and Adele Cutler in
2001, is a powerful ensemble learning method widely employed for classification and
regression tasks . Its foundation lies in the construction of multiple decision trees during
training and the aggregation of their predictions through voting or averaging, resulting in
robust and accurate predictions . It creates a different training subset from sample training
data with replacement & the final output is based on majority voting. It combines weak
learners into strong learners by creating sequential models such that the final model has the
highest accuracy. For example, ADABOOST,XG BOOST . Steps Involved in Random Forest
Algorithm-

Step 1: In the Random forest model, a subset of data points and a subset of features is
selected for constructing each decision tree. Simply put, n random records and m features are
taken from the data set having k number of records.
Step 2: Individual decision trees are constructed for each sample.
Step 3: Each decision tree will generate an output.
Step 4: Final output is considered based on Majority Voting or Averaging for Classification
and regression, respectively.

By combining the predictions of multiple trees, Random Forests can capture complex
relationships between input variables and the target variable, making them suitable for
capturing the nonlinear dynamics [40] , [41]. Hyperparameters are used in random forests to
either enhance the performance and predictive power of models or to make the model faster.
The hyperparameters used by random forest classifier are n_estimators , max_features ,
mini_sample_leaf , criterion , and max_leaf_nodes for increasing predictive power . To
increase the speed n_jobs , random_state , oob_scores are used .

d)Gradient Boosting Classifier: Gradient Boosting Classifier (GBC), pioneered by Jerome


Friedman, is an ensemble method for regression and classification. It iteratively improves the
model by combining weak learners and minimizing a loss function through gradient descent.
[43]. The learning process aims to minimize errors from previous model iterations, enhancing
predictive performance. Parameter tuning, including adjusting the number of trees, learning
rate, and tree depth, is pivotal for optimizing results, mitigating overfitting, and improving
model accuracy [44]. The formulation for updating the prediction in gradient boosting at
iteration m can be expressed

y ̂_m (x)=y ̂_(m-1) (x)+λ⋅h_m (x) (7)

Where y ̂_m (x) represents the predicted value at iteration m for input x, y ̂_(m-1) (x) is the
prediction from the previous iteration. h_m (x) is the weak learner (e.g., decision tree) trained
to fit the residuals , λ is the learning rate, controlling the step size in the gradient descent
process. [45]

To study implementations of Gradient Boosting Machines there are mainly two algorithms:
XGBoost , LightGBM. Hyperparameters used in gradient boosting classifier here are learning
rate , n_estimators , subsample and max depth , using these hyperparameters we aimed to
achive maximum accuracy using LightGBM [46] , [47].

Grey Wolf Optimization-


Grey Wolf Optimization (GWO) is a metaheuristic optimization algorithm inspired by the
social behaviour and hunting mechQanism of grey wolves. Introduced by Mirjalili et al. in
2014, GWO mimics the leadership hierarchy observed in wolf packs, where the alpha, beta,
and delta wolves represent the pack's leaders [48]. In GWO, the search population consists of
two types of grey wolves: wolf leaders (dominant wolves) and follower wolves. In the group
of wolf leaders, there are three members: the alpha (α) wolf, representing the best solution
found so far in the search space; the beta (β) wolf, representing the second-best solution; and
the delta (δ) wolf, representing the third-best solution. The rest of the population are
considered as followers, namely omega (ω) wolves [49]. In this subsection the steps which
are taken in consideration by gray wolves to attack the prey are depicted in the sequence
along with explanation of the social hierarchy. 1)Tracking according to social hierarchy To
mathematically model the social hierarchy of wolves when designing GWO, we consider the
fittest solution as the alpha (α). Consequently, the second and third best solutions are named
beta (ẞ) and delta (δ) respectively. The rest of the candidate solutions are assumed to be
omega (ω). In the GWO algorithm the hunting (optimization) is guided by a, β, and δ. The w
wolves follow these three wolves. 2)Encircling the prey As mentioned above, grey wolves

⃗=|C ⃗.X ⃗(t)-X ⃗(t)|


encircle prey during the hunt. In order to mathematically model encircling behavior the

(8) X ⃗(t+1)=X ⃗p(t)-A ⃗.D ⃗


following equations are proposed: D

iteration, A ⃗ and C ⃗ are coefficient vectors, X ⃗p is the position vector of the prey, and X ⃗
(9) Where t indicates the current

indicates the position vector of a grey wolf. The vectors A ⃗ and \overline( C) ⃗ are calculated
as follows: A ⃗=2*a.〖r ⃗ 〗_1-a (10) C ⃗=2 .r ⃗2
(11) 3)Hunting In order to mathematically simulate the hunting behavior of grey wolves,
we suppose that the alpha (best candidate solution) beta, and delta have better
knowledge about the potential location of prey. Hence, we store the top three solutions
attained thus far and direct the remaining search agents, including the omegas, to adjust their

⃗α=|C ⃗1.X ⃗α-X ⃗| ⃗_β=|C ⃗_2.X ⃗β-X ⃗|


positions based on the best search agent's position. To accomplish this, we employ the

(12) D ⃗_δ=|C ⃗_3.X ⃗δ-X ⃗| X ⃗₁=X ⃗_α-A ⃗₁.D ⃗_a X ⃗_2=X ⃗_β-A ⃗₂.D ⃗_β
following formulas: D D

(13) X ⃗₃=X ⃗_δ-A ⃗₃.D ⃗_δ X ⃗(t+1)=(X ⃗_1+X ⃗_2+X ⃗_3)/3


(14) 4)Attacking prey(exploitation) To model the wolves' approach to the prey, the algorithm
decreases the value of a, representing the fluctuation range of A, from 2 to 0 across iterations.
ˉAˉ becomes a random value in the interval [-a, a]. When random values of A fall within [-1,
1], a search agent's next position can be anywhere between its current position and the prey's
position. Figure 5(a) illustrates that when <1A<1, wolves are directed to attack towards the

through parameters like ∣A∣ and ∣C∣ to encourage divergence among search agents, promoting
prey. 5)Searching for prey(exploration) In the GWO algorithm, randomness is introduced

global exploration. ∣A∣ facilitates exploration, while ∣C∣ provides random weights to influence
prey factors, aiding in avoiding local optima. Unlike ∣A∣, ∣C∣ maintains randomness
throughout optimization, preventing stagnation in local optima. GWO starts with a random
population of wolves, iteratively estimating prey positions by alpha, beta, and delta wolves
while adjusting their distances accordingly. Model Paradigm- The framework proposed in
this study, as depicted in Fig. 1, outlines a schematic flow diagram for predicting trends in the
Nifty50 indices. The input and output labels are fed into a predictive model, which undergoes
preprocessing. A notable preprocessing step involves addressing multicollinearity, where
rows with a threshold greater than 0.75 are averaged out into a new column, effectively
treating them as a new feature. Incorporating Grey Wolf Optimization (GWO) for
hyperparameter tuning significantly enhances the predictive performance of our models.
Hyperparameter tuning is vital for optimizing machine learning and deep learning models,
aiming to identify the optimal set of hyperparameters that maximize performance metrics
such as accuracy, precision, or recall. Manual hyperparameter tuning is often time-consuming
and requires domain expertise. However, by leveraging metaheuristic algorithms like GWO,
we automate the process of exploring the hyperparameter space efficiently, thus mitigating
the challenges associated with manual tuning. Fig. 1 Flow diagram of the proposed
framework Fig. 2 Confusion matrix for total data (a) SVM without GWO, and (b) SVM with
GWO . The confusion matrix shown in Fig. 2 serve as visual representations of the Support
Vector Machine (SVM) model's performance, contrasting between scenarios with and without
the Grey Wolf Optimization (GWO) technique. In the initial matrix, SVM's classification
outcomes are depicted, offering insights into its accuracy and predictive capabilities.
Conversely, the second matrix reflects the model's performance post-GWO integration,
showcasing potential improvements in classification accuracy. Fig. 3 Confusion matrix for
total data (a) LR without GWO, and (b) LR with GWO . The confusion matrices shown in fig
3 for Logistic Regression depict the model's classification results before and after integrating
the Grey Wolf Optimization (GWO) method. Initially, the matrix showcases the model's
classification accuracy and misclassifications. However, post-GWO implementation, the
subsequent matrix illustrates minimal improvements in accuracy, with the model's
performance showing an increase of less than 1%. Despite the slight enhancement, the
matrices offer valuable insights into the impact of GWO on Logistic Regression's predictive
capabilities, underscoring the need for further optimization strategies to achieve more
substantial performance gains. Fig. 4 Confusion matrix for total data (a) RFC without GWO,
and (b) RFC with GWO . The confusion matrices shown in fig 4 for Random Forest represent
the classification outcomes both before and after the integration of Grey Wolf Optimization
(GWO). Initially, the model achieved an impressive accuracy of approximately 99.4%
without GWO, as depicted in the first matrix. However, upon implementing GWO, there was
a marginal improvement in accuracy, with the model's performance rising to around 99.6%,
as evidenced in the subsequent matrix Fig. 5 Confusion matrix for total data (a) GBC without
GWO, and (b) GBC with GWO The evolution of the Gradient Boosting Classifier (GBC) can
be observed through the comparison of its respective confusion matrices before and after the
incorporation of Grey Wolf Optimization (GWO). Initially, the GBC exhibited a modest
accuracy of approximately 79.2456%. However, upon implementing GWO, a remarkable
transformation occurred, elevating the accuracy to an impressive 100%. This stark
improvement underscores the significant impact of GWO in enhancing the performance of
the Gradient Boosting Classifier, leading to a perfect predictive accuracy.

You might also like