0% found this document useful (0 votes)
36 views51 pages

Stock Prediction

Stock prediction resear

Uploaded by

yeriya6649
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)
36 views51 pages

Stock Prediction

Stock prediction resear

Uploaded by

yeriya6649
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/ 51

A SHORT-TERM INTERNSHIP REPORT ON

ARTIFICIAL INTELLIGENCE &


MACHINE LEARNING
BY
Sai prasanna Dampanaboyina
III Data Science
Under the Esteemed Guidance of
Mr. G.V.S.S PRASANTH SIR
(Tutor of Artificial Intelligence & Machine Learning)

ADITYA DEGREE COLLEGE,


Bhimavaram.

(Affiliated to ADIKAVI NANNAYA University)


Bhimavaram-534201, West Godavari District,

ANDHRA PRADESH 2022-2025

1
ADITYA DEGREE COLLEGE

DECLARATION BY THE STUDENT


I hereby declare that the work described in this short-term
Internship, entitled “Artificial Intelligence & Machine
Learning” which is being submitted by me in partial fulfilment
of the requirements for the award of degree of Bachelor of
Computer Science from the Department of Bachelor of
Computer Science to Aditya Degree College, Bhimavaram under
the guidance of Mr. G.V.S.S PRASANTH Sir tutor of Artificial
Intelligence & Machine Learning in Aditya Degree College,
Bhimavaram.
Place: Bhimavaram
Date:

(sai prasanna)

2
ADITYA DEGREE COLLEGE

CERTIFICATE FROM THE SUPERVISOR


This is to certify that the Short-Term Internship entitled,”
ARTIFICIAL INTELLIGENCE & MACHINE LEARNING”,
that is being submitted by sai prasanna dampanaboyina
bearing 223097156051 of III DS which is being
submitted to us in partial fulfilment of the requirements
for the award of degree of Bachelor of Computer
Science from the department of Bachelor of Computer
Science to Aditya Degree College, bonified work carried
out by him under my guidance and supervision.
(Mr. G.V.S.S PRASANTH SIR)

3
ACKNOWLEDGEMENT
No endeavour is completed without the valuable support of others.
I would like to take this opportunity to extend my sincere gratitude
to all those who have contributed to the successful completion of this
Short-Term Internship Project Report.

I express my deep sense of gratitude to Mr. Kamal Sir,


Principal, for his efforts and for giving us permission for
carrying out this Short-Term Internship.

I feel deeply honoured in expressing my sincere thanks to Mr.


G.V.S.S Prasanth Sir tutor of ULearn for making the resources
available at right time and providing valuable insights leading to the
successful completion of my Short-Term Internship Project Report.

Finally, I thank all the faculty members of our department who


contributed their valuable suggestions in completion of Short-Term
Internship Report and I also put my sincere thanks to my parents
who stood with me during the whole Short-Term Internship.

(sai prasanna)

4
CONTENTS
 Introduction
 Learning outcome of Short-Term Internship
 Introduction to AI and ML
 ML and types of ML
 Applications of ML
 Deep Learning
 ANN, NLP, CC
 AI tools we used in our daily life
 Back propagation
 Difference between neural & deep neural
networks
 Difference between ChatGPT and Google
 POS Tagging
 Object detection
 CNN algorithm
 Deep fake, Deep dream
 GAN model and architecture
 Data augmentation
 Parameter sharing and typing
 Ensemble methods
 Bayes theorem
5
 LSTM- long short-term memory
 Restricted Boltzmann Machine
 RNN- Recurrent Neural Network
 Auto encoders and types
 VGG Net and architecture
 Google Net and architecture
 Data types in Python
 Arithmetic operations in python
 Declaration of comments and variables
 Reserved words in python
 Control statements in python
 Programs
 Problem statement & Explanation
 Source and Outputs
 Conclusion

6
INTRODUCTION
Stock market prediction is the act of trying to determine the future
value of a company stock or other financial instrument traded on
an exchange. The successful prediction of a stock's future price could
yield significant profit. The efficient market hypothesis suggests that
stock prices reflect all currently available information and any price
changes that are not based on newly revealed information thus are
inherently unpredictable. Others disagree and those with this
viewpoint possess myriad methods and technologies which
purportedly allow them to gain future price information
The efficient market hypothesis posits that stock prices are a function
of information and rational expectations, and that newly revealed
information about a company's prospects is almost immediately
reflected in the current stock price. This would imply that all publicly
known information about a company, which obviously includes its
price history, would already be reflected in the current price of the
stock. Accordingly, changes in the stock price reflect release of new
information, changes in the market generally, or random movements
around the value that reflects the existing information set.
Burton Malkiel, in his influential 1973 work A Random Walk Down
Wall Street, claimed that stock prices could therefore not be
accurately predicted by looking at price history. As a result, Malkiel
argued, stock prices are best described by a statistical process called
a "random walk" meaning each day's deviations from the central
value are random and unpredictable. This led Malkiel to conclude that
paying financial services persons to predict the market actually hurt,
rather than helped, net portfolio return. A number of empirical tests
support the notion that the theory applies generally, as most portfolios
managed by professional stock predictors do not outperform the
market average return after accounting for the managers' fees.
7
LEARNING OUTCOME OF
SHORT-TERM INTERNSHIP
Introduction to AI & ML: -

AI is a branch of computer science. It stands for artificial intelligence. It is the


simulation of human intelligence which is processed by machines.
There are two subsets in AI. They are: - 1. Machine Learning 2. Deep Learning
Machine Learning: -
It is a subset of AI which focus on the use of data and algorithms to imitate the way
that human learn and gradually increasing its accuracy. It learns from data & solve the
problems.
Deep Learning: -
Deep learning is a subset of AI that uses multilayered neural networks, called deep
neural networks, to simulate the complex decision-making power of the human brain.

Types of ML: -
There are three types of machine learning:
1. supervised learning – it is a labelled data or structured data
2. unsupervised learning – it is un-labelled data or unstructured data
3. reinforcement learning -it uses both structured data and unstructured data
Supervised learning: -
• Supervised learning involves training a machine from labelled data.
8
• Labelled data consists of examples with the correct answer or classification.
• The machine learns the relationship between inputs (fruit images) and
outputs (fruit labels).
• The trained machine can then make predictions on new, unlabelled data.
Supervised learning is classified into two categories of algorithms:
• Regression: A regression problem is when the output variable is a real value,
such as “dollars” or “weight”.
• Classification: A classification problem is when the output variable is a
category, such as “Red” or “blue”, “disease” or “no disease”

Regression: -
Regression is a type of supervised learning that is used to predict continuous values,
such as house prices, stock prices, or customer churn. Regression algorithms learn a
function that maps from the input features to the output value.
Some common regression algorithms include:
• Linear Regression
• Polynomial Regression
• Support Vector Machine Regression
• Decision Tree Regression
• Random Forest Regression
Classification: -
Classification is a type of supervised learning that is used to predict categorical values,
such as whether a customer will churn or not, whether an email is spam or not, or
whether a medical image shows a tumour or not. Classification algorithms learn a
function that maps from the input features to a probability distribution over the
output classes.
Some common classification algorithms include:
• Logistic Regression
• Support Vector Machines
• Decision Trees
• Random Forests
• Naive Baye

9
Unsupervised Learning: -
• Unsupervised learning allows the model to discover patterns and relationships
in unlabelled data.
• Clustering algorithms group similar data points together based on their
inherent characteristics.
• Feature extraction captures essential information from the data, enabling the
model to make meaningful distinctions.
• Label association assigns categories to the clusters based on the extracted
patterns and characteristics.
Unsupervised learning is classified into two categories of algorithms:
• Clustering: A clustering problem is where you want to discover the inherent
groupings in the data, such as grouping customers by purchasing behaviour.
• Association: An association rule learning problem is where you want to
discover rules that describe large portions of your data, such as people that buy
X also tend to buy Y.
Clustering: -
Clustering is a type of unsupervised learning that is used to group similar data points
together. Clustering algorithms work by iteratively moving data points closer to their
cluster centres and further away from data points in other clusters. Some types of
clustering are:
• Hierarchical clustering
• K-means clustering
• Principal Component Analysis
• Singular Value Decomposition
• Independent Component Analysis
Association: -
Association rule learning is a type of unsupervised learning that is used to identify
patterns in a data. Association rule learning algorithms work by finding relationships
between different items in a dataset.
Some common association rule learning algorithms include:
• Apriori Algorithm
• Eclat Algorithm
• FP-Growth Algorithm

10
Reinforcement Learning: -
Reinforcement Learning (RL) is the science of decision making. It is about learning the
optimal behaviour in an environment to obtain maximum reward. In RL, the data is
accumulated from machine learning systems that use a trial-anderror method. Data is
not part of the input that we would find in supervised or unsupervised machine
learning.
Reinforcement learning uses algorithms that learn from outcomes and decide which
action to take next.
Reinforcement learning elements are as follows:
• Policy
• Reward function
• Value function
• Model of the environment

Applications of ML: -
Today, companies are using Machine Learning to improve business decisions,
increase productivity, detect disease, forecast weather, and do many more things.
Some of the most common examples are:
• Image Recognition
• Speech Recognition
• Recommender Systems
• Fraud Detection
• Self-driving Cars
• Medical Diagnosis
• Stock Market Trading
• Virtual Try On
Image Recognition: -
Image recognition made a bloom in Deep Learning.The task which started from
classification between cats and dog images has now evolved up to the level of Face
Recognition and real-world use cases based on that like employee attendance
tracking.
Speech Recognition: -
Speech Recognition based smart systems like Alexa and Siri have certainly come
across and used to communicate with them. In the backend, these systems are based

11
basically on Speech Recognition systems. These systems are designed such that they
can convert voice instructions into text.
Recommender Systems: -
Approximately everyone trying to provide customized services to its users. This
application is possible just because of the recommender systems which can analyse a
user’s preferences and search history and based on that they can recommend content
or services to them.
Fraud detection: -
Due to ML applications only whenever the system detects red flags in a user’s activity
than a suitable notification be provided to the administrator so, that these cases can
be monitored properly for any spam or fraud activities.
Medical diagnosis: -
Not even in the field of disease diagnosis in human beings but they work perfectly
fine for plant disease-related tasks whether it is to predict the type of disease it is or
to detect whether some disease is going to occur in the future.

Deep Learning: -
In the fast-evolving era of artificial intelligence, Deep Learning stands as a cornerstone
technology, revolutionizing how machines understand, learn, and interact with
complex data. At its essence, Deep Learning AI mimics the intricate neural networks
of the human brain, enabling computers to autonomously discover patterns and
make decisions from vast amounts of unstructured data. This transformative field has
propelled breakthroughs across various domains, from computer vision and natural
language processing to healthcare diagnostics and autonomous driving. In a fully
connected Deep neural network, there is an input layer and one or more hidden
layers connected one after the other.

ANN, NLP, CC: -


Artificial neural networks: -
Artificial Neural Networks contain artificial neurons which are called units. These units
are arranged in a series of layers that together constitute the whole Artificial Neural
Network in a system. A layer can have only a dozen units or millions of units as this
depends on how the complex neural networks will be required to learn the hidden
patterns in the dataset. Commonly, Artificial Neural Network has an input layer, an
output layer as well as hidden layers. The input layer receives data from the outside

12
world which the neural network needs to analyse or learn about. Then this data
passes through one or multiple hidden layers that transform the input into data that
is valuable for the output layer. Finally, the output layer provides an output in the
form of a response of the Artificial Neural Networks to input data provided.

Natural language processing (NLP):


In Deep learning applications, second application is NLP. NLP, the Deep learning model
can enable machines to understand and generate human language. Some of the main
applications of deep learning in NLP include:
• Automatic Text Generation: -Deep learning model can learn the corpus of text
and new text like summaries, essays can be automatically generated using
these trained models.
• Language translation: -Deep learning models can translate text from one
language to another, making it possible to communicate with people from
different linguistic backgrounds.
• Sentiment analysis: -Deep learning models can analyse the sentiment of a piece
of text, making it possible to determine whether the text is positive, negative,
or neutral. This is used in applications such as customer service, social media
monitoring, and political analysis.
• Speech recognition: -Deep learning models can recognize and transcribe
spoken words, making it possible to perform tasks such as speech-to-text
conversion, voice search, and voice-controlled devices.

Congestion Control: -
Congestion Control is a mechanism that controls the entry of data packets into the
network, enabling a better use of a shared network infrastructure and avoiding
congestive collapse. Congestive-Avoidance Algorithms (CAA) are implemented at the
TCP layer as the mechanism to avoid congestive collapse in a network. There are two
congestion control algorithm which are as follows:
• Leaky Bucket Algorithm: -
The leaky bucket algorithm discovers its use in the context of network traffic
shaping or rate-limiting. This algorithm is used to control the rate at which traffic is
sent to the network and shape the burst traffic to a steady traffic stream. The large
area of network resources such as bandwidth is not being used effectively.
• Token bucket Algorithm: -
13
In some applications, when large bursts arrive, the output is allowed to speed up.
This calls for a more flexible algorithm, preferably one that never loses
information. Therefore, a token bucket algorithm finds its uses in network traffic
shaping or rate-limiting. It is a control algorithm that indicates when traffic should
be sent. This order comes based on the display of tokens in the bucket.

AI Tools In Our Daily Life: -


In our daily life, we use lot of AI tools. These AI tools help us to work in an effective
manner. Following is some of the AI tools we use on our daily basis: -
Voice assistance: -
Voice assistance is used to communicate with the computer. It recognizes the
human language and coverts into machine understandable language. It uses NLP
technology i.e. Natural language processing.
Examples are Alexa, Siri, Google Assistance, Bixby etc.
Image recognition: -
It identifies the object in the image. It recognizes the object by using artificial
intelligence. It also uses OCR technology i.e. optical character recognition. OCR is
used to detect the spam mails by using POS tagging.
Examples are Google lens, X-rays, spam detection etc.
CHATGPT: -
CHATGPT is a generative AI tool which is used to get information related to the
question. It is like a chat-box.
Some of other tools like these are SNAPAI, Copilot, Gemini etc. Web
browsers: - web browsers are like search engines that gives information
relevant to our query. These are predictive AI too.
Examples are Google, Microsoft edge, Firefox, Yahoo etc.
Recommendation systems: -
Recommendation systems refer to that they give recommendations relevant to our
searches. They analyse our search history, watch history and likes on the post and
gives the recommendations based on it.
Examples are YouTube, Instagram, Aha, Flipkart and all other apps.

14
Back Propagation: -
The reverse process of feed forward neural network is called back
propagation. It rectifies the error in hidden layers and form backward
direction. The flow chart as follows: -
Predictive value errors (input layer) backward directionoutput layer to hidden
layer errors correctionoutput layerprediction value
Calculation of weights: -

following are the terms to keep in mind while calculating weights: -


•Weights should be in decimal value.
•Sum of neurons or predictive values is called bias.
•From the adjacent diagram, the terms are: -
•i1 and i2 are input values
•h1 and h2 are hidden layers
•o1 and o2 are output values
•b1 and b2 are bias values
•w1, w2, ……. are weights
Now for NETh1= w1*i1 + w2*i2 + b1*1
= 0.15*0.05 + 0.20*0.10 + 0.35*1 = 0.3775
Now for NETh2= w3*i1 + w4*i2 + b2*1
= 0.25*0.05 + 0.30*0.10 + 0.60*1= 0.645

15
Difference between Neural and Deep Neural
Networks: -
The differences between the neural networks and deep learning neural networks are
tabulate as follows: -
Neural Deep Learning
s.no Differences in Networks Neural
Networks
1. A neural network is Deep learning
a model of neurons neural networks
inspired by the are distinguished
human brain. It is from neural
Definition made up of many networks on the
neurons that at basis of their depth
inter-connected or number of
with each other. hidden layers.
2. Architecture Feed Forward Recursive Neural
Neural Networks Networks
Recurrent Neural Unsupervised
Networks Pre-trained
Symmetrically Networks
Connected Convolutional
Neural Networks Neural Networks
3. Structure Neurons Motherboards
Connection and PSU
weights RAM
Propagation Processors
function Learning
rate
4. Performance It gives low It gives high
performance performance
compared to Deep compared to
Learning neural networks.
Networks.

16
5. Task Interpretation Your task is poorly The deep learning
interpreted by a network more
neural network. effectively.

Difference between CHATGPT & GOOGLE: -


The differences between CHATGPT & GOOGLE are tabulated as follow: -

s.no CHATGPT GOOGLE


1. CHATGPT is an AI powered tool. GOOGLE is a search engine.

2. It works like a chat box between the It gives information by showing


user and server. different websites.
3. It gives the information based on the It shows the relevant information
question entered. in different sites.
4. Data may not be accurate Gives most accurate data.

5. It gives the answer based on the Gives the answer based on the
information it trained on. searches and reviews.
6. It focused on generating humanlike It can be used for variety of tasks
texts. like voices and image recognition.

7. It provides an answer based on the It provides information based on


personal views and subjective the Articles opinions of experts
views found in the data. and activists.
8. It is an Artificial intelligence model. It is a worldwide search engine.

9. Gives the information from its data Gives the information that is
source. already on the internet
10. It is developed by OpenAI. It is developed by Google Inc.

POS Tagging: -
Parts of Speech tagging is a linguistic activity in Natural Language Processing
(NLP) wherein each word in a document is given a particular part of speech (adverb,
adjective, verb, etc.) or grammatical category. Through the addition of a layer of
syntactic and semantic information to the words, this procedure makes it easier to
comprehend the sentence’s structure and meaning.

17
In NLP applications, POS tagging is useful for machine translation, named entity
recognition, and information extraction, among other things. It also works well for
clearing out ambiguity in terms with numerous meanings and revealing a sentence’s
grammatical structure.

Object Detection: -
Object detection is a technique that uses neural networks to localize and classify
objects in images. This computer vision task has a wide range of applications, from
medical imaging to self-driving cars.
Object detection is a computer vision task that aims to locate objects in digital
images. Object detection overlaps with other computer vision techniques, but
developers nevertheless treat it as a discrete endeavour.
Image classification (or image recognition) aims to classify images according to
defined categories. A rudimentary example of this is CAPTCHA image tests, in which a
group of images may be organized as images with stop signs and images without.
Image classification assigns one label to a whole image.
Object detection, by comparison, delineates individual objects in an image according
to specified categories. While image classification divides images among those that
have stop signs and those that do not, object detection locates and categorizes all of
the road signs in an image, as well as other objects such as cars and people.
Image segmentation (or semantic segmentation) is similar to object detection, albeit
more precise. Like object detection, segmentation delineates objects in an image
according to semantic categories. But rather than mark objects using boxes,
segmentation demarcates objects at the pixel level.

18
CNN Algorithm: -
A Convolutional Neural Network (CNN), also known as ConvNet, is a specialized type
of deep learning algorithm mainly designed for tasks that necessitate object
recognition, including image classification, detection, and segmentation. CNNs are
employed in a variety of practical scenarios, such as autonomous vehicles, security
camera systems, and others.
The convolutional neural network is made of four main parts.They help the CNNs
mimic how the human brain operates to recognize patterns and features in images:
• Convolutional layers
• Rectified Linear Unit (ReLU for short)
• Pooling layers
• Fully connected layers

Deep Fake & Deep Dream: -


Deep Dream: -
Deep Dream is one of the applications of learning in computer vision. In this deep
dream we used deep neural networks. We are using CNN algorithm to find image
patterns in images. Deep Dream software original image is using deep CNN named as
inceptions. Algorithms that are used in deep dream are as follows:
• CNN
• Deep CNN
• GAN model
• VGG16, VGG22visual geometrical graphs
19
If we take any image in deep dream it will identifies faces and other patterns in image
by using deep CNN algorithm to modify the image. Once we trained this algorithm, its
reverse process takes place to change the image patterns. This can be visualizes to
understand the emergent structure of neural network and basis for the deep dream
concept.
Deep Fake: -
It is digitally altered image, video or audio that replaces one person face with another
person face is called deep fake. It’s deep learning application and using deep CNN
algorithm.
Algorithms that are used in deep fake are as follows: -
• Deep CNN
• GAN model
• VGG 24
Deep fakes have potential positive applications, such as in the film industry for special
effects or in healthcare for medical simulations. They also present significant ethical
and societal challenges.

GAN Model & Architecture: -


GAN model: -
GAN stands for Generative Adversarial Network. GAN was introduced by Lan
Goodfellow in 2014. GAN is an algorithmic architecture that uses two neural networks
by putting one against to other to generate new data that passes through real data.
The flowchart as follows: -
Image dataneural network1neural network2create new data passes through
real data.
GAN architecture:

20
In GAN architecture, it takes the samples of real-world images and from generator.
The samples are aligned into a discriminator to generate new images. It gives the loss
function by analyzing real and fake images. Here back propagation error is occurred to
update discriminator weights. The flowchart is as follows: -
Loss functionOutput – MistakeBackpropagationDiscriminator->Errors
identificationRectify errorsOutput

Data Augmentation: -
Data Augmentation is a set of techniques used to increase the amount of data by
adding or slightly modifying copies in already existing data or newly Created Synthetic
data. It includes making minor changes to the dataset or using deep learning to
generate new data points. Data augmentation is useful to prevent models from
overfitting. It improves the model accuracy. It also useful to reduce the operational
cost of labelling and cleaning the raw dataset. Data augmentation is used in X-rays,
self-driving cars, automatic speech recognition. Data augmentation is useful to
improve the performance and outcomes of machine learning models by forming new
and different examples to train datasets.

Parameter Sharing & Typing: -


It is a convolutional neural network model which is used to share the weights equally
in neural networks.
• It is a deep learning application.
• Parameter sharing is the method of sharing weights by all neurons in a
particular feature map.
• It helps to reduce the number of parameters in the whole system.
• Parameter sharing is used in all convolution layers in the network.
21
• It reduces the training time.
• The idea behind parameter sharing is the essence of forcing the
parameters to be similar.
• In parameter typing, two models performing the same classification task
but with somewhat different input distributions.
• Parameter typing refers to the practice of constraining different parts of a
model to share the same parameter values.
• This can be useful in cases where we want to encourage certain
properties of model, such as symmetry or sparsity.

Ensemble Methods: -
Ensemble methods are techniques that aims to improve the results in models by
combining multiple model instead of single model. These methods help to increase
the accuracy of the results. Ensemble methods are ideal for regression and
classification where they reduce bis and variance to accuracy of models. The most
popular ensemble methods are as follows: -
Bagging: -
Bagging is the short form for bootstrap aggregating. It is mainly applied in
classification and regression.
It increases the accuracy of models through decision trees, which reduces variance
to a large extent.
It classified into two types i.e. bootstrapping and aggregation.
Bootstrapping is a sampling technique where samples are derived from the whole
set using the replacement procedure.
Aggregation in bagging is done to incorporate all possible outcomes of the
prediction and randomize the outcome.
Without aggregation, predictions will not be accurate because all outcomes are not
put into consideration.
Boosting: -
Boosting is an ensemble method that learns from previous predictor mistakes to
make better predictions in the future.
This technique combines several weak base learners to form one strong learner,
thus improving the predictability of models.
22
Boosting takes many forms, including gradient boosting, Adaptive boosting, and XG
Boost.
Stacking: -
Stacking is often referred to as stacked generalization.
This method works by allowing a training algorithm to ensemble several other
similar learning algorithm predictions.
It can also be used to measure the error rate involved during bagging.
Combination of boosting and stacking is called Boostacking.

Bayes Theorem: -
Bayes’ theorem is a fundamental concept in probability theory that plays a crucial role
in various machine learning algorithms, especially in the fields of Bayesian statistics
and probabilistic modelling. It provides a way to update probabilities based on new
evidence or information. In the context of machine learning, Bayes’ theorem is often
used in Bayesian inference and probabilistic models. The theorem can be
mathematically expressed as:
𝑃�(𝐴�/𝐵�)=𝑃�(𝐵�/𝐴�)⋅𝑃�(𝐴�)/𝑃�(𝐵�)
Where: -
P(A/B) is the posterior probability of event A given event B.
(B/A) is the likelihood of event B given event A.
P(A) is the prior probability of event A.
P(B) is the total probability of event B.

LSTM- Long Short-Term Memory: -


Long Short-Term Memory is an improved version of recurrent neural network
designed by Hochreiter & Schmidhuber. A traditional RNN has a single hidden state
that is passed through time, which can make it difficult for the network. LSTMs model
address this problem by introducing a memory cell, which is a container that can hold
information for an extended period. LSTM architectures are capable of learning long-
23
term dependencies in sequential data, which makes them well-suited for tasks such
as language translation, speech recognition, and time series forecasting. LSTMs can
also be used in combination with other neural network architectures, such as
Convolutional Neural Networks (CNNs) for image and video analysis.

LSTM Architecture: -
The LSTM architectures involve the memory cell which is controlled by three gates:
the input gate, the forget gate, and the output gate. These gates decide what
information to add to, remove from, and output from the memory cell.
• The input gate controls what information is added to the memory cell.
• The forget gate controls what information is removed from the memory cell.
• The output gate controls what information is output from the memory cell.

RBM- Restricted Boltzmann Machine: -


Restricted Boltzmann Machine (RBM) is a type of artificial neural network that is used
for unsupervised learning. It is a type of generative model that is capable of learning a
probability distribution over a set of input data.
The RBM is trained using a process called contrastive divergence, which is a variant of
the stochastic gradient descent algorithm. During training, the network adjusts the
weights of the connections between the neurons in order to maximize the likelihood
of the training data. Once the RBM is trained, it can be used to generate new samples
from the learned probability distribution.
It is a network of neurons in which all the neurons are connected to each other. In this
machine, there are two layers named visible layer or input layer and hidden layer. The
visible layer is denoted as v and the hidden layer is denoted as the h. The visible layer
actions can be computed by using h = sigmoid (Wv+bh) sigmoid(x) = %(temp(-x)) v =
sigmoid (Wx th+b-v)
This can be done using a technique called constructive divergence which as an
approximation to the maximum likelihood.

24
RNN- Recurrent Neural Networks: -
In RNN we have separate and independent input and output layers which we
inefficient the dealing with sequential data hence a new neural network called RNN
was introduced to store of previous outputs in the internal memory. these results are
then fed into the neural network as input this allows it to use in applications like
pattern detection speech recognition, NLP, time series prediction. RNN has hidden
layers that acts memory locations to store the output of a layer in a loop. There are
4types in recurrent neural network
1. one to one
2. one to many
3. many to one 4. many to many one to one:
In RNN is one to one wich allows a single input & single output. It has fired input
and output sizes and acts as a Traditional Neural Networks Applications:
image classification
input --> | | --> output
one to many:
One to many is a type of RNN that gives multiple outputs which we given single
input. It tables a fixed size and give a sequential of data inputs and the main
applications are found in music generation and image capturing input --> | | -->
output
| | --> output
| | --> output
many to one:
Many-to-one is used when a single output is required from multiple inputs in
Sequence. It takes a sequence of inputs to display fixed output.
input 1 --> input 2 -->
input 3 --> | | -->
output many-to-many:

It is used to generate the sequence of output data from a sequence of input data.
They are divided into 2 sub categories
25
1. equal unit size 2.unequal unit size Equal
unit size:
The no. of both inputs and outputs is same. it can be found in batch normalization
and name-entity recognition.
input1 --> | | --> output1 input2
--> | | --> output2 input2 --> | |
--> output3 Unequal unit size:
Input and output have different unit numbers and it applications can be found in
machine translation. input1 --> | | --> output1 input2 --> | | --> output2
Input and output values have different unit numbers

Auto Encoders & Types: -


An auto encoder is a type of neural network architecture that is used in
unsupervised learning. The main goal of auto encoder is to learn a component
representation of the original data. Auto encoders consist of two parts: -
- encode -
decode
An encoder maps encoding back to original input.
Decoder maps encoding to back for dimensional encoder.
The network architecture for auto encoders can vary b/w a simple feed
Forward network, LSTM, convolutional neural network depending upon user case.

Types of auto encoders:


1. Vanila autoencoders
2. Convolutional auto encoders
3. Recurrent auto encoders
4. Variational auto encoders
5. Denoising auto encoders
6. Adversarial auto encoders.
26
VGG NET: -
VGG stands for Visual Geometry Group; it is a standard deep Convolutional Neural
Network (CNN) architecture with multiple layers. The “deep” refers to the number of
layers with VGG-16 or VGG-19 consisting of 16 and 19 convolutional layers.
The VGG architecture is the basis of ground-breaking object recognition models.
Developed as a deep neural network, the VGG Net also surpasses baselines on many
tasks and datasets beyond ImageNet. Moreover, it is now still one of the most
popular image recognition architectures.
VGG Architecture: -
VGG architecture consist of blocks, whereas each block of composed of convolution
and max pooling layers.
VGG net comes in 2 flavours, vgg16 and vgg19, where as they consist no. of layers in
each of them. It is the basic of ground breaking object recognition model.
The architecture has 22 layers with 60 million parameters are used in ReLu (rectified
linear unit) activation function. This architecture uses techniques such as |x|
convolution in middle of architecture and global average pooling.
--> conv l-1 --> conv l2 --> pooling
--> conv l-1 --> conv l2 --> pooling
--> conv l-1 --> conv l2 --> pooling
--> dense --> dense --> dense --> output

Google Net & Architecture: -


It is used in deep learning model which is developed by researchers of google and it
consist of 22-layers and trained on the image net dataset. it can classify objects into
1000 different categories.
Architecture:
conv 2 --> max pooling --> conv 2 --> max pooling --> inception 3a --> inception 3b -->
max pooling --> inception 4a --> inception 4b --> inception 4c --> inception
4d --> inception 4d --> inception 4c --> inception 5a --> inception 5b --> inception 5c --
> dropout 40% --> soft max

27
Data Types in Python: -
Python: -
Python is an interpreted, object-orientated high level programming language. It was
created by Gudio Van Rossum in 1991. Python supports modules and packages which
encourages program modularity and code reusability. Python works on different
platforms such as windows, mac OS, Linux etc. Python has syntax that allows develop
to write programs with fewer lines compared to other programming languages. There
are 14 data types. They are as follows: -
• INT: -It consists the integer values i.e. numbers. 2, 3, ….
• FLOAT: - It consists of floating values i.e. decimals 0.78, 0,66, ….
• COMPLEX: - It consists of imaginary and real numbers. 2+3i, ….
• CHAR: - It consists of characters i.e. alphabets. A, C, e ….
• STR: -It consists of string values i.e. group of characters. ‘Python’
• BYTE: - Consists of 0 and 1.
• BOOL: -Consists of Boolean type i.e. TRUE and FALSE.
• SET: -Consists the data items in a curly-braces. ,1, 5-
• TUPPLE: - Consists the data items in parentheses. (78, 98)
• DICT: -Consists the data items in curly-braces. ,1, 6, 9, 8-
• FROZEN SET: - Consists of set Operations. union, intersection
• RANGE: - Consists of range values. for i in range
• LIST: -Consists the data items in square brackets. *3, 6, 8+

Arithmetic Operations in Python: -


Arithmetic operators in python: -
Arithmetic operators are used with numeric values to perform common
mathematical operations.
Following are the arithmetic operators with examples: -
OPERATOR NAME EXAMPLE X=9 and Y=3

28
+ Addition x+y 9 + 3 = 12

- Subtraction x-y 9–3=6

* Multiplication x*y 9 * 3 = 27

% Modulus x%y 9%3=0

** Exponent x ** y 9 **3= 729

// Floor division x // y 9 // 3 = 3

Declaration of Comments & Variables: -


Variables in python: -
Variables are used to store data values. In python, address is also created for
variables.
SYNTAX: - variable = value
Declaration of variables: -
While declaring variables, we have to keep some rules in mind. They are: -
It should not start with digit or symbols
We can use underscore at first then use digits or symbols.
Some of the examples are as follows: - _python123, n=50 etc.

Comments in python: -
Comments are used for the description of the code.
There are two types of comment lines. They are: -
1. Single line comment 2. Multiple line comment
Single line comments are declared with the symbol (#) in-front of them Multiple
line comments are declared with triple quotations (‘ ’ ’).
Examples are as follows: - # Python is a high-level language.
‘’’
Python is interpreted language
29
It executes the code line by line
‘‘‘

Reserved Words in Python: -


There are 35 reserved words in python. They are: -
• Boolean constraints:
 True
 False
 none
• Logical operators:
 and
 or
 not
 is
• Conditional statements:
 if
 elif
 else
• Looping statements:
 while
 for
 break
 continue
 return
 in  yield
• Exception handling:
 try
 expect
 finally
 raise  assert
• Module and import:
30
 import
 from
 as
• Function and class definition:
 class
 def
 pass
 global
 nonlocal
 lambda
 del
• Context managers:
 with
 async
 await

Control Statements in Python: -


Control statements: -
Control statements in python are used to control the flow of execution of a program.
The three types of control statements are: - 1. Conditional statements
2. Jumping statements 3. Looping statements
• Conditional statements: -  if statement: -
The `if` statement executes a block of code only if a specified condition is true.
SYNTAX: -
if condition:
statement

31
 if…else statement: -
The `if…else` statement allows you to execute the instructions if one block of
code condition is true, and another block when if the condition is false.
SYNTAX: -
if condition:
statement
else:
statement
 if…elif…else statement: -
The `if…elif…else` statement allows you to check multiple conditions and
execute different blocks of code based on which condition is true.
SYNTAX: -
if condition1:
statement elif
condition2:
statement
else:statement
Nested if statement:
-
A nested `if` statement is an `if` statement that is placed inside another `if`
statement.
SYNTAX: -
if condition1:
if condition2:
statement
 Nested if…else statement: -
A nested `if…else` statement is similar to a nested `if` statement, but it
includes an `else` block for each `if` condition.

32
SYNTAX: -
if condition1:
if condition2:
statement
else:
statement
else:
statement
• Jumping statements: -  Break statement: -
The break statement terminates the loop it is currently in, regardless of
whether the loop condition is true or false.
EXAMPLE: -
for i in range (10):
If i==5:
Break
Print(i)

Continue statement: -
The continue statement skips the rest of the code inside the loop for the
current iteration and proceeds to the next iteration of the loop.
EXAMPLE: -
for i in range (10):
if i==5:
continue
print(i)
 Pass statement: -
 The pass statement is a null operation; nothing happens when it is executed.

33
EXAMPLE: -
for i in range (5):
if i==3:
pass else:
print(i)

• Looping statements: - • While loop: -


A while loop is used to execute a block of statements repeatedly until a given
condition is satisfied.
SYNTAX: -
while expression:
statement

• For loop: -
It can be used to iterate over a range and iterators.
SYNTAX: - for
iterator_var in range: statement

• Nested loop: -
Python programming language allows to use one loop inside another loop
which is called nested loop.
SYNTAX1: - for
iterator_var in sequence:
for iterator_var in sequence:

statements(s)
statements(s) SYNTAX2: -
while expression:
while expression:
statement(s) statement(s)

34
Programs: -
Given number is positive or negative or zero: -
n=float (input ()) if n>0:
print("positive")
elif n<0:
print("negative")
else:
print("zero")
Given number is odd or even: -
n=int (input ()) if n%2==0:
print("even")
else:
print("Odd")
Given number is Armstrong or not: -
n=int(input()) temp=n s=0 while
n!=0: r=n%10 n=n//10
s=s+r*r*r if s==temp:
print('Armstrong') else:
print('Not Armstrong)
Eliminate Duplicate Values: -
l=list(map(int,input().split()))
u=*+ d=*+ for i in l: if i not in
u:
u.append(i)
else:

35
d.append(i) for
i in u :
print(i,end=" ")

Problem statement &


Explanation

36
To work on a supermarket sales prediction project, you
would typically use datasets that contain historical records of
supermarket transactions. These datasets can vary in
complexity and granularity but generally include information
such as date of transaction, store ID, item ID, sales amount,
promotions, and possibly additional features like weather
conditions or customer demographics.
Example Supermarket Sales Dataset Features
Date: The date of the transaction, which helps capture
seasonal and daily trends.
Store ID: Identifies the specific store where the transaction
took place. This can be useful for analyzing sales
performance across different locations.
Item ID: Identifies the product that was sold during the
transaction.
Sales: The amount of sales generated from the transaction,
which serves as the target variable for prediction.
Promotion: Indicates whether the item was sold at a
promotional price or during a special offer period.
Price: The price at which the item was sold during the
transaction.
Customer Demographics: If available, data on customer
characteristics such as age, gender, loyalty status, etc. This
can help in understanding buying patterns based on different
customer segments.
37
Store Location: Information about the store's geographical
location, which might include urban/rural classification,
region, etc
External Factors (optional): Additional data like weather
conditions (temperature, precipitation), economic indicators
(GDP, inflation), or competitor pricing could be included if
deemed relevant for predicting sales.
Libraries Used for Analysis and Modeling
To work with such a dataset and build predictive models, you
would typically use Python along with various libraries:
Pandas: For data manipulation and preprocessing tasks
such as loading data, cleaning, filtering, and transforming
datasets.
NumPy: For numerical operations and array manipulations,
often used in conjunction with Pandas.
Matplotlib and Seaborn: For data visualization, creating plots
and graphs to explore distributions, trends, and relationships
within the dataset.
scikit-learn: A comprehensive library for machine learning
tasks, providing tools for preprocessing data, building
models (regression, classification, clustering), model
evaluation, and more.
XGBoost or LightGBM: Gradient boosting libraries that are
commonly used for building ensemble models, which can
often yield better predictive performance compared to
traditional models like linear regression.

38
SOURCE CODE:

39
40
41
42
43
44
45
46
47
48
49
50
CONCLUSION

Accurate prediction of stock market returns is a very challenging


task due to volatile and non-linear nature of the financial stock
markets. With the introduction of artificial intelligence and increased
computational capabilities, programmed methods of prediction have
proved to be more efficient in predicting stock prices. In this work,
Artificial Neural Network and Random Forest techniques have been
utilized for predicting the next day closing price for five companies
belonging to different sectors of operation. The financial data: Open,
High, Low and Close prices of stock are used for creating new
variables which are used as inputs to the model. The models are
evaluated using standard strategic indicators: RMSE and MAPE. The
low values of these two indicators show that the models are efficient
in predicting stock closing price.

51

You might also like