aiml
aiml
in
COURSE OBJECTIVES:
The main objectives of this course are to:
Study about uninformed and Heuristic search techniques.
Learn techniques for reasoning under uncertainty
Introduce Machine Learning and supervised learning algorithms
Study about ensembling and unsupervised learning algorithms
Learn the basics of deep learning using neural networks
n
UNIT I PROBLEM SOLVING
g.i
Introduction to AI - AI Applications - Problem solving agents – search algorithms –
uninformed search strategies – Heuristic search strategies – Local search and optimization
problems – adversarial search – constraint satisfaction problems (CSP)
rin
UNIT II PROBABILISTIC REASONING
Acting under uncertainty – Bayesian inference – naïve bayes models. Probabilistic
reasoning – Bayesian networks – exact inference in BN – approximate inference in BN –
ee
causal networks.
gin
UNIT III SUPERVISED LEARNING
Introduction to machine learning – Linear Regression Models: Least squares, single
& multiple variables, Bayesian linear regression, gradient descent, Linear Classification
Models: Discriminant function – Probabilistic discriminative model - Logistic regression,
En
Probabilistic generative model – Naive Bayes, Maximum margin classifier – Support vector
machine, Decision Tree, Random forests
arn
PRACTICAL EXERCISES:
1. Implementation of Uninformed search algorithms (BFS, DFS)
2. Implementation of Informed search algorithms (A*, memory-bounded A*)
3. Implement naïve Bayes models
4. Implement Bayesian Networks
5. Build Regression models
6. Build decision trees and random forests
7. Build SVM models
8. Implement ensembling techniques
9. Implement clustering algorithms
www.LearnEngineering.in
www.LearnEngineering.in
COURSE OUTCOMES:
At the end of this course, the students will be able to:
CO1: Use appropriate search algorithms for problem solving
CO2: Apply reasoning under uncertainty
CO3: Build supervised learning models
CO4: Build ensembling and unsupervised models
CO5: Build deep learning neural network models
n
g.i
TEXT BOOKS:
1. Stuart Russell and Peter Norvig, “Artificial Intelligence – A Modern Approach”, Fourth
rin
Edition, Pearson Education, 2021.
2. Ethem Alpaydin, “Introduction to Machine Learning”, MIT Press, Fourth Edition, 2020.
REFERENCES: ee
1. Dan W. Patterson, “Introduction to Artificial Intelligence and Expert Systems”, Pearson
Education,2007
gin
2. Kevin Night, Elaine Rich, and Nair B., “Artificial Intelligence”, McGraw Hill, 2008
3. Patrick H. Winston, "Artificial Intelligence", Third Edition, Pearson Education, 2006
4. Deepak Khemani, “Artificial Intelligence”, Tata McGraw Hill Education, 2013
(http://nptel.ac.in/)
En
www.LearnEngineering.in
www.LearnEngineering.in
Part A
n
2. What is an agent?
g.i
An agent is anything that can be viewed as perceiving its environment through
sensors and acting upon that environment through actuators.
rin
3. What are the different types of agents?
A human agent has eyes, ears, and other organs for sensors and hands, legs,
ee
mouth, and other body parts for actuators.
A robotic agent might have cameras and infrared range finders for sensors
and various motors for actuators.
gin
A software agent receives keystrokes, file contents, and network packets as
sensory inputs and acts on the environment by displaying on the screen, writing files,
and sending network packets.
En
percept sequence and whatever built-in knowledge the agent has. A rational agent
should be autonomous.
w.
www.LearnEngineering.in
www.LearnEngineering.in
n
Speech recognition
g.i
Autonomous planning and scheduling
Game playing
Spam fighting
rin
Logistics planning
Robotics
Machine Translation ee
7. Are reflex actions (such as flinching from a hot stove) rational? Are they
gin
intelligent?
Reflex actions can be considered rational. If the body is performing the action,
En
then it can be argued that reflex actions are rational because of evolutionary
adaptation. Flinching from a hot stove is a normal reaction, because the body wants to
keep itself out of danger and getting away from something hot is a way to do that.
arn
Reflex actions are also intelligent. Intelligence suggests that there is reasoning
and logic involved in the action itself.
Le
at the core of any science, allows us to study artificial intelligence. From what we
learn by observation and experimentation, we are able to engineer new systems that
encompass what we learn and that may even be capable of learning themselves.
ww
www.LearnEngineering.in
www.LearnEngineering.in
n
consider given a goal.
g.i
12. List the steps involved in simple problem solving agent.
(i) Goal formulation
(ii) Problem formulation
rin
(iii) Search
(iv) Search Algorithm
(v) Execution phase ee
13. What are the components of well-defined problems? (or)
gin
What are the four components to define a problem? Define them?
The four components to define a problem are,
1) Initial state – it is the state in which agent starts in.
2) A description of possible actions – it is the description of possible actions
En
(final) state.
4) A path cost function – it is the function that assigns a numeric cost (value)
to each path.
The problem-solving agent is expected to choose a cost function that reflects
Le
real world problem is one whose solutions people actually care about.
www.LearnEngineering.in
www.LearnEngineering.in
Automatic Assembly
Internet searching
Toy problem Examples:
8 – Queen problem
8 – Puzzle problem
Vacuum world problem
n
one?
g.i
Optimality: Does the strategy find the optimal solution?
Time complexity: How long does it take to find a solution?
Space complexity: How much memory is needed to perform the search?
rin
17. What is the application of BFS?
It is simple search strategy, which is complete i.e. it surely gives solution if
ee
solution exists. If the depth of search tree is small then BFS is the best choice. It is
useful in tree as well as in graph search.
gin
18. State on which basis search algorithms are chosen?
Search algorithms are chosen depending on two components.
1) How is the state space – That is, state space is tree structured or graph?
En
Critical factor for state space is what is branching factor and depth level of that tree or
graph.
2) What is the performance of the search strategy? A complete, optimal search
arn
strategy with better time and space requirement is critical factor in performance of
search strategy.
Le
www.LearnEngineering.in
www.LearnEngineering.in
Depth-limited search
Iterative deepening depth-first search
Bidirectional search
21. What is the power of heuristic search? (or) Why does one go for heuristics
search?
Heuristic search uses problem specific knowledge while searching in state
space. This helps to improve average search performance. They use evaluation
functions which denote relative desirability (goodness) of a expanding node set. This
makes the search more efficient and faster. One should go for heuristic search because
n
it has power to solve large, hard problems in affordable times.
g.i
22. What are the advantages of heuristic function?
Heuristics function ranks alternative paths in various search algorithms, at
rin
each branching step, based on the available information, so that a better path is
chosen. The main advantage of heuristic function is that it guides for which state to
explore now, while searching. It makes use of problem specific knowledge like
ee
constraints to check the goodness of a state to be explained. This drastically reduces
the required searching time.
gin
23. State the reason when hill climbing often gets stuck?
Local maxima are the state where hill climbing algorithm is sure to get struck.
Local maxima are the peak that is higher than each of its neighbour states, but lower
En
than the global maximum. So we have missed the better state here. All the search
procedure turns out to be wasted here. It is like a dead end.
arn
cost to reach the goal state. It means that h(n) gives true cost to reach the goal state
‘n’. The admissible heuristic for TSP is
a. Minimum spanning tree.
w.
25. What do you mean by local maxima with respect to search technique?
Local maximum is the peak that is higher than each of its neighbour states, but
lowers than the global maximum i.e. a local maximum is a tiny hill on the surface
whose peak is not as high as the main peak (which is a optimal solution). Hill
climbing fails to find optimum solution when it encounters local maxima. Any small
move, from here also makes things worse (temporarily). At local maxima all the
search procedure turns out to be wasted here. It is like a dead end.
www.LearnEngineering.in
www.LearnEngineering.in
Ridge and plateau in hill climbing can be avoided using methods like
backtracking, making big jumps. Backtracking and making big jumps help to avoid
plateau, whereas, application of multiple rules helps to avoid the problem of ridges.
n
It finds solution slow as It finds a solution more quickly.
Performance compared to an informed
g.i
search.
Completion It is always complete. It may or may not be complete.
Cost Factor Cost is high. Cost is low.
rin
It consumes moderate time It consumes less time because of
Time
because of slow searching. quick searching.
No suggestion is given There is a direction given about
Direction ee
regarding the solution in it. the solution.
It is lengthier while It is less lengthy while
Implementation
implemented. implemented.
gin
It is comparatively less It is more efficient as efficiency
efficient as incurred cost is takes into account cost and
Efficiency more and the speed of finding performance. The incurred cost
the Breadth-First solution is is less and speed of finding
En
Size of search Solving a massive search task Having a wide scope in terms of
problems is challenging. handling large search problems.
Example Example
a) Breadth first search a) Best first search
Le
www.LearnEngineering.in
www.LearnEngineering.in
In a game of chance, we can add extra level of chance nodes in game search tree.
These nodes have successors which are the outcomes of random element. The
minimax algorithm uses probability P attached with chance node di based on this
value. Successor function S(N,di) give moves from position N for outcome di
Part B
1. Enumerate Classical “Water jug Problem”. Describe the state space for this
problem and also give the solution.
2. How to define a problem as state space search? Discuss it with the help of an
example
n
3. Solve the given problem. Describe the operators involved in it.
g.i
Consider a Water Jug Problem : You are given two jugs, a 4-gallon one and
a 3-gallon one. Neither has any measuring markers on it. There is a pump
that can be used to fill the jugs with water. How can you get exactly 2 gallons
rin
of water into the 4-gallon jug ? Explicit Assumptions: A jug can be filled
from the pump, water can be poured out of a jug onto the ground, water can
be poured from one jug to another and that there are no other measuring
ee
devices available.
4. Define the following problems. What types of control strategy is used in the
gin
following problem.
i.The Tower of Hanoi
ii.Crypto-arithmetic
iii.The Missionaries and cannibals problems
En
iv.8-puzzle problem
5. Discuss uninformed search methods with examples.
6. Give an example of a problem for which breadth first search would work
arn
9. Explain AO* algorithm with a suitable example. State the limitations in the
algorithm?
10. Explain the nature of heuristics with example. What is the effect of heuristics
w.
accuracy?
11. Explain the various types of hill climbing search techniques.
ww
12. Discuss about constraint satisfaction problem with a algorithm for solving a
crypt arithmetic Problem.
13. Solve the following Crypt arithmetic problem using constraints satisfaction
search procedure.
CROSS
+ROADS
------------
DANGER
----------------
www.LearnEngineering.in
www.LearnEngineering.in
14. Explain alpha-beta pruning algorithm and the Minmax game playing
algorithm with example?
15. Solve the given problem. Describe the operators involved in it.
Consider a water jug problem: You are given two jugs, a 4-gallon one and a
3-gallon one. Neither have any measuring Markers on it. There is a pump
that can be used to fill the jug with water. How can you get exactly 2 gallons
of water into the 4 gallon jug? Explicit Assumptions: A jug can be filled from
the pump, water can be poured out of a jug onto the ground, water can be
poured from one jug to another and that there are no other measuring
devices available.
n
UNIT II PROBABILISTIC REASONING
g.i
Acting under uncertainty – Bayesian inference – naïve bayes models. Probabilistic
reasoning – Bayesian networks – exact inference in BN – approximate inference in BN –
causal networks.
rin
Part A
1. Why does uncertainty arise? ee
Agents almost never have access to the whole truth about their environment.
Uncertainty arises because of both laziness and ignorance. It is inescapable in
complex, nondeterministic, or partially observable environments
gin
Agents cannot find a categorical answer.
Uncertainty can also arise because of incompleteness, incorrectness in agents
understanding of properties of environment.
En
agent, and that the agent will prefer states with higher utility.
ww
www.LearnEngineering.in
www.LearnEngineering.in
n
P(A|B). Bayes' theorem allows updating the probability prediction of an event by
observing new information of the real world.
g.i
Example: If cancer corresponds to one's age then by using Bayes' theorem,
we can determine the probability of cancer more accurately with the help of age.
rin
P(A/B)=[P(A)*P(B/A)]/P(B)
0.4 = (0.3*P(B/A))/0.5
En
P(B/A) = 0.66
probability distribution, and also use probability theory for prediction and
anomaly detection.
A Bayesian network is a directed graph in which each node is annotated with
quantitative probability information. The full specification is as follows:
w.
Part B
www.LearnEngineering.in
www.LearnEngineering.in
n
8. How to get the approximate inference from Bayesian network.
9. Construct a Bayesian Network and define the necessary CPTs for the given
g.i
scenario. We have a bag of three biased coins a,b and c with probabilities of
coming up heads of 20%, 60% and 80% respectively. One coin is drawn
randomly from the bag (with equal likelihood of drawing each of the three
rin
coins) and then the coin is flipped three times to generate the outcomes X1,
X2 and X3.
a. Draw a Bayesian network corresponding to this setup and define the
ee
relevant CPTs.
b. Calculate which coin is most likely to have been drawn if the flips come
up HHT
gin
10. Consider the following set of propositions
Patient has spots
Patient has measles
En
www.LearnEngineering.in
www.LearnEngineering.in
PART - A
n
programming in order to automatically learn and improve with experience. For
example: Robots are programed so that they can perform the task based on data
g.i
they gather from sensors. It automatically learns programs from data.
rin
Machine learning relates with the study, design and development of the
algorithms that give computers the capability to learn without being explicitly
programmed. While, data mining can be defined as the process in which the
ee
unstructured data tries to extract knowledge or unknown interesting patterns.
The possibility of overfitting exists as the criteria used for training the model
is not the same as the criteria used to judge the efficacy of a model.
you can use a technique known as cross validation. In this method the dataset
splits into two section, testing and training datasets, the testing dataset will only
test the model while, in training dataset, the datapoints will come up with the
ww
www.LearnEngineering.in
www.LearnEngineering.in
Supervised Learning
Unsupervised Learning
Semi-supervised Learning
Reinforcement Learning
Transduction
Learning to Learn
n
8. What are the three stages to build the hypotheses or model in machine
g.i
learning?
Model building
Model testing
Applying the model
rin
9. What is the standard approach to supervised learning?
The standard approach to supervised learning is to split the set of example into
ee
the training set and the test.
gin
10. What is ‘Training set’ and ‘Test set’?
In various areas of information science like machine learning, a set of data is
used to discover the potentially predictive relationship known as ‘Training Set’.
Training set is an examples given to the learner, while Test set is used to test the
En
accuracy of the hypotheses generated by the learner, and it is the set of example
held back from the learner. Training set are distinct from Test set.
arn
11. What is the difference between artificial learning and machine learning?
Designing and developing algorithms according to the behaviours based on
empirical data are known as Machine Learning. While artificial intelligence in
addition to machine learning, it also covers other aspects like knowledge
Le
13. What is the main key difference between supervised and unsupervised
machine learning?
supervised learning Unsupervised learning
The supervised learning technique needs Unsupervised learning does not
labelled data to train the model. For need any labelled dataset. This is
example, to solve a classification problem the main key difference between
(a supervised learning task), you need to supervised learning and
have label data to train the model and to unsupervised learning.
classify the data into your labelled groups.
www.LearnEngineering.in
www.LearnEngineering.in
n
demerit of the linear model is overfitting. Similarly, underfitting is also a
significant disadvantage of the linear model.
g.i
16. What is the difference between classification and regression?
Classification is used to produce discrete results; classification is used to
rin
classify data into some specific categories. For example, classifying emails into
spam and non-spam categories. Whereas, we use regression analysis when we are
dealing with continuous data, for example predicting stock prices at a certain point
in time. ee
17. What is the difference between stochastic gradient descent (SGD) and
gin
gradient descent (GD)?
Both algorithms are methods for finding a set of parameters that minimize a
loss function by evaluating parameters against data and then making adjustments.
In standard gradient descent, you'll evaluate all training samples for each set of
En
parameters. This is akin to taking big, slow steps toward the solution. In stochastic
gradient descent, you'll evaluate only 1 training sample for the set of parameters
before updating them. This is akin to taking small, quick steps toward the solution.
arn
19. What is the difference between least squares regression and multiple
regression?
The goal of multiple linear regression is to model the linear relationship
ww
www.LearnEngineering.in
www.LearnEngineering.in
n
coefficients.
g.i
23. What are the advantages of Bayesian Regression?
Extremely efficient when the dataset is tiny.
Particularly well-suited for online learning as opposed to batch learning,
rin
when we know the complete dataset before we begin training the model.
This is so that Bayesian Regression can be used without having to save
data.
ee
The Bayesian technique has been successfully applied and is quite strong
mathematically. Therefore, using this requires no additional prior
knowledge of the dataset.
gin
for our dataset, and the regular probability approach does the task more
effectively.
arn
Decision Tree
Support Vector Machines
w.
intrinsically two-class. For multiclass problem you will need to reduce it into
multiple binary classification problems. Random Forest works well with a mixture
of numerical and categorical features.
www.LearnEngineering.in
www.LearnEngineering.in
n
Discriminative models are a class of supervised machine learning models
which make predictions by estimating conditional probability P(y|x). In order to
g.i
use a generative model, more unknowns should be solved: one has to estimate
probability of each class and probability of observation given class.
rin
31. What is SVM?
It is a supervised learning algorithm used both for classification and regression
problems. A type of discriminative modelling, support vector machine (SVM)
ee
creates a decision boundary to segregate n-dimensional space into classes. The
best decision boundary is called a hyperplane created by choosing the extreme
points called the support vectors.
gin
32. What is Decision tree?
A type of supervised machine learning model where data is continuously split
according to certain parameters. It has two main entities–decision nodes and
En
leaves. While leaves are the final outcomes or decisions, nodes are the points
where data is split.
arn
regression tasks.
34. What is Decision Tree Classification?
A decision tree builds classification (or regression) models as a tree structure,
w.
with datasets broken up into ever-smaller subsets while developing the decision
tree, literally in a tree-like way with branches and nodes. Decision trees can
handle both categorical and numerical data.
ww
www.LearnEngineering.in
www.LearnEngineering.in
36. Do you think 50 small decision trees are better than a large one? Why?
Yes. Because a random forest is an ensemble method that takes many weak
decision trees to make a strong learner. Random forests are more accurate, more
robust, and less prone to overfitting.
37. You’ve built a random forest model with 10000 trees. You got delighted after
getting training error as 0.00. But, the validation error is 34.23. What is going
on? Haven’t you trained your model perfectly?
n
The model has overfitted. Training error 0.00 means the classifier has
mimicked the training data patterns to an extent, that they are not available in the
g.i
unseen data. Hence, when this classifier was run on an unseen sample, it couldn’t
find those patterns and returned predictions with higher error. In a random forest,
it happens when we use a larger number of trees than necessary. Hence, to avoid
rin
this situation, we should tune the number of trees using cross-validation.
38. When would you use random forests vs SVM and why?
ee
There are a couple of reasons why a random forest is a better choice of the
model than asupport vector machine:
● Random forests allow you to determine the feature importance. SVM’s can’t
gin
do this.
● Random forests are much quicker and simpler to build than an SVM.
● For multi-class classification problems, SVMs require a one-vs-rest method,
which is less scalable and more memory intensive.
En
Part – B
1. Assume a disease so rare that it is seen in only one person out of every
arn
million. Assume also that we have a test that is effective in that if a person has
the disease, there is a 99 percent chance that the test result will be positive;
however, the test is not perfect, and there is a one in a thousand chance that
the test result will be positive on a healthy person. Assume that a new patient
Le
arrives and the test result is positive. What is the probability that the patient
has the disease?
2. Explain Naïve Bayes Classifier with an Example.
w.
explanation with a diagram. Explain the use of all the terms and constants
that you introduce and comment on the range of values that they can take.
6. Explain the following
a) Linear regression
b) Logistic Regression
www.LearnEngineering.in
www.LearnEngineering.in
PART - A
1. What is bagging and boosting in ensemble learning?
Bagging is a way to decrease the variance in the prediction by generating additional
data for training from dataset using combinations with repetitions to produce multi-sets of the
original data. Boosting is an iterative technique which adjusts the weight of an observation
n
based on the last classification.
g.i
2. What is stacking in ensemble learning?
Stacking is one of the most popular ensemble machine learning techniques used to
predict multiple nodes to build a new model and improve model performance. Stacking
rin
enables us to train multiple models to solve similar problems, and based on their combined
output, it builds a new model with improved performance.
ee
3. Which are the three types of ensemble learning?
The three main classes of ensemble learning methods are bagging, stacking, and
boosting, and it is important to both have a detailed understanding of each method and to
gin
consider them on your predictive modeling project.
related; they are: Performance: An ensemble can make better predictions and achieve better
performance than any single contributing model. Robustness: An ensemble reduces the
spread or dispersion of the predictions and model performance.
arn
aggregating criteria can be combined decision of voting for each estimator output
8. What are Gaussian mixture models How is expectation maximization used in it?
Expectation maximization provides an iterative solution to maximum
likelihood estimation with latent variables. Gaussian mixture models are an approach
www.LearnEngineering.in
www.LearnEngineering.in
to density estimation where the parameters of the distributions are fit using the
expectation-maximization algorithm.
9. What is k-means unsupervised learning?
K-Means clustering is an unsupervised learning algorithm. There is no labeled
data for this clustering, unlike in supervised learning. K-Means performs the division
of objects into clusters that share similarities and are dissimilar to the objects
belonging to another cluster. The term 'K' is a number.
n
algorithm. K in K-Means refers to the number of clusters, whereas K in KNN is the
number of nearest neighbors (based on the chosen distance metric).
g.i
11. What is expectation maximization algorithm used for?
` The EM algorithm is used to find (local) maximum likelihood parameters of a
rin
statistical model in cases where the equations cannot be solved directly. Typically
these models involve latent variables in addition to unknown parameters and known
data observations.
ee
12. What is the advantage of Gaussian process?
Gaussian processes are a powerful algorithm for both regression and
gin
classification. Their greatest practical advantage is that they can give a reliable
estimate of their own uncertainty.
M-step: update the hypothesis h for the distributional class parameters based
on the new data assignments.
w.
Part – B
1. Explain briefly about unsupervised learning structure?
2. Explain various learning techniques involved in unsupervised learning?
3. What is Gaussian process? And explain in detail of Gaussian parameter
estimates with suitable examples.
4. Explain the concepts of clustering approaches. How it differ from classification.
5. List the applications of clustering and identify advantages and disadvantages of
clustering algorithm.
6. Explain about EM algorithm.
www.LearnEngineering.in
www.LearnEngineering.in
n
g.i
2. Which activation function is used in multilayer perceptron?
Image result for Perceptron - Multilayer perceptron, activation functions
The Sigmoid Activation Function: Activation in Multilayer Perceptron Neural Networks.
rin
3. What are the activation functions of MLP?
In MLP and CNN neural network models, ReLU is the default activation function for
ee
hidden layers. In RNN neural network models, we use the sigmoid or tanh function for
hidden layers. The tanh function has better performance. Only the identity activation function
is considered linear.
gin
4. Does MLP have activation function?
Multilayer perceptrons (MLP) has been proven to be very successful in many applications
including classification. The activation function is the source of the MLP power. Careful
En
selection of the activation function has a huge impact on the network performance.
The Perceptron was only capable of handling linearly separable data hence the multi-layer
perception was introduced to overcome this limitation. An MLP is a neural network capable
of handling both linearly separable and non-linearly separable data.
Le
Linear Function
Sigmoid
Tanh
ww
ReLU
Leaky ReLU
Parameterised ReLU
Exponential Linear Unit
www.LearnEngineering.in
www.LearnEngineering.in
n
10. What do you mean by activation function?
g.i
An activation function is a function used in artificial neural networks which outputs a
small value for small inputs, and a larger value if its inputs exceed a threshold. If the inputs
are large enough, the activation function "fires", otherwise it does nothing.
rin
11. What are the limitations of perceptron?
Perceptron networks have several limitations. First, the output values of a perceptron can
ee
take on only one of two values (0 or 1) because of the hard-limit transfer function. Second,
perceptrons can only classify linearly separable sets of vectors.
gin
12. How many layers are there in perceptron?
This is known as a two-layer perceptron. It consists of two layers of neurons. The first
layer is known as hidden layer, and the second layer, known as the output layer, consists of a
single neuron.
En
suitable to large-scale datasets. But since the gradient it's not computed for the entire dataset,
and only for one random point on each iteration, the updates have a higher variance.
Gradient Descent is the most common optimization algorithm and the foundation of how
we train an ML model. But it can be really slow for large datasets. That's why we use a
variant of this algorithm known as Stochastic Gradient Descent to make our model learn a lot
faster.
16. What is stochastic gradient descent and why is it used in the training of neural
networks?
Stochastic Gradient Descent is an optimization algorithm that can be used to train neural
network models. The Stochastic Gradient Descent algorithm requires gradients to be
calculated for each variable in the model so that new values for the variables can be
calculated.
www.LearnEngineering.in
www.LearnEngineering.in
17. What are the three main types gradient descent algorithm?
There are three types of gradient descent learning algorithms: batch gradient descent,
stochastic gradient descent and mini-batch gradient descent.
19. How do you solve the vanishing gradient problem within a deep neural network?
n
The vanishing gradient problem is caused by the derivative of the activation function used
to create the neural network. The simplest solution to the problem is to replace the activation
g.i
function of the network. Instead of sigmoid, use an activation function such as ReLU
rin
Key among the limitations of ReLU is the case where large weight updates can mean that
the summed input to the activation function is always negative, regardless of the input to the
network. This means that a node with this problem will forever output an activation value of
0.0. This is referred to as a “dying ReLU“ ee
21. Why is ReLU used in deep learning?
gin
The ReLU function is another non-linear activation function that has gained popularity in
the deep learning domain. ReLU stands for Rectified Linear Unit. The main advantage of
using the ReLU function over other activation functions is that it does not activate all the
neurons at the same time.
En
Generally , we use ReLU in hidden layer to avoid vanishing gradient problem and better
computation performance , and Softmax function use in last output layer .
Part – B
Le
1. Draw the architecture of a single layer perceptron (SLP) and explain its
operation. Mention its advantages and disadvantages.
w.
www.LearnEngineering.in
lOMoARcPSD|26586732
Humans depend more and more on machines for their day-to-day things. Machines have
created a revolution, and no human can think of a life without machines.
A machine is only a device consisting of different parts, and is used for performing different
functions. They do not have life, as they are mechanical. On the other hand, humans are made
of flesh and blood; life is just not mechanical for humans.
Humans have feelings and emotions, and they can express these emotions; happiness and
sorrow are part of one’s life. On the other hand, machines have no feelings and emotions.
They just work as per the details fed into their mechanical brain.
Humans have the capability to understand situations, and behave accordingly. On the
contrary, Machines do not have this capability.
While humans behave according to their consciousness, machines perform as they are taught.
Humans perform activities as per their own intelligence. On the contrary, machines only have
an artificial intelligence.
It is a man-made intelligence that the machines have. The brilliance of the intelligence of a
machine depends on the intelligence of the humans that created it.
Another striking difference that can be seen is that humans can do anything original, and
machines cannot. Machines have limitations to their performance because they need humans
to guide them.
Humans have the capability to understand situations, and behave accordingly. On the
contrary, machines do not have this capability.
While humans behave as per their consciousness, machines just perform as they are taught.
2. Explain the schematic of AI’S agent performing action. (Dec-09, 12, 14, May-12).
search algorithms are also called blind search algorithms. The search algorithm produces the search
tree without using any domain knowledge, which is the brute force in nature. They are different from
informed search algorithms in a way that you check for a goal when a node is generated or expanded,
and they don’t have any background information on how to approach the goal.
It occupies a lot of memory space, and time to execute when the solution is at the bottom or
end of the tree and uses the FIFO queue.
Time Complexity of BFS is expressed as T (n) = 1+n2+n3+…….+ nd= O (nd) and;
Space Complexity of BFS is O (nd).
The breadth-first search algorithm is complete.
The optimal solution is possible to obtain from BFS.
Unlike the BFS, the DFS requires very less space in the memory because of the way it stores
the nodes stack only on the path it explores depth-wise.
In comparison to BFS, the execution time is also less if the expansion of nodes is correct. If
the path is not correct, then the recursion continues, and there is no guarantee that one may
find the solution. This may result in an infinite loop formation.
The DFS is complete only with finite state space.
Time Complexity is expressed as T(n) = 1+ n2+ n3+………+ nm=O(nm).
The Space Complexity is expressed as O (bm).
The DFS search algorithm is not optimal, and it may generate large steps and possibly high
cost to find the solution.
o SFV: The Standard failure value which tells that there is no solution to the problem.
o CFV: The Cutoff failure value tells that there is no solution within the given depth.
The expansion takes place on the basis of cost from the root. The UCS is implemented using a
priority queue.
The UCS does not care for the number of steps, and so it may end up an infinite loop.
The uniform-cost search algorithm is known to be complete.
Time Complexity can be expressed as O(b1 + [C*/ε])/
Space Complexity is expressed as O(b1 + [C*/ε]).
We can say that UCs is the optimal algorithm as it chooses the path with the lowest cost only.
6. Explain the Mini-Max algorithm and how it is work for game tic-tac-toe. (dec-
03,04, May -09,10, 17 , 19)
Mini-max algorithm is a recursive or backtracking algorithm which is used in decision-
making and game theory. It provides an optimal move for the player assuming that opponent is
also playing optimally.
Min-Max algorithm is mostly used for game playing in AI. Such as Chess, Checkers, tic-tac-
toe, go, and various tow-players game. This Algorithm computes the minimax decision for the
current state.
In this algorithm two players play the game, one is called MAX and other is called MIN.
Both the players fight it as the opponent player gets the minimum benefit while they get the
maximum benefit.
Both Players of the game are opponent of each other, where MAX will select the maximized
value and MIN will select the minimized value.
The minimax algorithm performs a depth-first search algorithm for the exploration of the
complete game tree.
The minimax algorithm proceeds all the way down to the terminal node of the tree, then
backtrack the tree as the recursion.
o In this example, there are two players one is called Maximizer and other is called Minimizer.
o Maximizer will try to get the Maximum possible score, and Minimizer will try to get the
minimum possible score.
o This algorithm applies DFS, so in this game-tree, we have to go all the way through the leaves
to reach the terminal nodes.
o At the terminal node, the terminal values are given so we will compare those value and
backtrack the tree until the initial state occurs. Following are the main steps involved in
solving the two-player game tree:
Step-1: In the first step, the algorithm generates the entire game-tree and applies the utility function
to get the utility values for the terminal states. In the below tree diagram, let's take A is the initial state
of the tree. Suppose maximizer takes first turn which has worst-case initial value =- infinity, and
minimizer will take next turn which has worst-case initial value = +infinity.
Step 2: Now, first we find the utilities value for the Maximizer, its initial value is -∞, so we will
compare each value in terminal state with initial value of Maximizer and determines the higher nodes
values. It will find the maximum among the all.
o For node D max(-1,- -∞) => max(-1,4)= 4
o For Node E max(2, -∞) => max(2, 6)= 6
o For Node F max(-3, -∞) => max(-3,-5) = -3
o For node G max(0, -∞) = max(0, 7) = 7
Step 3: In the next step, it's a turn for minimizer, so it will compare all nodes value with +∞, and will
find the 3rd layer node values.
o For node B= min(4,6) = 4
o For node C= min (-3, 7) = -3
Step 4: Now it's a turn for Maximizer, and it will again choose the maximum of all nodes value and
find the maximum value for the root node. In this game tree, there are only 4 layers, hence we reach
immediately to the root node, but in real games, there will be more than 4 layers.
o For node A max(4, -3)= 4
Properties of Mini-Max
algorithm:
o Complete- Min-Max algorithm is
Complete. It will definitely find a
solution (if exist), in the finite
search tree.
o Optimal- Min-Max algorithm is
optimal if both opponents are
playing optimally.
o Time complexity- As it performs
DFS for the game-tree, so the
time complexity of Min-Max
algorithm is O(bm), where b is branching factor of the game-tree, and m is the maximum
depth of the tree.
o Space Complexity- Space complexity of Mini-max algorithm is also similar to DFS which
is O(bm).
A description for the algorithm, assuming X is the "turn taking player," would look
something like:
You'll notice that this algorithm is recursive; it flips back and forth between the
players until a final score is found. Let’s walk through the algorithm's execution with
the full move tree, and show why, algorithmically, the instant winning move will be
picked:
It's X's turn in state 1. X generates the states 2, 3, and 4 and calls minimax on
those states.
State 2 pushes the score of +10 to state 1's score list, because the game is in an
end state.
State 3 and 4 are not in end states, so 3 generates states 5 and 6 and calls
minimax on them, while state 4 generates states 7 and 8 and calls minimax on
them.
State 5 pushes a score of -10 onto state 3's score list, while the same happens
for state 7 which pushes a score of -10 onto state 4's score list.
State 6 and 8 generate the only available moves, which are end states, and so
both of them add the score of +10 to the move lists of states 3 and 4.
Because it is O's turn in both state 3 and 4, O will seek to find the minimum
score, and given the choice between -10 and +10, both states 3 and 4 will yield
-10.
Finally the score list for states 2, 3, and 4 are populated with +10, -10 and -10
respectively, and state 1 seeking to maximize the score will chose the winning
move with score +10, state 2.
That is certainly a lot to take in. And that is why we have a computer execute this
algorithm.
Alpha-Beta Pruning
o Alpha-beta pruning is a modified version of the minimax algorithm. It is an optimization
technique for the minimax algorithm.
o As we have seen in the minimax search algorithm that the number of game states it has to
examine are exponential in depth of the tree. Since we cannot eliminate the exponent, but we
can cut it to half. Hence there is a technique by which without checking each node of the
game tree we can compute the correct minimax decision, and this technique is called pruning.
This involves two threshold parameter Alpha and beta for future expansion, so it is
called alpha-beta pruning. It is also called as Alpha-Beta Algorithm.
o Alpha-beta pruning can be applied at any depth of a tree, and sometimes it not only prune the
tree leaves but also entire sub-tree.
o The two-parameter can be defined as:
a. Alpha: The best (highest-value) choice we have found so far at any point along the
path of Maximizer. The initial value of alpha is -∞.
b. Beta: The best (lowest-value) choice we have found so far at any point along the path
of Minimizer. The initial value of beta is +∞.
o The Alpha-beta pruning to a standard minimax algorithm returns the same move as the
standard algorithm does, but it removes all the nodes which are not really affecting the final
decision but making algorithm slow. Hence by pruning these nodes, it makes the algorithm
fast.
Let's take an example of two-player search tree to understand the working of Alpha-beta pruning
Step 1: At the first step the, Max player will start first move from node A where α= -∞ and β= +∞,
these value of alpha and beta passed down to node B where again α= -∞ and β= +∞, and Node B
passes the same value to its child D.
Step 2: At Node D, the value of α will be calculated as its turn for Max. The value of α is compared
with firstly 2 and then 3, and the max (2, 3) = 3 will be the value of α at node D and node value will
also 3.
Step 3: Now algorithms backtrack to node B, where the value of β will change as this is a turn of
Min, Now β= +∞ will compare with the available subsequent nodes value, i.e. min (∞, 3) = 3, hence
at node B now α= -∞, and β= 3. In the next step, algorithm traverse the next successor of Node B
which is node E, and the values of α= -∞, and β= 3 will also be passed.
Step 4: At node E, Max will take its turn, and the value of alpha will change. The current value of
alpha will be compared with 5, so max (-∞, 5) = 5, hence at node E α= 5 and β= 3, where α>=β, so
the right successor of E will be pruned, and algorithm will not traverse it, and the value at node E will
be 5.
Step 5: At next step, algorithm again backtrack the tree, from node B to node A. At node A, the value
of alpha will be changed the maximum available value is 3 as max (-∞, 3)= 3, and β= +∞, these two
values now passes to right successor of A which is Node C.
At node C, α=3 and β= +∞, and the same values will be passed on to node F.
Step 6: At node F, again the value of α will be compared with left child which is 0, and max(3,0)= 3,
and then compared with right child which is 1, and max(3,1)= 3 still α remains 3, but the node value
of F will become 1.
Step 7: Node F returns the node value 1 to node C, at C α= 3 and β= +∞, here the value of beta will
be changed, it will compare with 1 so min (∞, 1) = 1. Now at C, α=3 and β= 1, and again it satisfies
the condition α>=β, so the next child of C which is G will be pruned, and the algorithm will not
compute the entire sub-tree G.
Step 8: C now returns the value of 1 to A here the best value for A is max (3, 1) = 3. Following is the
final game tree which is the showing the nodes which are computed and nodes which has never
computed. Hence the optimal value for the maximizer is 3 for this example.
The effectiveness of alpha-beta pruning is highly dependent on the order in which each node is
examined. Move order is an important aspect of alpha-beta pruning. It can be of two types:
o Worst ordering: In some cases, alpha-beta pruning algorithm does not prune any of the
leaves of the tree, and works exactly as minimax algorithm. In this case, it also consumes
more time because of alpha-beta factors, such a move of pruning is called worst ordering. In
this case, the best move occurs on the right side of the tree. The time complexity for such an
order is O(bm).
o Ideal ordering: The ideal ordering for alpha-beta pruning occurs when lots of pruning
happens in the tree, and best moves occur at the left side of the tree. We apply DFS hence it
first search left of the tree and go deep twice as minimax algorithm in the same amount of
time. Complexity in ideal ordering is O (bm/2).
In the informed search we will discuss two main algorithms which are given below:
Advantages:
o Best first search can switch between BFS and DFS by gaining the advantages of both the
algorithms.
o This algorithm is more efficient than BFS and DFS algorithms.
Disadvantages:
o It can behave as an unguided depth-first search in the worst case scenario.
o It can get stuck in a loop as DFS.
o This algorithm is not optimal.
Example:
o Consider the below search problem, and we will traverse it using greedy best-first search. At
each iteration, each node is expanded using evaluation function f(n)=h(n) , which is given in
the below table.
In this search example, we are using two lists which are OPEN and CLOSED Lists. Following are
the iteration for traversing the above example.
Iteration2: Open[E,F,A],Closed[S,B]
: Open [E, A], Closed [S, B, F]
Complete: Greedy best-first search is also incomplete, even if the given state space is finite.
Optimal: Greedy best first search algorithm is not optimal.
Complexity: The worst case time complexity of Greedy best first search is O(bm).
Algorithm of A* search:
Step1: Place the starting node in the OPEN list.
Step 2: Check if the OPEN list is empty or not, if the list is empty then return failure and stops.
Step 3: Select the node from the OPEN list which has the smallest value of evaluation function (g+h),
if node n is goal node then return success and stop, otherwise
Step 4: Expand node n and generate all of its successors, and put n into the closed list. For each
successor n', check whether n' is already in the OPEN or CLOSED list, if not then compute
evaluation function for n' and place into Open list.
Step 5: Else if node n' is already in OPEN and CLOSED, then it should be attached to the back
pointer which reflects the lowest g(n') value.
Step 6: Return to Step 2.
Advantages:
o A* search algorithm is the best algorithm than other search algorithms.
Points to remember:
o A* algorithm returns the path which occurred first, and it does not search for all remaining
paths.
o The efficiency of A* algorithm depends on the quality of heuristic.
o A* algorithm expands all nodes which satisfy the condition f(n)<="" li="">
Time Complexity: The time complexity of A* search algorithm depends on heuristic function, and
the number of nodes expanded is exponential to the depth of solution d. So the time complexity is
O(b^d), where b is the branching factor.
This section examines the constraint optimization methodology, another form or real concern
method. By its name, constraints fulfillment implies that such an issue must be solved while adhering
to a set of restrictions or guidelines. Whenever a problem is actually variables comply with stringent
conditions of principles, it is said to have been addressed using the solving multi - objective method.
Wow what a method results in a study sought to achieve of the intricacy and organization of both the
issue.
For a constraint satisfaction problem (CSP), the following conditions must be met:
o States area
o Fundamental idea while behind remedy.
The definition of a state in phase space involves giving values to any or all of the parameters, like as
X1 = v1, X2 = v2, etc.
o Discrete Domain: This limitless area allows for the existence of a single state with numerous
variables. For instance, every parameter may receive a endless number of beginning states.
o It is a finite domain with continuous phases that really can describe just one area for just one
particular variable. Another name for it is constant area.
Basically, there are three different categories of limitations in regard towards the parameters:
o Unary restrictions are the easiest kind of restrictions because they only limit the value of one
variable.
o Binary resource limits: These restrictions connect two parameters. A value between x1 and x3
can be found in a variable named x2.
o Global Resource limits: This kind of restriction includes a unrestricted amount of variables.
The main kinds of restrictions are resolved using certain kinds of resolution methodologies:
o In linear programming, when every parameter carrying an integer value only occurs in linear
equation, linear constraints are frequently utilized.
o Non-linear Constraints: With non-linear programming, when each variable (an integer value)
exists in a non-linear form, several types of restrictions were utilized.
PROBABILISTIC REASONING
Uncertainty:
Till now, we have learned knowledge representation using first-order logic and propositional logic
with certainty, which means we were sure about the predicates. With this knowledge representation,
we might write A→B, which means if A is true then B is true, but consider a situation where we are
not sure about whether A is true or not then we cannot express this statement, this situation is called
uncertainty. So to represent uncertain knowledge, where we are not sure about the predicates, we need
uncertain reasoning or probabilistic reasoning.
Causes of uncertainty:
Following are some leading causes of uncertainty to occur in the real world.
1. Information occurred from unreliable sources.
2. Experimental Errors
3. Equipment fault
4. Temperature variation
5. Climate change.
Probabilistic reasoning:
Probabilistic reasoning is a way of knowledge representation where we apply the concept of
probability to indicate the uncertainty in knowledge. In probabilistic reasoning, we combine
probability theory with logic to handle the uncertainty.
We use probability in probabilistic reasoning because it provides a way to handle the
uncertainty that is the result of someone's laziness and ignorance.
In the real world, there are lots of scenarios, where the certainty of something is not
confirmed, such as "It will rain today," "behavior of someone for some situations," "A match
between two teams or two players."
These are probable sentences for which we can assume that it will happen but not sure about
it, so here we use probabilistic reasoning.
Probability: Probability can be defined as a chance that an uncertain event will occur. It is the
numerical measure of the likelihood that an event will occur. The value of probability always remains
between 0 and 1 that represent ideal uncertainties.
0 ≤ P(A) ≤ 1, where P(A) is the probability of an event A.
P(A) = 0, indicates total uncertainty in an event A.
P(A) =1, indicates total certainty in an event A.
We can find the probability of an uncertain event by using the below formula.
Posterior Probability: The probability that is calculated after all evidence or information has taken
into account. It is a combination of prior probability and new information.
Conditional probability:
Conditional probability is a probability of occurring an event when another event has already
happened.
Let's suppose, we want to calculate the event A when event B has already occurred, "the
probability of A under the conditions of B", it can be written as:
It can be explained by using the below Venn diagram, where B is occurred event, so sample space
will be reduced to set B, and now we can only calculate event A when event B is already occurred by
dividing the probability of P(A⋀B) by P( B ).
Bayes' theorem:
Bayes' theorem is also known as Bayes' rule, Bayes' law, or Bayesian reasoning, which determines
the probability of an event with uncertain knowledge. In probability theory, it relates the conditional
probability and marginal probabilities of two random events. Baye’s theorem was named after the
British mathematician Thomas Bayes. The Bayesian inference is an application of Baye’s theorem,
which is fundamental to Bayesian statistics. It is a way to calculate the value of P(B|A) with the
knowledge of P(A|B).
Bayes' theorem allows updating the probability prediction of an event by observing new
information of the real world.
Example: If cancer corresponds to one's age then by using Bayes' theorem, we can determine the
probability of cancer more accurately with the help of age.
Bayes' theorem can be derived using product rule and conditional probability of event A with
known event B: As from product rule we can write:
The above equation (a) is called as Bayes' rule or Bayes' theorem. This equation is basic of most
modern AI systems for probabilistic inference.
It shows the simple relationship between joint and conditional probabilities. Here,
P (A|B) is known as posterior, which we need to calculate, and it will be read as Probability
of hypothesis A when we have occurred an evidence B.
P (B|A) is called the likelihood, in which we consider that hypothesis is true, then we
calculate the probability of evidence.
P(A) is called the prior probability, probability of hypothesis before considering the
evidence
P (B) is called marginal probability, pure probability of evidence.
In the equation (a), in general, we can write P (B) = P(A)*P(B|Ai), hence the Bayes' rule can be
written as:
Where A1, A2, A3,........, An is a set of mutually exclusive and exhaustive events.
Bayes' rule allows us to compute the single term P(B|A) in terms of P(A|B), P(B), and P(A). This is
very useful in cases where we have a good probability of these three terms and want to determine the
fourth one. Suppose we want to perceive the effect of some unknown cause, and want to compute that
cause, then the Bayes' rule becomes:
o It is used to calculate the next step of the robot when the already executed step is given.
o Bayes' theorem is helpful in weather forecasting.
o It can solve the Monty Hall problem.
Bayesian network
o "A Bayesian network is a probabilistic graphical model which represents a set of variables and
their conditional dependencies using a directed acyclic graph."
o It is also called a Bayes network, belief network, decision network, or Bayesian model.
o Bayesian networks are probabilistic, because these networks are built from a probability
distribution, and also use probability theory for prediction and anomaly detection.
Real world applications are probabilistic in nature, and to represent the relationship between multiple
events, we need a Bayesian network. It can also be used in various tasks including prediction,
anomaly detection, diagnostics, automated insight, reasoning, time series prediction,
and decision making under uncertainty.
Bayesian Network can be used for building models from data and experts opinions, and it consists
of two parts:
o Directed Acyclic Graph
o Table of conditional probabilities.
The generalized form of Bayesian network that represents and solve decision problems under
uncertain knowledge is known as an Influence diagram.
A Bayesian network graph is made up of nodes and Arcs (directed links), where:
o Each node corresponds to the random variables, and a variable can be continuous or discrete.
o Arc or directed arrows represent the causal relationship or conditional probabilities between
random variables. These directed links or arrows connect the pair of nodes in the graph.
These links represent that one node directly influence the other node, and if there is no
directed link that means that nodes are independent with each other
o In the above diagram, A, B, C, and D are random variables represented by the nodes of
the network graph.
o If we are considering node B, which is connected with node A by a directed arrow,
then node A is called the parent of Node B.
o Node C is independent of node A.
Each node in the Bayesian network has condition probability distribution P(Xi |Parent(Xi) ), which
determines the effect of the parent on that node. Bayesian network is based on Joint probability
distribution and conditional probability. So let's first understand the joint probability distribution:
P[x1, x2, x3,....., xn], it can be written as the following way in terms of the joint probability
distribution.
= P[x1| x2, x3,....., xn]P[x2, x3,....., xn]
= P[x1| x2, x3,....., xn]P[x2|x3,....., xn]....P[xn-1|xn]P[xn].
In general for each variable Xi, we can write the equation as:
P (Xi|Xi-1,........., X1) = P(Xi |Parents(Xi ))
o DST is a mathematical theory of evidence based on belief functions and plausible reasoning.
It is used to combine separate pieces of information (evidence) to calculate the probability of
an event.
Example:
Let A represent the proposition "Moore is attractive". Then the axioms of probability insist
that P(A) + P(¬A) = 1. Now suppose that Andrew does not even know who "Moore" is, then Also, it
is not fair to say that he disbelieves the proposition. It would therefore be meaningful to denote
Andrew's belief B of B(A) and B(¬A) as both being 0.
Dempster-Shafer Model
The idea is to allocate a number between 0 and 1 to indicate a degree of belief on a proposal as
in the probability framework. However, it is not considered a probability but a belief mass. The
distribution of masses is called basic belief assignment.
In other words, in this formalism a degree of belief (referred as mass) is represented as
a belief function rather than a Bayesian probability distribution.
Suppose a system has five members, say five independent states, and exactly one of which is actual.
If the original set is called S, | S | = 5, then the set of all subsets (the power set) is called 2S. If each
possible subset as a binary vector (describing any member is present or not by writing 1 or 0 ),
then 25 subsets are possible, ranging from the empty subset ( 0, 0, 0, 0, 0 ) to the "everything" subset (
1, 1, 1, 1, 1 ).
The "empty" subset represents a "contradiction", which is not true in any state, and is thus assigned a
mass of one; The remaining masses are normalized so that their total is 1. The "everything" subset is
labeled as "unknown"; it represents the state where all elements are present one , in the sense that you
cannot tell which is actual.
Shafer's framework allows for belief about propositions to be represented as intervals, bounded by
two values, belief (or support) and plausibility:
belief ≤ plausibility
Belief in a hypothesis is constituted by the sum of the masses of all sets enclosed by it (i.e. the sum of
the masses of all subsets of the hypothesis). It is the amount of belief that directly supports a given
hypothesis at least in part, forming a lower bound.
Plausibility is 1 minus the sum of the masses of all sets whose intersection with the hypothesis is
empty. It is an upper bound on the possibility that the hypothesis could possibly happen, up to that
value, because there is only so much evidence that contradicts that hypothesis.
Example:
A proposition say "the cat in the box is dead." Suppose we have belief of 0.5 and plausibility of
0.8 for the proposition.
For example,
Suppose we have a belief of 0.5 for a proposition, say "the cat in the box is dead." This means that
we have evidence that allows us to state strongly that the proposition is true with a confidence of 0.5.
However, the evidence contrary to that hypothesis (i.e. "the cat is alive") only has a confidence of 0.2.
The remaining mass of 0.3 (the gap between the 0.5 supporting evidence on the one hand, and the 0.2
contrary evidence on the other) is "indeterminate," meaning that the cat could either be dead or alive.
This interval represents the level of uncertainty based on the evidence in the system.
The "neither" hypothesis is set to zero by definition (it corresponds to "no solution"). The
orthogonal hypotheses "Alive" and "Dead" have probabilities of 0.2 and 0.5, respectively.
This could correspond to "Live/Dead Cat Detector" signals, which have respective reliabilities
of 0.2 and 0.5.
Finally, the all-encompassing "Either" hypothesis (which simply acknowledges there is a cat in
the box) picks up the slack so that the sum of the masses is 1. The belief for the "Alive" and
"Dead" hypotheses matches their corresponding masses because they have no subsets; belief
for "Either" consists of the sum of all three masses (Either, Alive, and Dead) because "Alive"
and "Dead" are each subsets of "Either".
The "Alive" plausibility is 1 − m (Dead): 0.5 and the "Dead" plausibility is 1 − m (Alive): 0.8.
In other way, the "Alive" plausibility is m(Alive) + m(Either) and the "Dead" plausibility
is m(Dead) + m(Either).
Finally, the "Either" plausibility sums m(Alive) + m(Dead) + m(Either). The universal
hypothesis ("Either") will always have 100% belief and plausibility—it acts as a checksum of
sorts.
Advantages:
As we add more information, uncertainty interval reduces.
DST has much lower level of ignorance.
Diagnose hierarchies can be represented using this.
Person dealing with such problems is free to think about evidences.
Disadvantages:
In this, computation effort is high, as we have to deal with 2 n of sets.
These ML algorithms help to solve different business problems like Regression, Classification,
Forecasting, Clustering, and Associations, etc.
Based on the methods and way of learning, machine learning is divided into mainly four types, which
are:
1. Supervised Machine Learning
2. Unsupervised Machine Learning
3. Semi-Supervised Machine Learning
4. Reinforcement Learning
Example: Suppose we have an input dataset of cats and dog images. So, first, we will provide
the training to the machine to understand the images, such as the shape & size of the tail of cat and
dog, Shape of eyes, colour, height (dogs are taller, cats are smaller), etc. After completion of training,
we input the picture of a cat and ask the machine to identify the object and predict the output. Now,
the machine is well trained, so it will check all the features of the object, such as height, shape, color,
eyes, ears, tail, etc., and find that it's a cat. So, it will put it in the Cat category. This is the process of
how the machine identifies the objects in Supervised Learning.
The main goal of the supervised learning technique is to map the input variable(x) with the output
variable(y). Some real-world applications of supervised learning are Risk Assessment, Fraud
Detection, Spam filtering, etc.
Supervised machine learning can be classified into two types of problems, which are given
below:
o Classification
o Regression
a) Classification
Classification algorithms are used to solve the classification problems in which the output variable is
categorical, such as "Yes" or No, Male or Female, Red or Blue, etc. The classification algorithms
predict the categories present in the dataset. Some real-world examples of classification algorithms
are Spam Detection, Email filtering, etc.
Some popular classification algorithms are given below:
o Random Forest Algorithm
o Decision Tree Algorithm
o Logistic Regression Algorithm
o Support Vector Machine Algorithm
b) Regression
Regression algorithms are used to solve regression problems in which there is a linear relationship
between input and output variables. These are used to predict continuous output variables, such as
market trends, weather prediction, etc.
Advantages:
o Since supervised learning work with the labelled dataset so we can have an exact idea about
the classes of objects.
o These algorithms are helpful in predicting the output on the basis of prior experience.
Disadvantages:
o These algorithms are not able to solve complex tasks.
o It may predict the wrong output if the test data is different from the training data.
o It requires lots of computational time to train the algorithm.
Unsupervised Learning can be further classified into two types, which are given below:
o Clustering
o Association
Advantages:
o These algorithms can be used for complicated tasks compared to the supervised ones because
these algorithms work on the unlabeled dataset.
o Unsupervised algorithms are preferable for various tasks as getting the unlabeled dataset is
easier as compared to the labelled dataset.
Disadvantages:
o The output of an unsupervised algorithm can be less accurate as the dataset is not labelled, and
algorithms are not trained with the exact output in prior.
o Working with Unsupervised learning is more difficult as it works with the unlabelled dataset
that does not map with the output.
Linear regression algorithm shows a linear relationship between a dependent (y) and one or
more independent (y) variables, hence called as linear regression. Since linear regression
shows the linear relationship, which means it finds how the value of the dependent variable is
changing according to the value of the independent variable.
The linear regression model provides a sloped straight line representing the relationship
between the variables. Consider the below image:
y= a0+a1x+ ε
Here,
Y= Dependent Variable (Target Variable)
X= Independent Variable (predictor Variable)
a0= intercept of the line (Gives an additional degree of freedom)
a1 = Linear regression coefficient (scale factor to each input value).
ε = random error
The values for x and y variables are training datasets for Linear Regression model representation.
o SimpleLinearRegression:
If a single independent variable is used to predict the value of a numerical dependent variable,
then such a Linear Regression algorithm is called Simple Linear Regression.
o MultipleLinearregression:
If more than one independent variable is used to predict the value of a numerical dependent
variable, then such a Linear Regression algorithm is called Multiple Linear Regression.
o PositiveLinearRelationship:
If the dependent variable increases on the Y-axis and independent variable increases on X-
axis, then such a relationship is termed as a Positive linear relationship.
o NegativeLinearRelationship:
If the dependent variable decreases on the Y-axis and independent variable increases on the X-
axis, then such a relationship is called a negative linear relationship.
For Linear Regression, we use the Mean Squared Error (MSE) cost function, which is the average
of squared error occurred between the predicted values and actual values. It can be written as:
Where,
N=Total number of observation
Yi = Actual value
(a1xi+a0)= Predicted value.
Residuals: The distance between the actual value and predicted values is called residual. If the
observed points are far from the regression line, then the residual will be high, and so cost function
will high. If the scatter points are close to the regression line, then the residual will be small and
hence the cost function.
Gradient Descent:
o Gradient descent is used to minimize the MSE by calculating the gradient of the cost function.
o A regression model uses gradient descent to update the coefficients of the line by reducing the
cost function.
o It is done by a random selection of values of coefficient and then iteratively update the values
to reach the minimum cost function.
Model Performance:
The Goodness of fit determines how the line of regression fits the set of observations. The process of
finding the best model out of various models is called optimization.
o The curve from the logistic function indicates the likelihood of something such as whether the
cells are cancerous or not, a mouse is obese or not based on its weight, etc.
o Logistic Regression is a significant machine learning algorithm because it has the ability to
provide probabilities and classify new data using continuous and discrete datasets.
o Logistic Regression can be used to classify the observations using different types of data and
can easily determine the most effective variables used for the classification. The below image
is showing the logistic function:
o In Logistic Regression y can be between 0 and 1 only, so for this let's divide the above
equation by (1-y):
o But we need range between -[infinity] to +[infinity], then take logarithm of the equation it will
become:
The goal of the SVM algorithm is to create the best line or decision boundary that can
segregate n-dimensional space into classes so that we can easily put the new data point in the
correct category in the future. This best decision boundary is called a hyperplane.
SVM chooses the extreme points/vectors that help in creating the hyperplane. These extreme
cases are called as support vectors, and hence algorithm is termed as Support Vector Machine.
Consider the below diagram in which there are two different categories that are classified using a
decision boundary or hyperplane:
Example: SVM can be understood with the example that we have used in the KNN classifier.
Suppose we see a strange cat that also has some features of dogs, so if we want a model that can
accurately identify whether it is a cat or dog, so such a model can be created by using the SVM
algorithm. We will first train our model with lots of images of cats and dogs so that it can learn about
different features of cats and dogs, and then we test it with this strange creature. So as support vector
creates a decision boundary between these two data (cat and dog) and choose extreme cases (support
vectors), it will see the extreme case of cat and dog.
SVM algorithm can be used for Face detection, image classification, text categorization, etc.
Types of SVM
SVM can be of two types:
o Linear SVM: Linear SVM is used for linearly separable data, which means if a dataset can be
classified into two classes by using a single straight line, then such data is termed as linearly
separable data, and classifier is used called as Linear SVM classifier.
o Non-linear SVM: Non-Linear SVM is used for non-linearly separated data, which means if a
dataset cannot be classified by using a straight line, then such data is termed as non-linear data
and classifier used is called as Non-linear SVM classifier.
Hyperplane:
The dimensions of the hyperplane depend on the features present in the dataset, which means
if there are 2 features (as shown in image), then hyperplane will be a straight line. And if there
are 3 features, then hyperplane will be a 2-dimension plane.
Support Vectors:
The data points or vectors that are the closest to the hyperplane and which affect the position of the
hyperplane are termed as Support Vector. Since these vectors support the hyperplane, hence called a
Support vector.
Linear SVM:
The working of the SVM algorithm can be understood by using
an example. Suppose we have a dataset that has two tags (green
and blue), and the dataset has two features x1 and x2. We want a
classifier that can classify the pair(x1, x2) of coordinates in either
green or blue. Consider the below image:
Hence, the SVM algorithm helps to find the best line or decision boundary; this best boundary
or region is called as a hyperplane. SVM algorithm finds the closest point of the lines from both the
classes. These points are called support vectors. The distance between the vectors and the hyperplane
is called as margin. And the goal of SVM is to maximize this margin. The hyperplane with
maximum margin is called the optimal hyperplane.
Non-Linear SVM:
If data is linearly arranged, then we can separate it by using a straight line, but for non-linear data, we
cannot draw a single straight line. Consider the below image:
So to separate these data points, we need to add one more dimension. For linear data, we have used
two dimensions x and y, so for non-linear data, we will add a third dimension z. It can be calculated
as:
z=x2 +y2
By adding the third dimension, the sample space will become as below image:
So now, SVM will divide the datasets into classes in the following
way. Since we are in 3-d Space, hence it is looking like a plane
parallel to the x-axis. If we convert it in 2d space with z=1, then it
will become as:
o Decision nodes are used to make any decision and have multiple branches, whereas Leaf nodes are
the output of those decisions and do not contain any further branches.
o The decisions or the test are performed on the basis of features of the given dataset. It is a
graphical representation for getting all the possible solutions to a problem/decision based on given
conditions.
o It is called a decision tree because, similar to a tree, it starts with the root node, which expands on
further branches and constructs a tree-like structure. In order to build a tree, we use the CART
algorithm, which stands for Classification and Regression Tree algorithm.
o A decision tree simply asks a question, and based on the answer (Yes/No), it further split the tree
into subtrees. Below diagram explains the general structure of a decision tree:
There are various algorithms in Machine learning, so choosing the best algorithm for the given
dataset and problem is the main point to remember while creating a machine learning model. Below
are the two reasons for using the Decision tree:
o Decision Trees usually mimic human thinking ability while making a decision, so it is easy to
understand.
o The logic behind the decision tree can be easily understood because it shows a tree-like
structure.
Step-3: Divide the S into subsets that contains possible values for the best attributes.
Step-4: Generate the decision tree node, which contains the best attribute.
Step-5: Recursively make new decision trees using the subsets of the dataset created in step -3.
Continue this process until a stage is reached where you cannot further classify the nodes and
called the final node as a leaf node.
Example: Suppose there is a candidate who has a job offer and wants to decide whether he should
accept the offer or Not. So, to solve this problem, the decision tree starts with the root node (Salary
attribute by ASM). The root node splits further into the next decision node (distance from the office)
and one leaf node based on the corresponding labels. The next decision node further gets split into
one decision node (Cab facility) and one leaf node. Finally, the decision node splits into two leaf
nodes (Accepted offers and Declined offer). Consider the below diagram:
Ensemble methods fall into two broad categories, i.e., sequential ensemble techniques and
parallel ensemble techniques. Sequential ensemble techniques generate base learners in a sequence,
e.g., Adaptive Boosting (AdaBoost). The sequential generation of base learners promotes the
dependence between the base learners. The performance of the model is then improved by assigning
higher weights to previously misrepresented learners.
The majority of ensemble techniques apply a single algorithm in base learning, which results
in homogeneity in all base learners. Homogenous base learners refer to base learners of the
same type, with similar qualities. Other methods apply heterogeneous base learners, giving
rise to heterogeneous ensembles. Heterogeneous base learners are learners of distinct types.
1. Bagging
Bagging, the short form for bootstrap aggregating, is mainly applied in classification
and regression. It increases the accuracy of models through decision trees, which reduces
variance to a large extent. The reduction of variance increases accuracy, eliminating
overfitting, which is a challenge to many predictive models.
Bagging is classified into two types, i.e., bootstrapping and aggregation. Bootstrapping is a
sampling technique where samples are derived from the whole population (set) using the
replacement procedure. The sampling with replacement method helps make the selection
procedure randomized. The base learning algorithm is run on the samples to complete the
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. Therefore, the aggregation is based on the probability
bootstrapping procedures or on the basis of all outcomes of the predictive models.
Bagging is advantageous since weak base learners are combined to form a single strong learner
that is more stable than single learners. It also eliminates any variance, thereby reducing the
overfitting of models. One limitation of bagging is that it is computationally expensive. Thus, it can
lead to more bias in models when the proper procedure of bagging is ignored.
2. Boosting
Boosting is an ensemble technique that learns from previous predictor mistakes to make better
predictions in the future. The technique combines several weak base learners to form one
strong learner, thus significantly improving the predictability of models. Boosting works by
arranging weak learners in a sequence, such that weak learners learn from the next learner in
the sequence to create better predictive models.
Boosting takes many forms, including gradient boosting, Adaptive Boosting (AdaBoost), and
XGBoost (Extreme Gradient Boosting). AdaBoost uses weak learners in the form of decision
trees, which mostly include one split that is popularly known as decision stumps. AdaBoost’s
main decision stump comprises observations carrying similar weights.
Gradient boosting adds predictors sequentially to the ensemble, where preceding predictors
correct their successors, thereby increasing the model’s accuracy. New predictors are fit to
counter the effects of errors in the previous predictors. The gradient of descent helps the
gradient booster identify problems in learners’ predictions and counter them accordingly.
3. Stacking
Stacking, another ensemble method is often referred to as stacked generalization. This technique
works by allowing a training algorithm to ensemble several other similar learning algorithm
predictions. Stacking has been successfully implemented in regression, density estimations, distance
learning, and classifications. It can also be used to measure the error rate involved during bagging.
Variance Reduction
Ensemble methods are ideal for reducing the variance in models, thereby increasing the accuracy
of predictions. The variance is eliminated when multiple models are combined to form a single
prediction that is chosen from all other possible predictions from the combined models. An ensemble
of models combines various models to ensure that the resulting prediction is the best possible, based
on the consideration of all predictions.
1. Max Voting
2. Averaging
3. Weighted Averaging
It allows us to cluster the data into different groups and a convenient way to discover the
categories of groups in the unlabeled dataset on its own without the need for any training.
It is a centroid-based algorithm, where each cluster is associated with a centroid. The main
aim of this algorithm is to minimize the sum of distances between the data point and their
corresponding clusters.
The algorithm takes the unlabeled dataset as input, divides the dataset into k-number of
clusters, and repeats the process until it does not find the best clusters. The value of k should
be predetermined in this algorithm.
The k-means clustering algorithm mainly performs two tasks:
o Determines the best value for K center points or centroids by an iterative process.
o Assigns each data point to its closest k-center. Those data points which are near to the
particular k-center, create a cluster.
Hence each cluster has datapoints with some commonalities, and it is away from other clusters. The
below diagram explains the working of the K-means Clustering Algorithm:
Now we will assign each data point of the scatter plot to its closest K-point or centroid. We will
compute it by applying some mathematics that we have studied to calculate the distance between two
points. So, we will draw a median between both the centroids. Consider the below image:
From the above image, it is clear that points left side of the line is near to the K1 or blue centroid, and
points to the right of the line are close to the yellow centroid. Let's color them as blue and yellow for
clear visualization. As we need to find the closest cluster, so we will repeat the process by choosing a
new centroid. To choose the new centroids, we will compute the center of gravity of these centroids,
and will find new centroids as below: Next, we will reassign each datapoint to the new centroid. For
this, we will repeat the same process of finding a median line.
o Example: Suppose, we have an image of a creature that looks similar to cat and dog, but we
want to know either it is a cat or dog. So for this identification, we can use the KNN
algorithm, as it works on a similarity measure. Our KNN model will find the similar features
of the new data set to the cats and dogs images and based on the most similar features it will
put it in either cat or dog category.
The K-NN working can be explained on the basis of the below algorithm:
o Step-1: Select the number K of the neighbors
o Step-2: Calculate the Euclidean distance of K number of neighbors
o Step-3: Take the K nearest neighbors as per the calculated Euclidean distance.
o Step-4: Among these k neighbors, count the number of the data points in each category.
o Step-5: Assign the new data points to that category for which the number of the neighbor is
maximum.
o Step-6: Our model is ready.
Suppose we have a new data point and we need to put it in the required category. Consider the below
image:
o Firstly, we will choose the number of neighbors, so we will choose the k=5.
o Next, we will calculate the Euclidean distance between the data points. The Euclidean
distance is the distance between two points, which we have already studied in geometry. It can
be calculated as:
o By calculating the Euclidean distance we got the nearest neighbors, as three nearest neighbors
in category A and two nearest neighbors in category B. Consider the below image:
o As we can see the 3 nearest neighbors are from category A, hence this new data point must
belong to category A.
EM algorithm in GMM
In statistics, EM (expectation maximization) algorithm handles latent variables, while GMM is the
Gaussian mixture model.
Gaussian mixture models (GMMs) are a type of machine learning algorithm. They are used to
classify data into different categories based on the probability distribution. Gaussian mixture
models can be used in many different areas, including finance, marketing and so much more.
Gaussian Mixture Models (GMMs) give us more flexibility than K-Means. With GMMs we
assume that the data points are Gaussian distributed; this is a less restrictive assumption than
saying they are circular by using the mean. That way, we have two parameters to describe the
shape of the clusters: the mean and the standard deviation!
Taking an example in two dimensions, this means that the clusters can take any kind of
elliptical shape (since we have standard deviation in both the x and y directions). Thus, each
Gaussian distribution is assigned to a single cluster. In order to find the parameters of the
Gaussian for each cluster (e.g the mean and standard deviation) we will use an optimization
algorithm called Expectation–Maximization (EM). Take a look at the graphic below as an
illustration of the Gaussians being fitted to the clusters. Then we can proceed on to the process
of Expectation–Maximization clustering using GMMs.
Gaussian mixture models (GMM) are a probabilistic concept used to model real-world data
sets. GMMs are a generalization of Gaussian distributions and can be used to represent any
data set that can be clustered into multiple Gaussian distributions. The Gaussian mixture
model is a probabilistic model that assumes all the data points are generated from a mix of
Gaussian distributions with unknown parameters.
A Gaussian mixture model can be used for clustering, which is the task of grouping a set of
data points into clusters. GMMs can be used to find clusters in data sets where the clusters
may not be clearly defined. Additionally, GMMs can be used to estimate the probability that a
new data point belongs to each cluster. Gaussian mixture models are also relatively robust to
outliers, meaning that they can still yield accurate results even if there are some data points
that do not fit neatly into any of the clusters. This makes GMMs a flexible and powerful tool
for clustering data.
It can be understood as a probabilistic model where Gaussian distributions are assumed for
each group and they have means and co variances which define their parameters. GMM
consists of two parts – mean vectors (μ) & covariance matrices (Σ). A Gaussian distribution is
defined as a continuous probability distribution that takes on a bell-shaped curve. Another
name for Gaussian distribution is the normal distribution. Here is a picture of Gaussian
mixture models:
GMM has many applications, such as density estimation, clustering, and image segmentation.
For density estimation, GMM can be used to estimate the probability density function of a set
of data points. For clustering, GMM can be used to group together data points that come from
the same Gaussian distribution. And for image segmentation, GMM can be used to partition
an image into different regions.
Gaussian mixture models can be used for a variety of use cases, including identifying
customer segments, detecting fraudulent activity, and clustering images. In each of these
examples, the Gaussian mixture model is able to identify clusters in the data that may not be
immediately obvious. As a result, Gaussian mixture models are a powerful tool for data
analysis and should be considered for any clustering task.
The EM method works by first initializing the parameters of the GMM, then iteratively
improving these estimates. At each iteration, the expectation step calculates the expectation of
the log-likelihood function with respect to the current parameters. This expectation is then
used to maximize the likelihood in the maximization step. The process is then repeated until
convergence. Here is a picture representing the two-step iterative aspect of the algorithm
The EM algorithm consists of two steps: the E- step and the M-step. Firstly, the model parameters and
the can be randomly initialized. In the E-step, the algorithm tries to guess the value of based on the
parameters, while in the M-step, the algorithm updates the value of the model parameters based on
the guess of the E-step. These two steps are repeated until convergence is reached. The algorithm in
GMM is repeat until convergence.
Optimization uses the Expectation Maximization algorithm, which alternates between two
steps:
1. E-step: Compute the posterior probability over z given our current model - i.e. how much
do we think each Gaussian generates each datapoint.
2. M-step: Assuming that the data really was generated this way, change the parameters of
each Gaussian to maximize the probability that it would generate the data it is currently
responsible for.
The EM Algorithm:
1. E-step: Compute the posterior probability over z given our current model
2. M-step: Maximize the probability that it would generate the data it is currently responsible for.
In a single layer perceptron model, its algorithms do not contain recorded data, so it begins with
inconstantly allocated input for weight parameters. Further, it sums up all inputs (weight). After adding
all inputs, if the total sum of all inputs is more than a pre-determined value, the model gets activated
and shows the output value as +1.
If the outcome is same as pre-determined or threshold value, then the performance of this model is
stated as satisfied, and weight demand does not change. However, this model consists of a few
discrepancies triggered when multiple weight inputs values are fed into the model. Hence, to find
desired output and minimize errors, some changes should be necessary for the weights input.
The multi-layer perceptron model is also known as the Backpropagation algorithm, which executes in
two stages as follows:
o Forward Stage: Activation functions start from the input layer in the forward stage and terminate
on the output layer.
o Backward Stage: In the backward stage, weight and bias values are modified as per the model's
requirement. In this stage, the error between actual output and demanded originated backward on the
output layer and ended on the input layer.
Instead of linear, activation function can be executed as sigmoid, TanH, ReLU, etc., for deployment.
A multi-layer perceptron model has greater processing power and can process linear and non-linear
patterns. Further, it can also implement logic gates such as AND, OR, XOR, NAND, NOT, XNOR,
NOR.
Perceptron Function
Perceptron function ''f(x)'' can be achieved as output by multiplying the input 'x' with the learned
weight coefficient 'w'.
Mathematically, we can express it as follows:
f(x)=1; if w.x+b>0 ; otherwise, f(x)=0
'w' represents real-valued weights vector
'b' represents the bias
'x' represents a vector of input x values.
Characteristics of Perceptron
The perceptron model has the following characteristics.
1. Perceptron is a machine learning algorithm for supervised learning of binary classifiers.
2. In Perceptron, the weight coefficient is automatically learned.
3. Initially, weights are multiplied with input features, and the decision is made whether the
neuron is fired or not.
4. The activation function applies a step rule to check whether the weight function is greater than
zero.
5. The linear decision boundary is drawn, enabling the distinction between the two linearly
separable classes +1 and -1.
6. If the added sum of all input values is more than the threshold value, it must have an output
signal; otherwise, no output will be shown.
The activation function decides how to compute the input values of a layer into output values.
The output values of a layer are then passed to the next layer as input values again. The next
layer then computes the values into output values for another layer again. There are 9
activation functions to tune in to this demonstration. Each activation function has its own
formula (and graph) to compute the input values. It will not be discussed in this article.
The layers of a neural network are compiled and an optimizer is assigned. The optimizer is
responsible to change the learning rate and weights of neurons in the neural network to reach
the minimum loss function. Optimizer is very important to achieve the possible highest
accuracy or minimum loss. There are 7 optimizers to choose from. Each has a different
concept behind it.
One of the hyperparameters in the optimizer is the learning rate. We will also tune the learning
rate. Learning rate controls the step size for a model to reach the minimum loss function. A
higher learning rate makes the model learn faster, but it may miss the minimum loss function
and only reach the surrounding of it. A lower learning rate gives a better chance to find a
minimum loss function. As a tradeoff lower learning rate needs higher epochs, or more time
and memory capacity resources.
function. Note that the values for any negative X input result in an output of 0, and only once positive
values are entered does the function begin to slope upward.
How does a Rectified Linear Unit work?
To understand how a ReLU works, it is important to understand the effects it has on variable
interaction effects. An interaction effect is when a variable affects a prediction depending on the value
of associated variables. For example, comparing IQ scores of two different schools may have
interaction effects of IQ and age. The IQ of a student in high school is better than the IQ of an
elementary school student, as age and IQ interact with each other regardless of the school. This is
known as an interaction effect and ReLUs can be applied to minimize interaction effects. For
example, if A=1 and B=2, and both have the respective associated weights of 2 and 3, the function
would be, f(2A+3B). If A increases, the output will increase as well. However, if B is a large negative
value, the output will be 0.
iii) Regularization :
Regularization is one of the most important concepts of machine learning. It is a technique to
prevent the model from overfitting by adding extra information to it. Sometimes the machine
learning model performs well with the training data but does not perform well with the test data. It
means the model is not able to predict the output when deals with unseen data by introducing noise in
the output, and hence the model is called overfitted. This problem can be deal with the help of a
regularization technique.
This technique can be used in such a way that it will allow to maintain all variables or features in
the model by reducing the magnitude of the variables. Hence, it maintains accuracy as well as a
generalization of the model. It mainly regularizes or reduces the coefficient of features toward zero.
In simple words, "In regularization technique, we reduce the magnitude of the features by keeping the
same number of features."
y= β0+β1x1+β2x2+β3x3+⋯+βnxn +b
In the above equation, Y represents the value to be predicted X1, X2, …Xn are the features for
Y.β0,β1,…..βn are the weights or magnitude attached to the features, respectively. Here represents the
bias of the model, and b represents the intercept.. Linear regression models try to optimize the β0 and
b to minimize the cost function. The equation for the cost function for the linear model is given
below:
Now, we will add a loss function and optimize parameter to make the model that can predict the
accurate value of Y. The loss function for the linear regression is called as RSS or Residual sum of
squares.
Techniques of Regularization
There are mainly two types of regularization techniques, which are given below:
o Ridge Regression
o Lasso Regression
Ridge Regression
o Ridge regression is one of the types of linear regression in which a small amount of bias is
introduced so that we can get better long-term predictions.
o Ridge regression is a regularization technique, which is used to reduce the complexity of the
model. It is also called as L2 regularization.
o In this technique, the cost function is altered by adding the penalty term to it. The amount of
bias added to the model is called Ridge Regression penalty. We can calculate it by
multiplying with the lambda to the squared weight of each individual feature.
o The equation for the cost function in ridge regression will be:
o In the above equation, the penalty term regularizes the coefficients of the model, and hence
ridge regression reduces the amplitudes of the coefficients that decreases the complexity of
the model.
o As we can see from the above equation, if the values of λ tend to zero, the equation becomes
the cost function of the linear regression model. Hence, for the minimum value of λ, the
model will resemble the linear regression model.
o A general linear or polynomial regression will fail if there is high collinearity between the
independent variables, so to solve such problems, Ridge regression can be used.
o It helps to solve the problems if we have more parameters than samples.
Lasso Regression:
o Lasso regression is another regularization technique to reduce the complexity of the model. It
stands for Least Absolute and Selection Operator.
o It is similar to the Ridge Regression except that the penalty term contains only the absolute
weights instead of a square of weights.
o Since it takes absolute values, hence, it can shrink the slope to 0, whereas Ridge Regression
can only shrink it near to 0.
o It is also called as L1 regularization. The equation for the cost function of Lasso regression
will be:
o Some of the features in this technique are completely neglected for model evaluation.
o Hence, the Lasso regression can help us to reduce the overfitting in the model as well as the
feature selection.
2. Recurrent backpropagation.
The recurrent backpropagation network is used for fixed-point learning. Recurrent
backpropagation activation feeds forward until it reaches a fixed value.
Advantages
It does not have any parameters to tune except for the number of inputs.
It is highly adaptable and efficient and does not require any prior knowledge about the
network.
It is a standard process that usually works well.
It is user-friendly, fast and easy to program.
Users do not need to learn any special functions.
DISADVANTAGES
It prefers a matrix-based approach over a mini-batch approach.
Data mining is sensitive to noise and irregularities.
Performance is highly dependent on input data.
Training is time- and resource-intensive.
Features of Backpropagation:
1. it is the gradient descent method as used in the case of simple perceptron network with the
differentiable unit.
2. it is different from other networks in respect to the process by which the weights are
calculated during the learning period of the network.
3. training is done in the three stages :
the feed-forward of input training pattern
the calculation and backpropagation of the error
updation of the weight
Working of Backpropagation:
Neural networks use supervised learning to generate output vectors from input vectors that the
network operates on. It Compares generated output to the desired output and generates an error
report if the result does not match the generated output vector. Then it adjusts the weights
according to the bug report to get your desired output.
Backpropagation Algorithm:
Step 1: Inputs X, arrive through the preconnected path.
Step 2: The input is modeled using true weights W. Weights are usually chosen randomly.
Step 3: Calculate the output of each neuron from the input layer to the hidden layer to the output
layer.
Step 4: Calculate the error in the outputs
Backpropagation Error= Actual Output – Desired Output
Step 5: From the output layer, go back to the hidden layer to adjust the weights to reduce the error.
Step 6: Repeat the process until the desired output is achieved.
Training Algorithm :
Step 1: Initialize weight to small random values.
Backpropagation Error :
Step 6: Each output unit y k (k=1 to n) receives a target pattern corresponding to an input pattern
then error is calculated as:
δk = ( tk – yk ) + yink
Step 7: Each hidden unit Z j (j=1 to a) sums its input from all units in the layer above
δinj = Σ δj wjk
The error information term is calculated as :
δj = δinj + zinj
In a neural network, we would update the weights and biases of the neurons on the basis of
the error at the output. This process is known as back-propagation . Activation functions make
the back-propagation possible since the gradients are supplied along with the error to update
the weights and biases.
Linear Function
Equation : Linear function has the equation similar to as of a straight line i.e. y = x
No matter how many layers we have, if all are linear in nature, the final activation function
of last layer is nothing but just a linear function of the input of first layer.
Range : -inf to +inf
Uses: Linear activation function is used at just one place i.e. output layer.
Issues: If we will differentiate linear function to bring non-linearity, result will no more
depend on input “x” and function will become constant, it won’t introduce any ground-
breaking behavior to our algorithm.
For example: Calculation of price of a house is a regression problem. House price may have any
big/small value, so we can apply linear activation at output layer. Even in this case neural net must
have any non-linear function at hidden layers.
Sigmoid Function
It is a function which is plotted as ‘S’ shaped graph.
Equation : A = 1/(1 + e-x)
Nature: Non-linear. Notice that X values lies between -2 to 2, Y values are very steep. This
means, small changes in x would also bring about large changes in the value of Y.
Value Range : 0 to 1
Uses: Usually used in output layer of a binary classification, where result is either 0 or 1,
as value for sigmoid function lies between 0 and 1 only so, result can be predicted easily to
be 1 if value is greater than 0.5 and 0 otherwise.
Tanh Function
The activation that works almost always better than sigmoid function is Tanh function also
knows as Tangent Hyperbolic function. It’s actually mathematically shifted version of the
sigmoid function. Both are similar and can be derived from each other.
Equation :-
Value Range :- -1 to +1
Nature :- non-linear
Uses: - Usually used in hidden layers of a neural network as its values lies between -1 to
1 hence the mean for the hidden layer comes out be 0 or very close to it, hence helps
in centering the data by bringing mean close to 0. This makes learning for the next layer much
easier.
RELU Function
It Stands for Rectified linear unit. It is the most widely used activation function. Chiefly
implemented in hidden layers of neural network.
Equation: - A(x) = max (0, x). It gives an output x if x is positive and 0 otherwise.
Value Range :- [0, inf)
Nature: - non-linear, which means we can easily backpropagate the errors and have
multiple layers of neurons being activated by the ReLU function.
Uses: - ReLu is less computationally expensive than tanh and sigmoid because it involves
simpler mathematical operations. At a time only a few neurons are activated making the
network sparse making it efficient and easy for computation.
In simple words, RELU learns much faster than sigmoid and Tanh function.
Softmax Function
The softmax function is also a type of sigmoid function but is handy when we are trying to
handle multi- class classification problems.
Nature :- non-linear
Uses: - Usually used when trying to handle multiple classes. The softmax function was
commonly found in the output layer of image classification problems. The softmax function
would squeeze the outputs for each class between 0 and 1 and would also divide by the sum of
the outputs.
Output: - The softmax function is ideally used in the output layer of the classifier where
we are actually trying to attain the probabilities to define the class of each input.
The basic rule of thumb is if you really don’t know what activation function to use, then
simply use RELU as it is a general activation function in hidden layers and is used in most
cases these days.
If your output is for binary classification then, sigmoid function is very natural choice for
output layer.
If your output is for multi-class classification then, Softmax is very useful to predict the
probabilities of each classes.
We essentially use this algorithm when we have to locate the least possible values which could
fulfill a given free function. In gadget getting to know, greater regularly that not we try to limit loss
features (like mean squared error). By minimizing the loss characteristic, we will improve our model
and gradient descent is one of the most popular algorithms used for this cause.
The graph above shows how exactly a gradient descent set of rules works.
We first take a factor in the value function and begin shifting in steps in the direction of the
minimum factor. The size of the step, or how quickly we ought to converge to the minimum factor is
defined by learning rate.
We can cowl more location with better learning fee but at the risk of overshooting the minima. On
the opposite hand, small steps/ smaller gaining knowledge of charges will eat a number of times to
attain the lowest point.
Now, the direction where in algorithm has to transport is also important. We calculate this by way
of using derivatives. You need to be familiar with derivatives from calculus. A spinoff is largely
calculated because the slope of the graph at any specific factor. We get that with the aid of finding the
tangent line to the graph at that point. The extra sleep the tangent, would suggest that more steps
would be needed to reach minimum point; much less steep might suggest lesser steps are required to
reach the minimum factor.
Stochastic gradient descent is a type of gradient descent that runs one training example per
iteration. It processes a training epoch for each example within a dataset and updates each
training example’s parameters one at a time.
As it requires only one training example at a time, hence it is easier to store in allocated
memory. However, it shows some computational efficiency losses in comparison to batch
gradient systems as it shows frequent updates that require more detail and speed.
Further, due to frequent updates, it is also treated as a noisy gradient. However, sometimes it
can be helpful in finding the global minimum and also escaping the local minimum.