ML
ML
Machine learning enables a machine to automatically learn from data, improve performance from
experiences, and predict things without being explicitly programmed.
With the help of sample historical data, which is known as training data, machine
learning algorithms build a mathematical model that helps in making predictions or
decisions without being explicitly programmed. Machine learning brings computer
science and statistics together for creating predictive models. Machine learning
constructs or uses the algorithms that learn from historical data. The more we will
provide the information, the higher will be the performance.
A machine has the ability to learn if it can improve its performance by gaining
more data.
We can train machine learning algorithms by providing them the huge amount of data
and let them explore the data, construct the models, and predict the required output
automatically. The performance of the machine learning algorithm depends on the
amount of data, and it can be determined by the cost function. With the help of
machine learning, we can save both time and money.
The importance of machine learning can be easily understood by its uses cases,
Currently, machine learning is used in self-driving cars, cyber fraud detection, face
recognition, and friend suggestion by Facebook, etc. Various top companies such
as Netflix and Amazon have build machine learning models that are using a vast
amount of data to analyze the user interest and recommend product accordingly.
Following are some key points which show the importance of Machine Learning:
1. Supervised learning
2. Unsupervised learning
3. Reinforcement learning
1) Supervised Learning
Supervised learning is a type of machine learning method in which we provide sample
labeled data to the machine learning system in order to train it, and on that basis, it
predicts the output.
The system creates a model using labeled data to understand the datasets and learn
about each data, once the training and processing are done then we test the model
by providing a sample data to check whether it is predicting the exact output or not.
The goal of supervised learning is to map input data with the output data. The
supervised learning is based on supervision, and it is the same as when a student learns
things in the supervision of the teacher. The example of supervised learning is spam
filtering.
2) Unsupervised Learning
Unsupervised learning is a learning method in which a machine learns without any
supervision.
The training is provided to the machine with the set of data that has not been labeled,
classified, or categorized, and the algorithm needs to act on that data without any
supervision. The goal of unsupervised learning is to restructure the input data into new
features or a group of objects with similar patterns.
o Clustering
o Density Estimation
o Dimensionality Reduction
3) Reinforcement Learning
Reinforcement learning is a feedback-based learning method, in which a learning
agent gets a reward for each right action and gets a penalty for each wrong action.
The agent learns automatically with these feedbacks and improves its performance. In
reinforcement learning, the agent interacts with the environment and explores it. The
goal of an agent is to get the most reward points, and hence, it improves its
performance.
The robotic dog, which automatically learns the movement of his arms, is an example
of Reinforcement learning.
APPLICATIONS OF MACHINE LEARNING
Machine learning is a buzzword for today's technology, and it is growing very rapidly day by
day. We are using machine learning in our daily life even without knowing it such as Google
Maps, Google assistant, Alexa, etc. Below are some most trending real-world applications of
Machine Learning:
Image Recognition: Image recognition is one of the most common applications of machine
learning. It is used to identify objects, persons, places, digital images, etc. The popular use case
of image recognition and face detection is, Automatic friend tagging suggestion:
Facebook provides us a feature of auto friend tagging suggestion. Whenever we upload a photo
with our Facebook friends, then we automatically get a tagging suggestion with name, and the
technology behind this is machine learning's face detection and recognition algorithm.
It is based on the Facebook project named "Deep Face," which is responsible for face
recognition and person identification in the picture.
Speech Recognition: While using Google, we get an option of "Search by voice," it comes
under speech recognition, and it's a popular application of machine learning.
Speech recognition is a process of converting voice instructions into text, and it is also known
as "Speech to text", or "Computer speech recognition." At present, machine learning algorithms
are widely used by various applications of speech recognition. Google assistant, Siri, Cortana,
and Alexa are using speech recognition technology to follow the voice instructions.
Traffic prediction: If we want to visit a new place, we take help of Google Maps, which shows
us the correct path with the shortest route and predicts the traffic conditions.
It predicts the traffic conditions such as whether traffic is cleared, slow-moving, or heavily
congested with the help of two ways:
o Real Time location of the vehicle form Google Map app and sensors
o Average time has taken on past days at the same time.
Everyone who is using Google Map is helping this app to make it better. It takes information
from the user and sends back to its database to improve the performance.
Product recommendations: Machine learning is widely used by various e-commerce and
entertainment companies such as Amazon, Netflix, etc., for product recommendation to the
user. Whenever we search for some product on Amazon, then we started getting an
advertisement for the same product while internet surfing on the same browser and this is
because of machine learning.
Google understands the user interest using various machine learning algorithms and suggests
the product as per customer interest.
As similar, when we use Netflix, we find some recommendations for entertainment series,
movies, etc., and this is also done with the help of machine learning.
Self-driving cars: One of the most exciting applications of machine learning is self-driving
cars. Machine learning plays a significant role in self-driving cars. Tesla, the most popular car
manufacturing company is working on self-driving car. It is using unsupervised learning
method to train the car models to detect people and objects while driving.
Email Spam and Malware Filtering: Whenever we receive a new email, it is filtered
automatically as important, normal, and spam. We always receive an important mail in our
inbox with the important symbol and spam emails in our spam box, and the technology behind
this is Machine learning. Below are some spam filters used by Gmail:
o Content Filter
o Header filter
o General blacklists filter
o Rules-based filters
o Permission filters
ISSUES IN MACHINE LEARNING.
a. Poor Quality of Data
Data plays a significant role in the machine learning process. One of the significant
issues that machine learning professionals face is the absence of good quality data. Unclean
and noisy data can make the whole process extremely exhausting. We don’t want our
algorithm to make inaccurate or faulty predictions. Hence the quality of data is essential to
enhance the output. Therefore, we need to ensure that the process of data preprocessing which
includes removing outliers, filtering missing values, and removing unwanted features, is done
with the utmost level of perfection.
b. Underfitting of Training Data
This process occurs when data is unable to establish an accurate relationship between
input and output variables. It simply means trying to fit in undersized jeans. It signifies the
data is too simple to establish a precise relationship. To overcome this issue:
Maximize the training time
Enhance the complexity of the model
Add more features to the data
Reduce regular parameters
Increasing the training time of model
c. Overfitting of Training Data
Overfitting refers to a machine learning model trained with a massive amount of data
that negatively affect its performance. It is like trying to fit in Oversized jeans. Unfortunately,
this is one of the significant issues faced by machine learning professionals. This means that
the algorithm is trained with noisy and biased data, which will affect its overall performance.
Let’s understand this with the help of an example. Let’s consider a model trained to
differentiate between a cat, a rabbit, a dog, and a tiger. The training data contains 1000 cats,
1000 dogs, 1000 tigers, and 4000 Rabbits. Then there is a considerable probability that it will
identify the cat as a rabbit. In this example, we had a vast amount of data, but it was biased;
hence the prediction was negatively affected.
It can be solved with:
Analyzing the data with the utmost level of perfection
Use data augmentation technique
Remove outliers in the training set
Select a model with lesser features
d. Machine Learning is a Complex Process
The machine learning industry is young and is continuously changing. Rapid hit and
trial experiments are being carried on. The process is transforming, and hence there are high
chances of error which makes the learning complex. It includes analyzing the data, removing
data bias, training data, applying complex mathematical calculations, and a lot more. Hence
it is a really complicated process which is another big challenge for Machine learning
professionals.
e. Lack of Training Data
The most important task you need to do in the machine learning process is to train the
data to achieve an accurate output. Less amount training data will produce inaccurate or too
biased predictions. A machine-learning algorithm needs a lot of data to distinguish. For
complex problems, it may even require millions of data to be trained. Therefore we need to
ensure that Machine learning algorithms are trained with sufficient amounts of data.
f. Slow Implementation
This is one of the common issues faced by machine learning professionals. The
machine learning models are highly efficient in providing accurate results, but it takes a
tremendous amount of time. Slow programs, data overload, and excessive requirements
usually take a lot of time to provide accurate results. Further, it requires constant monitoring
and maintenance to deliver the best output.
g. Imperfections in the Algorithm When Data Grows
So you have found quality data, trained it amazingly, and the predictions are really
concise and accurate. The best model of the present may become inaccurate in the coming
Future and require further rearrangement. So we need regular monitoring and maintenance to
keep the algorithm working. This is one of the most exhausting issues faced by machine
learning.
MACHINE LEARNING WORKFLOW | PROCESS STEPS
We have discussed-
Machine learning is building machines that can adapt and learn from experience.
Machine learning systems are not explicitly programmed.
Machine learning workflow refers to the series of stages or steps involved in the
process of building a successful machine learning system.
1. Data Collection-
In this stage,
Data is collected from different sources.
The type of data collected depends upon the type of desired project.
Data may be collected from various sources such as files, databases etc.
The quality and quantity of gathered data directly affects the accuracy of the desired
system.
2. Data Preparation-
In this stage,
Data preparation is done to clean the raw data.
Data collected from the real world is transformed to a clean dataset.
Raw data may contain missing values, inconsistent values, duplicate instances etc.
So, raw data cannot be directly used for building a model.
In this stage,
The best performing learning algorithm is researched.
It depends upon the type of problem that needs to solved and the type of data we have.
If the problem is to classify and the data is labeled, classification algorithms are used.
If the problem is to perform a regression task and the data is labeled, regression
algorithms are used.
If the problem is to create clusters and the data is unlabeled, clustering algorithms are
used.
4. Training Model-
In this stage,
The model is trained to improve its ability.
The dataset is divided into training dataset and testing dataset.
The training and testing split is order of 80/20 or 70/30.
It also depends upon the size of the dataset.
Training dataset is used for training purpose.
Testing dataset is used for the testing purpose.
Training dataset is fed to the learning algorithm.
The learning algorithm finds a mapping between the input and the output and generates
the model.
5. Evaluating Model-
In this stage,
The model is evaluated to test if the model is any good.
The model is evaluated using the kept-aside testing dataset.
It allows to test the model against data that has never been used before for training.
Metrics such as accuracy, precision, recall etc are used to test the performance.
If the model does not perform well, the model is re-built using different hyper parameters.
The accuracy may be further improved by tuning the hyper parameters.
6. Predictions-
In this stage,
The built system is finally used to do something useful in the real world.
Here, the true value of machine learning is realized.
WEIGHT SPACE
TESTING MACHINE LEARNING
ALGORITHMS
TURNING DATA INTO
PROBABILITIES
Preliminaries 2 7
P(X)
FIGURE 2.10 A histogram of feature values (r) against their probability for two classes
how often (in the training set) there is a neasurement of X given that the example 1s a
member of class C. Again. we can just get this information from the
histogram by couting
the ummber of exauples of class C in histogram biu X, aud dividiug by the mumber of
Nples of that cass there are (in any bin). Flopefully, this has just been revision for
you from a statistics course at some stage; ii not, and you don't follow it, get hold of any
3troductory probability book.
So we have now worked out two things trom our training data: the
joint probability
PIC. X,and the conditional probability P C). Since we actually want to compute
PCA, we need to kuow how to liuk these iiings together. As some of you may already
know. the answer is Bayes rule, which is what we are now going to derive. There is a link
between the joint probability and the conditional probability. It is:
P(CN)PX,C)P(C), (2.10)
or equivalently:
Po&L&ioh
PC ormal1L
atl pao
Sum to 1
PRedICtoa PRio PR0L
Preliminaries 29
PClx)
FIGURE 2.12 The posterior probabilities of the two classes C and C2 for feature .
The reason why Bayes rule is so inportant is that it lets us obtain the posterior
probability-which is what we actually want-by calculating things that are much eas-
ier to compute. VWe can estimate the prior probabilities by looking at how oftern each class
appears in our training set, and we can get the class-conditional probabilities from the his-
togram of the values of the feature for tlhe training set. We can use the posterior probability
(Figure 2.12) to assign each new observation to one of the classes by picking tlie class
where:
PC)|POXa,C). (2.16)
This is clearly a great simplification over evaluating
the full probability, so it
as a surprise
that the naive Bayes classifier has been shown to might come
have comparable results to
other classification methods in certain
domais. Where the simplilication is true, so that
the leatues Are coiditionally
indepedent of each otlier, the naive Bayes classilier produces
exactly the MAP classification
THE BIAS-VARIANCE TRADEOFF
Bias Vs Variance
uS
u s aa b
boou
ut h ou
u wel
c ell
varnance Letly
S and
during 7raining 2 festina
Our per-forms
C algorithm
Side bf Home 3
Sze o f Home
Si e o Hame
tOratO22
polynomial
)
o-f m g h v a r i a n c e
Cdegree,
Trainin error:
4he
am
get)
CPrediceð
oP
) a .error
[Link]
sampes
22
Mcv
Cross validation
error
8mcv 1E
CTesing error )
Underfi t
bias
High
esina Training Testina
e r r o r
ill be hiah.
error
v a r i a n C e
bias
Trainng error 5low
Tvaining
error
* Testirg error Verthigh.
d1 d d-3
degree o polynomia
d i f f ererd pa
rw as
seon
ns
variance"
Concept learning can be viewed as the task of searching through a large space of
hypotheses implicitly defined by the hypothesis representation.
The goal of this search is to find the hypothesis that best fits the training examples.
Example:
Consider the instances X and hypotheses H in the EnjoySport learning task. The attribute Skyhas three
possible values, and AirTemp, Humidity, Wind, Water, Forecast each have two possible values, the
instance space X contains exactly
[Link].2.2 = 96 distinct instances
[Link].4.4 = 5120 syntactically distinct hypotheses within H.
Every hypothesis containing one or more "Φ" symbols represents the empty set of instances; that is, it
classifies every instance as negative.
1 + ([Link].3.3) = 973. Semantically distinct hypotheses
Consider the sets of instances that are classified positive by hl and by h2.
h2 imposes fewer constraints on the instance, it classifies more instances as positive. So,any
instance classified positive by hl will also be classified positive by h2. Therefore, h2 is more
general than hl.
Given hypotheses hj and hk, hj is more-general-than or- equal do hk if and only if any instancethat
satisfies hk also satisfies hi
Definition: Let hj and hk be Boolean-valued functions defined over X. Then hj is more general-than-
or-equal-to hk (written hj ≥ hk) if and only if
FIND-S Algorithm
Observing the first training example, it is clear that hypothesis h is too specific. None of the
"Ø" constraints in h are satisfied by this example, so each is replaced by the nextmore general
constraint that fits the example
h1 = <Sunny Warm Normal Strong Warm Same>
The second training example forces the algorithm to further generalize h, this time
substituting a "?" in place of any attribute value in h that is not satisfied by the newexample
h2 = <Sunny Warm ? Strong Warm Same>
Upon encountering the third training the algorithm makes no change to h. The FIND-S
algorithm simply ignores every negative example.
h3 = < Sunny Warm ? Strong Warm Same>
Unanswered by FIND-S
The key idea in the CANDIDATE-ELIMINATION algorithm is to output a description of theset of all
hypotheses consistent with the training examples
Representation
Definition: version space- The version space, denoted V S with respect to hypothesis space
H, D
H and training examples D, is the subset of hypotheses from H consistent with the training
examples in D
VS h H | Consistent (h, D)}
H, D
List-Then-Eliminate algorithm
Example1 :
F1 – > A, B
F2 – > X, Y
Here F1 and F2 are two features (attributes) with two possible values for each feature or
attribute.
Instance Space: (A, X), (A, Y), (B, X), (B, Y) – 4 Examples
Hypothesis Space: (A, X), (A, Y), (A, ø), (A, ?), (B, X), (B, Y), (B, ø), (B, ?), (ø, X), (ø, Y), (ø, ø), (ø, ?),
(?, X), (?, Y), (?, ø), (?, ?) – 16 Hypothesis
Semantically Distinct Hypothesis : (A, X), (A, Y), (A, ?), (B, X), (B, Y), (B, ?), (?, X), (?, Y (?, ?), (ø, ø)
– 10
Example2 :
Version Space: (A, X), (A, Y), (A, ?), (B, X), (B, Y), (B, ?), (?, X), (?, Y) (?, ?), (ø, ø), •Training Instances
F1 F2 Target
A X Yes
A Y Yes
• If d is a negative example
• Remove from S any hypothesis inconsistent with d
• For each hypothesis g in G that is not consistent with d
• Remove g from G
• Add to G all minimal specializations h of g such that
• h is consistent with d, and some member of S is more specific than h
• Remove from G any hypothesis that is less general than another hypothesis in G
An Illustrative Example
Initializing the S boundary set to contain the most specific (least general) hypothesis
S0
When the first training example is presented, the CANDIDATE-ELIMINTION algorithm checks
the S boundary and finds that it is overly specific and it fails to cover the positive example.
The boundary is therefore revised by moving it to the least more general hypothesis that covers this
new example
No update of the G boundary is needed in response to this training example because G o correctly
covers this example
When the second training example is observed, it has a similar effect of generalizing Sfurther
to S2, leaving G again unchanged i.e., G2 = G1 = G0
Consider the third training example. This negative example reveals that the G boundaryof the
version space is overly general, that is, the hypothesis in G incorrectly predicts that this new
example is a positive example.
The hypothesis in the G boundary must therefore be specialized until it correctly classifies this
new negative example
Given that there are six attributes that could be specified to specialize G2, why are there only three new
hypotheses in G3?
For example, the hypothesis h = (?, ?, Normal, ?, ?, ?) is a minimal specialization of G 2 that
correctly labels the new example as a negative example, but it is not included in [Link] reason
this hypothesis is excluded is that it is inconsistent with the previously encountered positive
examples
This positive example further generalizes the S boundary of the version space. It alsoresults
in removing one member of the G boundary, because this member fails to cover the new
positive example
After processing these four examples, the boundary sets S4 and G4 delimit the version spaceof all
hypotheses consistent with the set of incrementally observed training examples.
BASIC CONCEPTS IN MACHINE LEARNING
We will be focussing on probabilistic models of the form p(y|x) or p(x), depending on whether we are
interested in supervised or unsupervised learning respectively. There are many ways to define such
models, but the most important distinction is this: does the model have a fixed number of parameters, or
does the number of parameters g
row with the amount of training data? The former is called a parametric model, and the latter is called a
nonparametric model. Parametric models have the advantage of often being faster to use, but the
disadvantage of making stronger assumptions about the nature of the data distributions. Nonparametric
models are more flexible, but often computationally intractable for large datasets.
o K-Nearest Neighbour is one of the simplest Machine Learning algorithms based on Supervised
Learning technique.
o K-NN algorithm assumes the similarity between the new case/data and available cases and put the
new case into the category that is most similar to the available categories.
o K-NN algorithm stores all the available data and classifies a new data point based on the
similarity. This means when new data appears then it can be easily classified into a well suite
category by using K- NN algorithm.
o K-NN algorithm can be used for Regression as well as for Classification but mostly it is used for
the Classification problems.
o K-NN is a non-parametric algorithm, which means it does not make any assumption on
underlying data.
o It is also called a lazy learner algorithm because it does not learn from the training set
immediately instead it stores the dataset and at the time of classification, it performs an action on
the dataset.
o KNN algorithm at the training phase just stores the dataset and when it gets new data, then it
classifies that data into a category that is much similar to the new data.
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 KNN classifier is simple and can work quite well, provided it is given a good distance metric and has
enough labeled training data. In fact, it can be shown that the KNN classifier can come within a factor of
2 of the best possible performance if N → ∞ (Cover and Hart 1967). However, the main problem with
KNN classifiers is that they do not work well with high dimensional inputs. The poor performance in high
dimensional settings is due to the curse of dimensionality.
Curse of Dimensionality refers to a set of problems that arise when working with high-dimensional data.
The dimension of a dataset corresponds to the number of attributes/features that exist in a dataset. A
dataset with a large number of attributes, generally of the order of a hundred or more, is referred to as
high dimensional data. Some of the difficulties that come with high dimensional data manifest during
analyzing or visualizing the data to identify patterns, and some manifest while training machine learning
models. The difficulties related to training machine learning models due to high dimensional data is
referred to as ‘Curse of Dimensionality’
The main way to combat the curse of dimensionality is to make some assumptions about the nature of the
data distribution (either p(y|x) for a supervised problem or p(x) for an unsupervised problem). These
assumptions, known as inductive bias, are often embodied in the form of a parametric model, which is a
statistical model with a fixed number of parameters.
Linear regression
Linear Regression is an algorithm that belongs to supervised Machine Learning. It tries to apply relations
that will predict the outcome of an event based on the independent variable data points. The relation is
usually a straight line that best fits the different data points as close as possible. The output is of a
continuous form, i.e., numerical value. For example, the output could be revenue or sales in currency, the
number of products sold, etc. In the above example, the independent variable can be single or multiple.
y= β0+ β 1x+ ε
Here,
Y= Dependent Variable
X= Independent Variable
β 0= intercept of the line
β1 = Linear regression coefficient (slope of the line)
ε = random error
The last parameter, random error ε, is required as the best fit line also doesn't include the data points
perfectly.
Since the Linear Regression algorithm represents a linear relationship between a dependent (y) and one or
more independent (y) variables, it is known as Linear Regression. This means it finds how the value of
the dependent variable changes according to the change in the value of the independent variable. The
relation between independent and dependent variables is a straight line with a slope.
A simple straight-line equation involving slope (dy/dx) and intercept (an integer/continuous value) is
utilized in simple Linear Regression. Here a simple form is:
y=mx+c where y denotes the output x is the independent variable, and c is the intercept when x=0. With
this equation, the algorithm trains the model of machine learning and gives the most accurate output
When a number of independent variables more than one, the governing linear equation applicable to
regression takes a different form like:
y= c+m1x1+m2x2… mnxn where represents the coefficient responsible for impact of different
independent variables x1, x2 etc. This machine learning algorithm, when applied, finds the values of
coefficients m1, m2, etc., and gives the best fitting line.
3. Non-Linear Regression
When the best fitting line is not a straight line but a curve, it is referred to as Non-Linear Regression.
Logistic regression
o Logistic regression is one of the most popular Machine Learning algorithms, which comes under
the Supervised Learning technique. It is used for predicting the categorical dependent variable
using a given set of independent variables.
o Logistic regression predicts the output of a categorical dependent variable. Therefore the outcome
must be a categorical or discrete value. It can be either Yes or No, 0 or 1, true or False, etc. but
instead of giving the exact value as 0 and 1, it gives the probabilistic values which lie between 0
and 1.
o Logistic Regression is much similar to the Linear Regression except that how they are used.
Linear Regression is used for solving Regression problems, whereas Logistic regression is used
for solving the classification problems.
o In Logistic regression, instead of fitting a regression line, we fit an "S" shaped logistic function,
which predicts two maximum values (0 or 1).
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:
Overfitting
Overfitting occurs when our machine learning model tries to cover all the data points or more than the
required data points present in the given dataset. Because of this, the model starts caching noise and
inaccurate values present in the dataset, and all these factors reduce the efficiency and accuracy of the
model. The overfitted model has low bias and high variance.
The chances of occurrence of overfitting increase as much we provide training to our model. It means the
more we train our model, the more chances of occurring the overfitted model.
Example: The concept of the overfitting can be understood by the below graph of the linear regression
output:
As we can see from the above graph, the model tries to cover all the data points present in the scatter plot.
It may look efficient, but in reality, it is not so. Because the goal of the regression model to find the best
fit line, but here we have not got any best fit, so, it will generate the prediction errors.
Both overfitting and underfitting cause the degraded performance of the machine learning model. But the
main cause is overfitting, so there are some ways by which we can reduce the occurrence of overfitting in
our model.
Cross-Validation
Training with more data
Removing features
Early stopping the training
Regularization
Ensembling
Model selection
Model selection is the process of selecting one final machine learning model from among a collection of
candidate machine learning models for a training dataset.
Model selection is a process that can be applied both across different types of models (e.g. logistic
regression, SVM, KNN, etc.) and across models of the same type configured with different model
hyperparameters (e.g. different kernels in an SVM).
When we have a variety of models of different complexity (e.g., linear or logistic regression models with
different degree polynomials, or KNN classifiers with different values of K), how should we pick the right
one?
For example, we may have a dataset for which we are interested in developing a classification or
regression predictive model. We do not know beforehand as to which model will perform best on this
problem, as it is unknowable. Therefore, we fit and evaluate a suite of different models on the problem.
Model selection is the process of choosing one of the models as the final model that addresses the
problem.
Model selection is different from model assessment.
For example, we evaluate or assess candidate models in order to choose the best one, and this is model
selection. Whereas once a model is chosen, it can be evaluated in order to communicate how well it is
expected to perform in general; this is model assessment.
The No Free Lunch Theorem is often used in optimization and machine learning, with little
comprehension of what it means or implies.
The theory asserts that when the performance of all optimization methods is averaged across all
conceivable problems, they all perform equally well. It indicates that no one optimum optimization
algorithm exists. Because of the strong link between optimization, search, and machine learning, there is
no one optimum machine learning method for predictive modelling tasks like classification and
regression.
They all agree on one point: there is no “best” algorithm for specific kinds of algorithms, since they all
perform similarly on average. Mathematically, the computing cost of finding a solution is the same for
any solution technique when averaged across all problems in the class. As a result, no solution provides a
shortcut.
According to the “No Free Lunch” theory, there is no one model that works best for every situation.
Because the assumptions of a great model for one issue may not hold true for another, it is typical in
machine learning to attempt many models to discover the one that performs best for a specific problem.
This is especially true in supervised learning, where validation or cross-validation is frequently used to
compare the prediction accuracy of many models of various complexity in order to select the optimal
model. A good model may also be trained using several methods — for example, linear regression can be
learned using normal equations or gradient descent.
UNIT 2- SUPERVISED LEARNING
Linear Models for Regression – Linear Basis Function Models –
The Bias-Variance Decomposition – Bayesian Linear
Regression – Common Regression Algorithms – Simple Linear
Regression – Multiple Linear Regression – Linear Models for
Classification – Discriminant Functions – Probabilistic
Generative Models – Probabilistic Discriminative Models –
Laplace Approximation – Bayesian Logistic Regression –
Common Classification Algorithms – k-Nearest Neighbors –
Decision Trees – Random Forest model – Support Vector
Machines
3
Linear
Models for
Regression
The focus so far in this book has been on unsupervised learning, including topics
such as density estimation and data clustering. We turn now to a discussion of super-
vised learning, starting with regression. The goal of regression is to predict the value
of one or more continuous target variables t given the value of a D-dimensional vec-
tor x of input variables. We have already encountered an example of a regression
problem when we considered polynomial curve fitting in Chapter 1. The polynomial
is a specific example of a broad class of functions called linear regression models,
which share the property of being linear functions of the adjustable parameters, and
which will form the focus of this chapter. The simplest form of linear regression
models are also linear functions of the input variables. However, we can obtain a
much more useful class of functions by taking linear combinations of a fixed set of
nonlinear functions of the input variables, known as basis functions. Such models
are linear functions of the parameters, which gives them simple analytical properties,
and yet can be nonlinear with respect to the input variables.
137
138 3. LINEAR MODELS FOR REGRESSION
y(x, w) = w0 + w1 x1 + . . . + wD xD (3.1)
where x = (x1 , . . . , xD )T . This is often simply known as linear regression. The key
property of this model is that it is a linear function of the parameters w0 , . . . , wD . It is
also, however, a linear function of the input variables xi , and this imposes significant
limitations on the model. We therefore extend the class of models by considering
linear combinations of fixed nonlinear functions of the input variables, of the form
M −1
y(x, w) = w0 + wj φj (x) (3.2)
j =1
where φj (x) are known as basis functions. By denoting the maximum value of the
index j by M − 1, the total number of parameters in this model will be M .
The parameter w0 allows for any fixed offset in the data and is sometimes called
a bias parameter (not to be confused with ‘bias’ in a statistical sense). It is often
convenient to define an additional dummy ‘basis function’ φ0 (x) = 1 so that
M −1
y(x, w) = wj φj (x) = wT φ(x) (3.3)
j =0
or feature extraction, to the original data variables. If the original variables com-
prise the vector x, then the features can be expressed in terms of the basis functions
{φj (x)}.
By using nonlinear basis functions, we allow the function y(x, w) to be a non-
linear function of the input vector x. Functions of the form (3.2) are called linear
models, however, because this function is linear in w. It is this linearity in the pa-
rameters that will greatly simplify the analysis of this class of models. However, it
also leads to some significant limitations, as we discuss in Section 3.6.
The example of polynomial regression considered in Chapter 1 is a particular
example of this model in which there is a single input variable x, and the basis func-
tions take the form of powers of x so that φj (x) = xj . One limitation of polynomial
basis functions is that they are global functions of the input variable, so that changes
in one region of input space affect all other regions. This can be resolved by dividing
the input space up into regions and fit a different polynomial in each region, leading
to spline functions (Hastie et al., 2001).
There are many other possible choices for the basis functions, for example
(x − µj )2
φj (x) = exp − (3.4)
2s2
where the µj govern the locations of the basis functions in input space, and the pa-
rameter s governs their spatial scale. These are usually referred to as ‘Gaussian’
basis functions, although it should be noted that they are not required to have a prob-
abilistic interpretation, and in particular the normalization coefficient is unimportant
because these basis functions will be multiplied by adaptive parameters wj .
Another possibility is the sigmoidal basis function of the form
x − µ
j
φj (x) = σ (3.5)
s
where σ(a) is the logistic sigmoid function defined by
1
σ(a) = . (3.6)
1 + exp(−a)
Equivalently, we can use the ‘tanh’ function because this is related to the logistic
sigmoid by tanh(a) = 2σ(a) − 1, and so a general linear combination of logistic
sigmoid functions is equivalent to a general linear combination of ‘tanh’ functions.
These various choices of basis function are illustrated in Figure 3.1.
Yet another possible choice of basis function is the Fourier basis, which leads to
an expansion in sinusoidal functions. Each basis function represents a specific fre-
quency and has infinite spatial extent. By contrast, basis functions that are localized
to finite regions of input space necessarily comprise a spectrum of different spatial
frequencies. In many signal processing applications, it is of interest to consider ba-
sis functions that are localized in both space and frequency, leading to a class of
functions known as wavelets. These are also defined to be mutually orthogonal, to
simplify their application. Wavelets are most applicable when the input values live
140 3. LINEAR MODELS FOR REGRESSION
1 1 1
0 0.5 0.5
−1 0 0
−1 0 1 −1 0 1 −1 0 1
Figure 3.1 Examples of basis functions, showing polynomials on the left, Gaussians of the form (3.4) in the
centre, and sigmoidal of the form (3.5) on the right.
on a regular lattice, such as the successive time points in a temporal sequence, or the
pixels in an image. Useful texts on wavelets include Ogden (1997), Mallat (1999),
and Vidakovic (1999).
Most of the discussion in this chapter, however, is independent of the particular
choice of basis function set, and so for most of our discussion we shall not specify
the particular form of the basis functions, except for the purposes of numerical il-
lustration. Indeed, much of our discussion will be equally applicable to the situation
in which the vector φ(x) of basis functions is simply the identity φ(x) = x. Fur-
thermore, in order to keep the notation simple, we shall focus on the case of a single
target variable t. However, in Section 3.1.5, we consider briefly the modifications
needed to deal with multiple target variables.
t = y(x, w) + (3.7)
where is a zero mean Gaussian random variable with precision (inverse variance)
β. Thus we can write
Recall that, if we assume a squared loss function, then the optimal prediction, for a
Section 1.5.5 new value of x, will be given by the conditional mean of the target variable. In the
case of a Gaussian conditional distribution of the form (3.8), the conditional mean
3.1. Linear Basis Function Models 141
will be simply
E[t|x] = tp(t|x) dt = y(x, w). (3.9)
Note that the Gaussian noise assumption implies that the conditional distribution of
t given x is unimodal, which may be inappropriate for some applications. An ex-
tension to mixtures of conditional Gaussian distributions, which permit multimodal
conditional distributions, will be discussed in Section 14.5.1.
Now consider a data set of inputs X = {x1 , . . . , xN } with corresponding target
values t1 , . . . , tN . We group the target variables {tn } into a column vector that we
denote by t where the typeface is chosen to distinguish it from a single observation
of a multivariate target, which would be denoted t. Making the assumption that
these data points are drawn independently from the distribution (3.8), we obtain the
following expression for the likelihood function, which is a function of the adjustable
parameters w and β, in the form
N
p(t|X, w, β) = N (tn |wT φ(xn ), β −1 ) (3.10)
n=1
where we have used (3.3). Note that in supervised learning problems such as regres-
sion (and classification), we are not seeking to model the distribution of the input
variables. Thus x will always appear in the set of conditioning variables, and so
from now on we will drop the explicit x from expressions such as p(t|x, w, β) in or-
der to keep the notation uncluttered. Taking the logarithm of the likelihood function,
and making use of the standard form (1.46) for the univariate Gaussian, we have
N
ln p(t|w, β) = ln N (tn |wT φ(xn ), β −1 )
n=1
N N
= ln β − ln(2π) − βED (w) (3.11)
2 2
where the sum-of-squares error function is defined by
1
N
ED (w) = {tn − wT φ(xn )}2 . (3.12)
2
n=1
Having written down the likelihood function, we can use maximum likelihood to
determine w and β. Consider first the maximization with respect to w. As observed
already in Section 1.2.5, we see that maximization of the likelihood function under a
conditional Gaussian noise distribution for a linear model is equivalent to minimizing
a sum-of-squares error function given by ED (w). The gradient of the log likelihood
function (3.11) takes the form
N
∇ ln p(t|w, β) = tn − wT φ(xn ) φ(xn )T . (3.13)
n=1
142 3. LINEAR MODELS FOR REGRESSION
1
N M −1
ED (w) = {tn − w0 − wj φj (xn )}2 . (3.18)
2
n=1 j =1
Setting the derivative with respect to w0 equal to zero, and solving for w0 , we obtain
M −1
w0 = t − wj φj (3.19)
j =1
Thus the bias w0 compensates for the difference between the averages (over the
training set) of the target values and the weighted sum of the averages of the basis
function values.
We can also maximize the log likelihood function (3.11) with respect to the noise
precision parameter β, giving
1
N
1
= {tn − wML
T
φ(xn )}2 (3.21)
βML N
n=1
THE BIAS-VARIANCE DECOMPOSITION
Bias and variance are negatively related, therefore it is essentially difficult to have
an ML model with both a low bias and a low variance. The bias-variance
decomposition is a useful theoretical tool for understanding a learning
algorithm‘s performance characteristics. Certain algorithms have a large bias and
a low variance by design, and vice versa. Bias-variance is a reducible error, in
this article, we will be understanding the concept with ways to decompose the
mean squared error.
The data predicted with high bias is in a straight-line format, which does not fit
the data in the data set adequately. Underfitting of data is a term used to describe
this type of fitting. This occurs when the theory is overly simplistic or linear in
form.
The variance of the model is the variability of model prediction for a particular
data point, which tells us about the dispersion of the data. The model with high
variance has a very complicated fit to the training data and so is unable to fit
correctly on new data.
As a result, while such models perform well on training data, they have large error
rates on test data. When a model has a large variance, this is referred to as
Overfitting of Data. Variability should be reduced to a minimum while training a
data model.
Bias and variance are negatively related, therefore it is essentially difficult to have
an ML model with both a low bias and a low variance. When we alter the ML
method to better match a specific data set, it results in reduced bias but increases
variance. In this manner, the model will fit the data set while increasing the
likelihood of incorrect predictions.
The same is true when developing a low variance model with a bigger bias. The
model will not fully fit the data set, even though it will lower the probability of
erroneous predictions. As a result, there is a delicate balance between biases and
variance.
In the above function “R(h)” which is the cost function of the algorithm also
known as the risk function. When the risk function is loss it is the squared error.
The expected function which is represented by “E” in the above equation contains
the random variables. Calculate the average of the probability distributions for
hypothesis “h”.
The data x and y are derived from the probability distribution on which the learner
will be trained. Since the weights are selected based on the training data, the
weights that define h are also obtained from the probability distribution. It can be
difficult to determine this distribution, but it does exist. The expectation function
consolidates the losses of all potential weight values.
Image source
In the above image after doing all the mathematical derivation, we can observe
that at last the three components are derived bias, variance and irreducible error
or noise.
Let’s understand this with an example.
In this example, we’re attempting to match a sine wave with lines, which are
obviously not realistic. On the left, we produced 50 distinct lines. The red line in
the top right corner represents the anticipated hypothesis which is an average of
infinitely many possibilities. The black curve depicts test locations along with the
true function.
Because lines do not match sine waves well, we notice that most test points have
a substantial bias. Here the bias is the squared difference between the black and
red curves.
Some of the test locations, however, exhibit a slight bias, where the sine wave
crosses the red line. The variance in the middle represents the predicted squared
difference between a random black line and the red line. The irreducible error is
the predicted squared difference between a random test point and the sine wave
.
DECLSION TREE
employed)
Yes
D2
Credit
Store2 Tnceme)
High ow Louu
R
Algoithm CID3
t h e given datasetL choose a target atnbu
LIn
PtN
P
p+N N0a (PtN
PtN
N
Cnrop
Entropy Ta Probabiliy
ECA) 2*Ni I N
P+N
a1ed
ON aSed
e
Lompeietion Iy Pe Profi
Jes DOun
NO slw Douon
Old
old
NO hlw Down
mid
Ses Sw DOun
mid
Yes hlu Down
mid
No blw Op
NO
mid
new
yeS
No b)uw
neu NO Sw p
SLep
Target Attaibute =Pacit
Tntormatiorn gain
T P log
PtN
N02tpN
PtN
N
5 to logt
tog,)+4 tog,(3) )
aer (-lg, x-lo9.2)
x i tx-1
(-D=L
T
Calulate entropy for remainn9 att
3
P down count
Deu N up COuDt
oba bily 3
LO
log4) ogl)
2
Prohability:tl1o Entropynid)-1x4
Taneu)a2lg{g}3a
pobability340 EntopyCneu):0x2
doyae
In the Same uay lal. Gain f Other
0tber atth
qain LCompeLition)= O D4
aain (THpe)= _O
eain (Age) o.
DOun Up
aed
ON a8ed
Learning with Trees 261
The information measure can be changed in another way, which is to add a weight to
the misclassifications. The idea is to consider the cost of misclassifying an instance of class
i as class j (which we will call the risk in Section 2.3.1) and add a weight that says how
important each datapoint is. It is typically labelled as λij and is presented as a matrix, with
element λij representing the cost of misclassifying i as j. Using it is simple, modifying the
Gini impurity (Equation (12.8)) to be:
X
Gi = λij N (i)N (j). (12.10)
j6=i
We will see in Section 13.1 that there is another benefit to using these weights, which
is to successively improve the classification ability by putting higher weight on datapoints
that the algorithm is getting wrong.
To produce a decision tree for this problem, the first thing that we need to do is work
out which feature to use as the root node. We start by computing the entropy of S:
and then find which feature has the maximal information gain:
|Surgent |
Gain(S, Deadline) = 1.6855 − Entropy(Surgent )
10
|Snear | |Snone |
− Entropy(Snear ) − Entropy(Snone )
10 10
3 2 2 1 1
= 1.6855 − − log2 − log2
10 3 3 3 3
4 2 2 1 1 1 1
− − log2 − log2 − log2
10 4 4 4 4 4 4
3 1 1 2 2
− − log2 − log2
10 3 3 3 3
= 1.6855 − 0.2755 − 0.6 − 0.2755
= 0.5345 (12.12)
5 5 5
Gain(S, Party) = 1.6855 − − log2
10 5 5
5 3 3 1 1 1 1
− − log2 − log2 − log2
10 5 5 5 5 5 5
= 1.6855 − 0 − 0.6855
= 1.0 (12.13)
6 3 3 1 1 1 1 1 1
Gain(S, Lazy) = 1.6855 − − log2 − log2 − log2 − log2
10 6 6 6 6 6 6 6 6
4 2 2 2 2
− − log2 − log2
10 4 4 4 4
= 1.6855 − 1.0755 − 0.4
= 0.21 (12.14)
Therefore, the root node will be the party feature, which has two feature values (‘yes’
and ‘no’), so it will have two branches coming out of it (see Figure 12.6). When we look at
the ‘yes’ branch, we see that in all five cases where there was a party we went to it, so we
just put a leaf node there, saying ‘party’. For the ‘no’ branch, out of the five cases there are
three different outcomes, so now we need to choose another feature. The five cases we are
looking at are:
Learning with Trees 263
FIGURE 12.6 The decision tree after one FIGURE 12.7 The tree after another
step of the algorithm. step.
We’ve used the party feature, so we just need to calculate the information gain of the
other two over these five examples:
2 2 2
Gain(S, Deadline) = 1.371 − − log2
5 2 2
2 1 1 1 1 1 1 1
− − log2 − log2 − − log2
5 2 2 2 2 5 1 1
= 1.371 − 0 − 0.4 − 0
= 0.971 (12.15)
4 2 2 1 1 1 1
Gain(S, Lazy) = 1.371 − − log2 − log2 − log2
5 4 4 4 4 4 4
1 1 1
− − log2
5 1 1
= 1.371 − 1.2 − 0
= 0.1710 (12.16)
This leads to the tree shown in Figure 12.7. From this point it is relatively simple to
complete the tree, leading to the one that was shown in Figure 12.1.
FURTHER READING
For more information about decision trees, the following two books are of interest:
• J.R. Quinlan. C4.5: Programs for Machine Learning. Morgan Kaufmann, San Fran-
cisco, CA, USA, 1993.
• L. Breiman, J.H. Friedman, R.A. Olshen, and C.J. Stone. Classification and Regression
Trees. Chapman & Hall, New York, USA, 1993.
250 Machine Learning: An Algorithmic Perspective
FIGURE 12.1 A simple decision tree to decide how you will spend the evening.
might make you study, but otherwise you’ll be slumped in front of the TV indulging your
secret love of Shortland Street (or other soap opera of your choice) rather than studying.
Of course, near the start of the semester when there are no assignments to do, and you are
feeling rich, you’ll be in the pub.
One of the reasons that decision trees are popular is that we can turn them into a set of
logical disjunctions (if ... then rules) that then go into program code very simply—the
first part of the tree above can be turned into:
• if there is a party then go to it
• if there is not a party and you have an urgent deadline then study
• etc.
That’s all that there is to using the decision tree. Compare it to the previous use of this
data, with the Naïve Bayes Classifier in Section 2.3.2. The far more interesting part is how
to construct the tree from data, and that is the focus of the next section.
BAYESIAN THEORY
Bayes’ theorem (Bayes’ law or Bayes' rule) describes the probability of an event, based on prior
knowledge of conditions that might be related to the event.
For example, if diabetic is related to age, then, using Bayes’ theorem, a person’s age can be used
to more accurately assess the probability that they have diabetic, compared to the assessment of the
probability of diabetic made without knowledge of the person's age. It is the basis of uncertain reasoning
where the results are unpredictable.
Bayes Rule
𝑃(𝐷|ℎ)𝑃(ℎ)
𝑃(ℎ|𝐷) =
𝑃(𝐷)
P(h)- prior probability of hypothesis h
P(D)prior probability of data D, the evident
P(h|D)-posterior probability (prob. Of h based on given evident)
P(D|h)- likelihood of D given h (Prob. of evident based on h)
Axioms of probability
1. All probabilities are between 0 and 1 ie0≤P(A) ≤1
2. P(True)=1 and P(false)=0
3. P(AB)=P(A)+P(B)-P(AB)
BAYESIAN NETWORK
• A Bayesian network is a probabilistic graphical model that represents a set of variables and their
probabilistic independencies. Otherwise known as Bayes net, Bayesian belief Network or simply
Belief Networks. A Bayesian network specifies a joint distribution in a structured form. It represents
dependencies and independence via a directed graph. Networks of concepts linked with conditional
probabilities.
• Bayesian network consists of
– Nodes = random variables
– Edges = direct dependence
• Directed edges => direct dependence
• Absence of an edge => conditional independence
• Requires that graph is acyclic (no directed cycles)
• 2 components to a Bayesian network
– The graph structure (conditional independence assumptions)
– The numerical probabilities (for each variable given its parents)
For eg, evidence says that lab produces 98% accurate results. It means that a person X has 98%
malaria or 2% of not having malaria. This factor is called uncertainty factor. This is the reason that we
go for Bayesian theory. Bayesian theory is also known as probability learning.
The probabilities are numeric values between 0 and 1 that represent uncertainties.
i) Simple Bayesian network
p(A,B,C) = p(C|A,B)p(A)p(B)
ii) 3-way Bayesian network (Marginal Independence)
p(A,B,C) = p(B|A)p(C|A)p(A)
B and C are conditionally independent Given A
iv) 3-way Bayesian network (Markov dependence)
Problem 1
You have a new burglar alarm installed. It is reliable about detecting burglary, but responds to minor
earth quakes. Two neighbors (John, Mary) promise to call you at work when they hear the alarm. John
always calls when hears alarm, but confuses with phone ringing. Mary likes loud music and
sometimes misses alarm. Find the probability of the event that the alarm has sounded but neither a
burglary nor an earth quake has occurred and both Mary and John call.
Consider 5 binary variables
B=Burglary occurs at your house
E=Earth quake occurs at your home
A=Alarm goes off
J=John calls to report alarm
M=Mary calls to report the alarm
Probability of the event that the alarm has sounded but neither a burglary nor an earth quake has
occurred and both Mary and John call
P(J,M,A, E, B)=P(J|A).P(M|A).P(A|E, B).P(E).P(B)
=0.90*0.70*0.001*0.99*0.998
=0.00062
Problem 2
Rain influences sprinkler usage. Rain and sprinkler influences whether grass is wet or not. What is the
probability that rain gives grass wet?
Solution
Let S= Sprinkler
R=Rain
G=Grass wet
P(G,S,R)=P(G|S,R).P(S|R).P(R)
=0.99*0.01*0.2
=0.00198
Problem 3
Bayesian Classifier: Training Dataset
Class:
C1:buys_computer = ‘yes’
C2:buys_computer = ‘no’
Data sample
X = (age <=30, Income = medium, Student = yes Credit_rating = Fair)
age income student credit_ratingbuys_computer
<=30 high no fair no
<=30 high no excellent no
31…40 high no fair yes
>40 medium no fair yes
>40 low yes fair yes
>40 low yes excellent no
31…40 low yes excellent yes
<=30 medium no fair no
<=30 low yes fair yes
>40 medium yes fair yes
<=30 medium yes excellent yes
31…40 medium no excellent yes
31…40 high yes fair yes
>40 medium no excellent no
Solution
• P(Ci):
P(buys_computer = “yes”) = 9/14 = 0.643
P(buys_computer = “no”) = 5/14= 0.357
• Compute P(X|Ci) for each class
P(age = “<=30” | buys_computer = “yes”) = 2/9 = 0.222
P(age = “<= 30” | buys_computer = “no”) = 3/5 = 0.6
P(income = “medium” | buys_computer = “yes”) = 4/9 = 0.444
P(income = “medium” | buys_computer = “no”) = 2/5 = 0.4
P(student = “yes” | buys_computer = “yes) = 6/9 = 0.667
P(student = “yes” | buys_computer = “no”) = 1/5 = 0.2
P(credit_rating = “fair” | buys_computer = “yes”) = 6/9 = 0.667
P(credit_rating = “fair” | buys_computer = “no”) = 2/5 = 0.4
• X = (age <= 30 , income = medium, student = yes, credit_rating = fair)
P(X|Ci) :
P(X|buys_computer = “yes”) = 0.222 x 0.444 x 0.667 x 0.667 = 0.044
P(X|buys_computer = “no”) = 0.6 x 0.4 x 0.2 x 0.4 = 0.019
P(X|Ci)*P(Ci) :
P(X|buys_computer = “yes”) * P(buys_computer = “yes”) = 0.028
P(X|buys_computer = “no”) * P(buys_computer = “no”) = 0.007
Therefore, X belongs to class (“buys_computer = yes”)
Problem 4
Did the patient have malignant tumour or not?
A patient takes a lab test and the result comes back positive. The test returns a correct positive
result in only 98% of the cases in which a malignant tumour actually present, and a correct negative
result in only 97% of the cases in which it is not present. Furthermore, o.oo8 of the entire population
have this tumour.
Solution:
P(tumour)=0.008 P(tumour)=0.992
P(+|tumour)=0.98 P(-|tumour)=0.02
P(+|tumour)=0.03 P(-|tumour)=0.97
𝑃(+|𝑡𝑢𝑚𝑜𝑢𝑟)𝑃(𝑡𝑢𝑚𝑜𝑢𝑟)
𝑃(𝑡𝑢𝑚𝑜𝑢𝑟)|+) =
𝑃(+)
0.98 ∗ 0.008
=
𝑃(+)
𝑃(+|𝑡𝑢𝑚𝑜𝑢𝑟)𝑃(𝑡𝑢𝑚𝑜𝑢𝑟)
𝑃(𝑡𝑢𝑚𝑜𝑢𝑟)|+) =
𝑃(+)
0.3∗0.992
=
𝑃(+)
Case 2:
Hypothesis: Did the patient have malignant tumour if the result reports negative.
Solution:
P(tumour)=0.008 P(tumour)=0.992
P(+|tumour)=0.98 P(-|tumour)=0.02
P(+|tumour)=0.03 P(-|tumour)=0.97
= (0.02)(0.008)/p(-)
= (0.97)(0.992)/p(-)
(0.02)(0.008)/p(-) + (0.97)(0.992)/p(-) = 1
(0.002)(0.008) + (0.97)(0.992) =p(-)
0.000016+0.96=p(-)
Hence p(-)=0.96
The probability of not having tumour is high. So the person is not having malignant tumour.
MARKOV MODEL
Markov model is a discrete finite system with N distinct states. It begins (at time t=1) in some initial
states. At each time step (t=1,2,..) the system moves from current to next state according to transition
probabilities associated with current state. This kind of system is called a finite or discrete Markov
model.
Markov property (Memory less property): The state of the system at time t+1 depends only on the
state of the system at time t. Future is independent of past given present. Three basic information to
define a Markov model
Parameter space
State space
State transition probability
What is the probability that the weather for the next 7 days will be “sun-sun-rain-rain-sun-cloudy-sun”
when today is sunny?
S1: rain, S2: cloudy, S3: sunny
P(O|model)=P(S3, S3, S3, S1, S1, S3, S2,S3|model)
=P(S3)*P(S3|S3)* P(S3|S3)* P(S1|S3)* P(S1|S1)* P(S3|S1)* P(S2|S3)* P(S3|S2)
= π 3*a33*a33*a31*a11*a11*a13*a32*a23
=1*0.8*0.8*0.1*0.4*0.3*0.1*0.2
=1.536x10-4
Initial sate probability matrix
0.5
π =( π i)=[0.2]
0.3
Sate transition probability matrix
0.6 0.2 0.2
A={aij}=[0.5 0.3 0.2]
0.4 0.1 0.5
What is the probability of 5 consecutive up days?
P(1,1,1,1,1)= π 1*a11*a11*a11*a11=0.5*(0.6)4= 0.0648
aij are state transition probabilities, bik are observation (output) probabilities.
Example 1:
2. Decoding Problem
Given the HMM M= (A, B, π) and the observation sequence O=o1 o2 ... oK, calculate the most
likely sequence of hidden states Si that produced this observation sequence O.
Solution: Use efficient Viterbi algorithm
Define variable δk(i) as the maximum probability of producing observation sequence o1, o2 ...
ok when moving along any hidden state sequence q1… qk-1 and getting into qk= si .
δk(i) = max P(q1… qk-1 , qk= si , o1 o2 ... ok) where max is taken over all possible paths q1… qk-1.
3. Learning Problem
Given some training observation sequences O=o1 o2 ... oK and general structure of HMM
(number of hidden and visible states), determine HMM parameters M= (A, B, π) that best fit
training data.
Solution: Use iterative expectation-maximization algorithm to find local maximum of P(O|M)
- Baum-Welch algorithm
Expected number of transitions from state sj to state si
aij= Expected number of transitions out of state sj
2. Mathematical Form
A: The height of a child
B: The # of words that the child knows
C: The child's age
A better way to remember the expression:
Thus, MRFs have more power than Bayesian networks, but are more difficult
to deal with computationally. A general rule of thumb is to use Bayesian
networks whenever possible, and only switch to MRFs if there is no natural
way to model the problem with a directed graph (like in our voting
example).
-CollPCron
Bayes eheorem A
*
on
based
Classifier not a bingle alg, butfamiloE al
Naive Rayes Share
common pmnap
a
beiDg claASIA
e eve
iS_indo
QLofeature
f eaOh e t t a
aProbablistc
A naie Baus claSSifier is
coseificatontassk
ML Model haLs Used for
Hat
Bayes Thapaun
PLa B PLBIA) .P) O- PoRmuna
PL8)
Featis
the_pooablity of
sing D e_an £ind
Occcarebce e A VenB
B Evidence
A> tPothesis
Example
EEs au oe bave a leature " headache" klCol
n Po
P A o p oh t
CTas
aeneralixing utetiko
Phohahilit
PALdictor_paioipRobabi lity
xFor all _entria in a data set the denaminator
does not Change Jt Can be removed
ON8ed
PClengty) xP(sweel) x pCyello) y
Lets uOk outL tach factor s in
o0o 0 8
PLenghy l8anana
P (Swee| 31500= 7
PgellawI 495D0
PCeanaDa )
500 Lo00 = 055
PCLengthy)
PCSweet) 6GD looO -0 65
PLyellow) 1ooo= O8
in
Subsutuitingall the above values
=0.62 0.94
thy,DeeEgRlaL
Plorangel Leng
No
N De need +o find
lororngs
Pengtylotange)
xD[swee lorarge)xPLHell
xPCorange)
PLlengthy)xPcweet)x Plyella)
L
Sin Ce pCLengtbylozange)=6
PLorangel lengthy sweet yellow =6
oN -doyla1ea
t i n d tor
We ASsign the
classwhich has maX._pogbability
which S gn b eq
m an m u u m
0f Gau
-posiion
Super
(n
dIs
é)
GaUssaN
T N (z ]HK
multi-varnate
P2)- N O r m a l
f ea
ore
tor ac
chh
Neiqhlage
(Oepficient: Saussian dist
Mixing
NO of Gaussians
reaure
N o r m a x l i z a t i o n
& Positi
v
i ty
O TTk , TT =
(onsidler loq-Likelihoed N
Plxn)= 2 n N(2nHk
n P(xIM, 4,T) =á4n rom )
no. Of insLaN Ce
form Son
ML doesnot uwork bere athere is no clased
Miture o f
3 6au6siaN
Obtain
frog
05
sa
(sam clA)
Catter matiX
probabili
POstEriOr
Late varia be
as P71Or
thin of the miing Co-ePfîCients
We an
Compenents
for the
Proba b i l i i e s
can e v a l u at e the
the
we
of x,
For a gn. va lue Called vesponbilii
pos&eior probabilities,
Correspondi m
M)
qaasSian Mixture model GMN
G(2|Hor= 4 2
2 2
2T
Man Varnance
NCa , » eN p x - 4 ' t 2 - w )
mean Co-variance
parameLers2, H)
of a
We need to etimate thesa
distibution:
£s Emato
*one method- Marimum Likelihood CML)
s
ML method for estimating Parame
diStrTbution
* Consider log of Gaussi an
(x-)
2n
Pla]H á): an(a) -arn |El -L(1-H
Zero
deMYatiVe & e¢uate
Take t h e
n P(|E)=o enPlzHE)
mi ture of GaUSSIans ?
What f we have
Gaus s i a n Mixture
Proro Baya Yule,
LQtent
Px NoOfampls
fbr pa tHC uhr
variablE
e lass
T N Ca HE , é whor e, T=Nx
N
T N (a|Hj£j)
No of
sampS
pts qssGNEd
Interpet k as the effective no. of
to Cluster k
EM lg for GMM
ikelihoad m
maximize -the
a MM, the goal is to ico-variances
coefficients
the2 Compaonenis
Of the
Of the2 mixing
.Dnitialize the me
j CDvaNiances z; &mixinG
Cintex likelihoo
Co-eff. T evalua te the initial value of Log
the curre
the responSi
billties usi ng
2. L
E-9Lep E v a l u a te
S ep: Pa a m e t e r values
J
parameters uSng the
3 currerDe
M-SLep: Re-etima te the
esponSibilities
N N
2Can)
T (an)
Evaluabe log Liklihoobd
N
An P(x|H, £,TT ) =É n N(an]Hk) é)9
to SLep 2
TA there ìs return
no
Converqen ce, SuccesSve
in Aev Iteratons
P2TT no change
iterations
in Prev.
ciange
og lik lidvool
no
EM alg : EXample
L5
repeate L
EM Step
AecOupu e Ld
rRe Blue
20
Re
Blue
He archi cal Cluste inj
Jn this ue mrtitio the dala by
pproach,
9ouping i into a tree o CluCteIs or a
bierar chy
s ue
isu s sfeu
fll
dala
epresenlateN of
H1erar Chical visuali zati on.
visuali z a t t o n .
data zaUn
Summari
for
for
a n d divide
combinos
Hierar chical cluster ing alq. SLH
hierarchical
a
exis ing r u p s , Creating are
the o r d e r
in which a r o u p s
that Showcases
Divisive
METHOD
CLSiERING
AGGLOME RATIVE
HtERARC HIC AL
iS used
approach
Bottom-up
Own
cluster.
-forms i-S
Each Object iLeratively mergin9
merging
The proceSS Converges by Leratively
a Lhe
l Lhe
all
c t u s t e r s , unti
ctusterS into larger terminaie
or a
etuster
are n a Single
objects
Conditon is reached
aistance
C(usters are identi-fied using
ures & Combine d to form a
larger
meas
Ctuster
Per iteratlon , two clusters a
are
e met ged, uwhere
each cluster
one obect
Contains aLea
the
at most
I9lbmeraiive meth require
'niLera tions
Three tHpes
O Single link Lechnique
The dist blw tuwo ctusters is defind as
a in each cluster.
the shortest dist. bw PAs
o
Conmplete tink echnique
is dasina as the
the
the dist bluU w o ctusters
Average tinKtechnique
Theavg
diSt blw each PE. In one cluSAer to everypl
Sep
Compute the dist. n a t i z
al tay)(aib)) =
Ca-a+(t-6
PIP2 P3 P4P5 P 6
PI
P2 1 o
P35664
P4 3.6 242 |2.24
PS24 3.53 4) |o
P
O
P 3.20|2.5 25 o.5 12
Step 2: clusters
Merging the & clasest members 0f
in dist. matma
fiod the. min. elemen t
min o5
P2 o1 O
P3 564 4-9S|O
36 2 92 2.5 O
P4P6
O
I.4112
Ps 4.24 353
Nou we (ombire PI&P2 d (P P3))
P3),
max (d (Ply P2) ,
P3)= maa/ d (Pl) b6
5 . 6 6 , 4 . 9 5 ) = t .
mar ( Pb
CP2 *|Pb
( Pl,Pu, Pt) ,
CaPlP2), (P41 PL)) = maa
3.6
2.4) =
maz ( 9.6,
3.53)
max Ca CPl P2) , P5) max CG.24,
2 4
P3 P4 P6 P5
Pl P2
CPl P2) O
5.66 O
P3
25
CP4 PL)
3.6
P5 2t 12
P4 PL P5 P3 P P2
Average gink:
as above
Same datapts.
AfLer al dlsL. m a t a i a
PIP P3P4Ps P
PI
P2 o7 o
P3 5.664
P4 3.6 |2.42 2.24
P5 424 353 | 41 |O
P6 8.202.5 | 2.5 D5112 O
9o Combne P4+) P6
Sc P4 P?), ( P6, PP)I
ava Cal P4, P6),
d ( PD) =
a9C
P2
o11 O
P3
5-66 445
P4 P6 3.4 2.71 2.37
Ps 424 3.53 41 06
No Combine PI4P2
dCp2,P3)DD
avg(a (PIy P2), Ps) =avg (d CP), P3D,
5.31
avg t5.66, 4.95)
=
P3 5.31
P4 P% 2.96 2.37
P5 3.89 t.41 06
CPI; P2)) =
avg ( Pl> P2) (P5, Pls P2)
P41 P6,
avg ld CP4) Pé, Ps)
avg a.9, 9.84) - 8.43
(Pl Pa
P3 S.31
P4,PbPs 3.4-3 6)
PIP2-
P3), CPlP2): ava(py, Po,Ps) (
avg (d (p4,Pb, P5,
CP3, PlyP2)
5-31) +37
avg (3.43,
PP2 P4 Pb PS P3
Pl, P2
P p
P PG P5 P3
Sinale link
as above
*Same dala pS.
mataia
[Link] aat dist P% P
P2 P3 P4
PL
Pt
P2
P3 5.66 495
Combine P P6.
25
25)
min P¢P6),P2)
(at i n t a42,
9.5): 2. 24
min (dC P41 P6), P3) mim (a.2 4,
t
min(dc P4Pé), Ps)= min (1, 1.12)
date distmati«
PG P5
p2
P3 P4
P
P
P2
P3 5-66 4 O
P5
Ps 224 9.53 .41
PIR P2
Combine
(4-24 j 3.53)
= 3.53
min CdC PIP2), Ps) min
OPdae;
P4 Pb P5
Pl Pa P 3
Pl P2
4-95 O
P3
P4 P 25 2:24
363I4l
Ps
P4, P6, P5
Combine P2)
min p4 P% Pl)
Pé, P), (Ply P2): CP5 Pl P2)3
min CdlP+
= 2.5
2.5/3.53)
min (
P3)
min (d CP4) Pb, P5, min , Pe, Pa)fs PD}
min (2.2 4, .4-1=t 41
Opdate Pl P2 P3 P Po Ps
Pl, P2
4. 9 5
P3
P4+, Po Ps 2.5
P3
Combine P4 P6, P
minf(P4 Pb,Ps )(M,P)
(Pi, P2)) -
in (dC Py Pby Ps, P3),
(rgPIP) y
m i n ( 9 . 5 , 4.95)-2.5/
P3
Upodate Pb, P ,
P P2 P4
PI, P2
O
25
P4 Po P5, Pa
Dendogram
P6 p P P2
P
DiviSive
Hie rarcbical cluserIn
PROCESS cluseer
obj. in
one
atl
Start by placing
by
ctusters
have Single abet
have
Cuni atl t h e
2. Repeat
Repeat
maz
intr-cluster
cluster
wlth
a
a) selecE
bisecting kmeans
Dvisive method
ProcesS R HS
Of
Points
P its c ltester
in aa cluASAer
in
he Set
OConsidr
Centroid
andom CL among the set of PLs
aa PL at
Setecte
pt. af CL
Construct ne PtCR a s the ymmetnC
[Link] centroid w Such that,
Co, cR)
distance Cw, CL)= d lstance
cluser it
in the
Seperate the other PES
to
ones ctosest to CR betong
betong
&groups
closet
Example
Consider datapts.
6(s13
(s,5), asC7, +),
a
ito 2 cluster.
splitit
+877+8/6=s
Soln (5,5)
2+2 3
7+5+6+5tYt 3/b *S
as
SComputed
Centroid w
O
to CL
o CL
be. assigned a5 coi{t be
Let a s (S,6) CL t o w,
stmmetiCitY
of
Basedd on
assigned o Ce,
Ca2,a3D, [a4a»
(a,a3D, la4\a
diSt, we see Cal, a3) ,
the
Evaluating
(a4a2), (a6, a 3)
Cal)a), Ca2,as))
Cabas,
a r e e t o s e r
to a3
alag aSs
closes E
clesest
to
t o a
are
aL
a4
LS a bbott
a out inding
findin9
Spectra
rera
dusiering
10a qraph
connected Abgraphs 2
toFinoding
the mostky
clusters
the
there by identirjing
SolO:
maximum
nmaximUm
no. e£
no. e witbi
whin5
Pinding Sub
graphs having blc c
C ll
u uss
te r
te
Pindin comecims
minimum
miimum no. a blw
Ctuser
Conecuons
graph GCVE)
undirected
Cwe have
Lets
Lets 9a4
Y3-
AAE
dsjoint qrouPS ALS
groups
nto
Hto 2a aSJoint
Tosk vertices of &
i d e -the
Y
is a goed cluster J
Gaph cuts What
but hes e
e set
t af
af
is nothin9
A Cu h a 9raph
closter
cluster
the
one node in
ecges wHh only
only
o4 edae
Cut a)=
jée
ieA
as
Let asSSume te edge weigt
The cuL CA)= a
cleustt
ADt
may alse
he
his
a Cct
metric alled
To overcome tnis oe go for
than ct"
Cond uctance"
the
Connectivit af the aroup to the r o s t of
the den sity a the goup
Ow retative to
shud know abt. volu me' me t1¢
of nodo i
d e qee
vol (A di
iA
Spectral cluStering
3 man Steps
Pre- processing
-MatrinreP of a graph
De Co mpositor
- Compu &e
e igen valuee & eigm vectrs af m a t i x
Eigen
Eige+or Value2
Spectral ctustering
bt the eigen rectors
is nothing
the mamitude ao
9pecerum magnitade af
ordered
aj of a graph,
23 456 with
2,3, 5 . Hence
A
2
5
let's find the
Rerfom LaplacIaN matrix,
matix
Degree 4 5 6
O O
D 3
2 2
O
O O
3 0
4o O
5 0 o3
2
23+||6 0 p a i ro f nodas
not ConNected
3
2 nodes
2 - Pair of
3 O that are
3 Connectad
1)
hat the dsmalle
in
L =o each row 2 eiqen value A he|ps
Co. adds Partition
the Graph
pto finding
Correspodin
*The eigen vector
the nede
Partitin
to A2
in such a uay (hat
a bels
B
0
Eigen vecfor, 2
SO
+ ieA
eB
2
3
A,2,39 & group
af
eigen vector 3 Clus t s
+
5 3
6
Summary
Prepro Sing Matriq constr on
D e conposin9 Pindin elgen vectors/values
Grouping n9 Partionig/elusteving.
Dimensionality Reduction
The number of input features, variables, or columns present in a given dataset is known as
dimensionality, and the process to reduce these features is called dimensionality reduction.
A dataset contains a huge number of input features in various cases, which makes the predictive
modeling task more complicated. Because it is very difficult to visualize or make predictions for
the training dataset with a high number of features, for such cases, dimensionality reduction
techniques are required to use.
Dimensionality reduction technique can be defined as, "It is a way of converting the higher
dimensions dataset into lesser dimensions dataset ensuring that it provides similar
information." These techniques are widely used in machine learning for obtaining a better fit
predictive model while solving the classification and regression problems.
It is commonly used in the fields that deal with high-dimensional data, such as speech recognition,
signal processing, bioinformatics, etc. It can also be used for data visualization, noise reduction,
cluster analysis, etc.
Handling the high-dimensional data is very difficult in practice, commonly known as the curse of
dimensionality. If the dimensionality of the input dataset increases, any machine learning
algorithm and model becomes more complex. As the number of features increases, the number of
samples also gets increased proportionally, and the chance of overfitting also increases. If the
machine learning model is trained on high-dimensional data, it becomes overfitted and results in
poor performance.
Hence, it is often required to reduce the number of features, which can be done with dimensionality
reduction.
Some benefits of applying dimensionality reduction technique to the given dataset are given below:
o By reducing the dimensions of the features, the space required to store the dataset also gets
reduced.
o Less Computation training time is required for reduced dimensions of features.
o Reduced dimensions of features of the dataset help in visualizing the data quickly.
o It removes the redundant features (if present) by taking care of multicollinearity.
There are also some disadvantages of applying the dimensionality reduction, which are given
below:
There are two ways to apply the dimension reduction technique, which are given below:
Feature Selection
Feature selection is the process of selecting the subset of the relevant features and leaving out the
irrelevant features present in a dataset to build a model of high accuracy. In other words, it is a
way of selecting the optimal features from the input dataset.
Filters Methods
In this method, the dataset is filtered, and a subset that contains only the relevant features is taken.
Some common techniques of filters method are:
o Correlation
o Chi-Square Test
o ANOVA
o Information Gain, etc.
Wrappers Methods
The wrapper method has the same goal as the filter method, but it takes a machine learning model
for its evaluation. In this method, some features are fed to the ML model, and evaluate the
performance. The performance decides whether to add those features or remove to increase the
accuracy of the model. This method is more accurate than the filtering method but complex to
work. Some common techniques of wrapper methods are:
o Forward Selection
o Backward Selection
o Bi-directional Elimination
Embedded Methods: Embedded methods check the different training iterations of the
machine learning model and evaluate the importance of each feature. Some common
techniques of Embedded methods are:
o LASSO
o Elastic Net
o Ridge Regression, etc.
Feature Extraction:
Feature extraction is the process of transforming the space containing many dimensions into space
with fewer dimensions. This approach is useful when we want to keep the whole information but
use fewer resources while processing the information.
Example:
Let’s suppose that our data set is 2-dimensional with 2 variables x,y and that the eigenvectors and
eigenvalues of the covariance matrix are as follows:
If we rank the eigenvalues in descending order, we get λ1>λ2, which means that the eigenvector
that corresponds to the first principal component (PC1) is v1 and the one that corresponds to the
second component (PC2) isv2.
After having the principal components, to compute the percentage of variance (information)
accounted for by each component, we divide the eigenvalue of each component by the sum of
eigenvalues. If we apply this on the example above, we find that PC1 and PC2 carry respectively
96% and 4% of the variance of the data.
Your question is how did he come up with those numbers? Which words in these
sentences carry "information":
o broccoli, bananas, smoothie, breakfast, munching, eat
o chinchilla, kitten, cute, adopted, hampster
Now let's go sentence by sentence getting words from each topic:
o food 3, cute 0 --> food
o food 5, cute 0 --> food
o food 0, cute 3 --> cute
o food 0, cute 2 --> cute
o food 2, cute 2 --> 50% food + 50% cute
So my numbers, differ slightly from Chen's. Maybe he includes the word "piece"
in "piece of broccoli" as counting towards food.
LDA Procedure
Step1: Go through each document and randomly assign each word in the document to one
of K topics (K is chosen beforehand)
Step2: This random assignment gives topic representations of all documents and word
distributions of all the topics, albeit not very good ones
So, to improve upon them: For each document d, go through each word w and compute:
p(topic t | document d): proportion of words in document d that are assigned to topic t
p(word w| topic t): proportion of assignments to topic t, over all documents d, that come
from word w
Step3: Reassign word w a new topic t’, where we choose topic t’ with probability
Solved calculation
Let's say you have two documents.
Next then,
After then, we will randomly select a word from doc i (word bank with topic assignment 1)
and we will remove its assigned topic and we will calculate the probability for its new
assignment.
For the
topic k=1
For the
topic k=2
Good fit for both document and word for topic 2 (area is greater) than topic 1. So, our new
assignment for word bank will be topic 2.
Now, we will update the count due to new
assignment.
Now we will repeat the same step of reassignment. and iterate through each word of the
whole
corpus.
dimensioN from 2to
t
Ue PCA to teduce
teatue E2 EE3 E4 4
13
SLep
No Af featur& n= 2
No. af Samples NE
Step2
variables
Compule mean e
= 4 8_t 3 t 7 4 8S
8 5
t +4++5. +tt/4
Step3
CompLatia_Co-var Ma tri
EY
Ordered pairs Caz) (a1H) CY2)
a_erederee pairS
Co-Yar ap
23
( CO-Var mahia_ O sle hxn [Link]-
Cov(12) Covla)
t o v ) cov (H)|
-U
- -I 23
SEep 4
COn&Lrualeigen value eign vecke
Noxmalized_ eigen vecter
i g e nv a t t
i d o n h t m a - l n r
d claen value
d e t (s-XT)=o
dt| 23-
Ct4-) C29-A) - C-12 (-u) to
vot
31At 20 6 ya
31
Elaen ector e A
t
23-A
U
4-A)u-lu2
-u + (23 - 2 4 2
-Au1lU20
T-
lu L23-A)Ua
u2
L-A
Vi+(-6.38) 2
=05514
-O. 303
e2- . s303
to.sST4
PCh P2 P3 PIq
P e 8 Lo551-o. 903J.
-85
- 2052
8-8
P12 b:564 8303 3. 134
4-85
P3 5.L22s
P4 S-4238
ON 28ed Pc -4-3or233SL S
Introduction to latent variable models
lecture 1
Francesco Bartolucci
Department of Economics, Finance and Statistics
University of Perugia, IT
bart@[Link]
[2/24]
Outline
• Finite mixture model: model, used even for a single response variable,
in which subjects are assumed to come from subpopulations having
different distributions of the response variables; typically covariates
are ruled out
• Basic notation:
. n: number of sample units (or clusters in the multilevel case)
. T : number of response variables (or observations of the same
response variable) for each subject
. yit: response variable of type t (or at occasion t) for subject i
. xit: corresponding column vector of covariates
General formulation of latent variable models [13/24]
• Exercise: write down the density of the model in the univariate case
with k = 2 and represent it for different parameter values
General formulation of latent variable models [17/24]
• In this case the nodes ξc and the corresponding weights πc are a priori
fixed; a few nodes are usually enough for an adequate approximation
• With more latent variables (l > 1), the quadrature method may be
difficult to implement and unprecise; a Monte Carlo method is
preferable in which the integral is approximated by a mean over a
sample drawn from the distribution of ui
General formulation of latent variable models [18/24]
exp[yit(ui + x0itβ)]
p(yit|ui, X i) = p(yit|ui, xit) =
1 + exp(ui + x0itβ)
• Exercise: show how to implement the algorithm for the finite mixture
of Normal distributions with common variance (try simulated data)
Latent class and latent regression model [24/24]
• Exercise: implement the EM algorithm for the latent class model (try
on the Goodman (1974) dataset)
Latent class and latent regression model [25/24]
ADVANCED LEARNING
REINFORCEMENT LEARNING:
There are mainly three ways to implement reinforcement-learning in ML, which are:
1. Value-based:
The value-based approach is about to find the optimal value function, which is
the maximum value at a state under any policy. Therefore, the agent expects
the long-term return at any state(s) under policy π.
2. Policy-based:
Policy-based approach is to find the optimal policy for the maximum future
rewards without using the value function. In this approach, the agent tries to
apply such a policy that the action performed in each step helps to maximize
the future reward.
The policy-based approach has mainly two types of policy:
To understand the working process of the RL, we need to consider two main things:
○ Environment: It can be anything such as a room, maze, football ground, etc.
Let's take an example of a maze environment that the agent needs to explore.
Consider the below image:
In the above image, the agent is at the very first block of the maze. The maze is
consisting of an S6 block, which is a wall, S8 a fire pit, and S4 a diamond block.
The agent cannot cross the S6 block, as it is a solid wall. If the agent reaches the S4
block, then get the +1 reward; if it reaches the fire pit, then gets -1 reward point. It
can take four actions: move up, move down, move left, and move right.
The agent can take any path to reach to the final point, but he needs to make it in
possible fewer steps. Suppose the agent considers the path S9-S5-S1-S2-S3, so he
will get the +1-reward point.
The agent will try to remember the preceding steps that it has taken to reach the final
step. To memorize the steps, it assigns 1 value to each previous step. Consider the
below step:
Now, the agent has successfully stored the previous steps assigning the 1 value to
each previous block. But what will the agent do if he starts moving from the block,
which has 1 value block on both sides? Consider the below diagram:
It will be a difficult condition for the agent whether he should go up or down as each
block has the same value. So, the above approach is not suitable for the agent to
reach the destination. Hence to solve the problem, we will use the Bellman
equation, which is the main concept behind reinforcement learning.
○ The reward/feedback obtained for each good and bad action is "R."
Where,
γ = Discount factor
In the above equation, we are taking the max of the complete values because the
agent tries to find the optimal solution always.
So now, using the Bellman equation, we will find value at each state of the given
environment. We will start from the block, which is next to the target block.
V(s3) = max [R(s,a) + γV(s`)], here V(s')= 0 because there is no further state to
move.
V(s1) = max [R(s,a) + γV(s`)], here γ= 0.9(lets), V(s')= 0.9, and R(s, a)= 0, because
there is no reward at this state also.
V(s5) = max [R(s,a) + γV(s`)], here γ= 0.9(lets), V(s')= 0.81, and R(s, a)= 0, because
there is no reward at this state also.
V(s9) = max [R(s,a) + γV(s`)], here γ= 0.9(lets), V(s')= 0.73, and R(s, a)= 0, because
there is no reward at this state also.
○ Positive Reinforcement
○ Negative Reinforcement
Positive Reinforcement:
This type of reinforcement can sustain the changes for a long time, but too much
positive reinforcement may lead to an overload of states that can reduce the
consequences.
Negative Reinforcement:
The negative reinforcement learning is opposite to the positive reinforcement as it
increases the tendency that the specific behavior will occur again by avoiding the
negative condition.
○ Q-Learning:
○ It learns the value function Q (S, a), which means how good to take
action "a" at a particular state "s."
○ In SARSA, new action and reward are selected using the same policy,
which has determined the original action.
○ SARSA is named because it uses the quintuple Q(s, a, r, s', a'). Where,
s: original state
a: Original action
r: reward observed while following the states
s' and a': New state, action pair.
Q-Learning Explanation:
○ The main objective of Q-learning is to learn the policy which can inform
the agent what actions should be taken for maximizing the reward under
what circumstances.
○ The value of Q-learning can be derived from the Bellman equation. Consider
the Bellman equation given below:
In the equation, we have various components, including reward, discount factor (γ),
probability, and end states s'. But there is no any Q-value is given so first consider the
below image:
In the above image, we can see there is an agent who has three values options, V(s1),
V(s2), V(s3). As this is MDP, the agent only cares for the current state and the future
state. The agent can go in any direction (Up, Left, or Right), so he needs to decide
where to go for the optimal path. Here the agent will take a move as per probability
bases and change the state. But if we want some exact moves, for this, we need to
make some changes in terms of Q-value. Consider the below image:
Q- represents the quality of the actions at each state. So instead of using a value at
each state, we will use a pair of state and action, i.e., Q(s, a). Q-value specifies which
action is more lubricated than others, and according to the best Q-value, the agent
takes his next move. The Bellman equation can be used for deriving the Q-value.
To perform any action, the agent will get a reward R(s, a), and also he will end up on
a certain state, so the Q -value equation will be:
Q-table:
A Q-table or matrix is created while performing the Q-learning. The table follows the
state and action pair, i.e., [s, a], and initializes the values to zero. After each action,
the table is updated, and the q-values are stored within the table.
The RL agent uses this Q-table as a reference table to select the best action based on
the q-values.
1. Robotics:
2. Control:
3. Game Playing:
4. Chemistry:
5. Business:
6. Manufacturing:
a. In various automobile manufacturing companies, the robots use deep
reinforcement learning to pick goods and put them in some containers.
7. Finance Sector:
REPRESENTATION LEARNING:
In representation learning, data is sent into the machine, and it learns the
representation on its own. It is a way of determining a data representation of the
features, the distance function, and the similarity function that determines how the
predictive model will perform. Representation learning works by reducing
high-dimensional data to low-dimensional data, making it easier to discover patterns
and anomalies while also providing a better understanding of the data’s overall
behaviour.
Basically, Machine learning tasks such as classification frequently demand input that
is mathematically and computationally convenient to process, which motivates
representation learning. Real-world data, such as photos, video, and sensor data, has
resisted attempts to define certain qualities algorithmically. An approach is to
examine the data for such traits or representations rather than depending on explicit
techniques.
Supervised Learning
This is referred to as supervised learning when the ML or DL model maps the input
X to the output Y. The computer tries to correct itself by comparing model output to
ground truth, and the learning process optimizes the mapping from input to output.
This process is repeated until the optimization function reaches global minima.
Even when the optimization function reaches the global minima, new data does not
always perform well, resulting in overfitting. While supervised learning does not
necessitate a significant amount of data to learn the mapping from input to output, it
does necessitate the learned features. The prediction accuracy can improve by up to
17 percent when the learned attributes are incorporated into the supervised learning
algorithm.
Using labelled input data, features are learned in supervised feature learning.
Supervised neural networks, multilayer perceptrons, and (supervised) dictionary
learning are some examples.
Unsupervised Learning
Unsupervised learning is a sort of machine learning in which the labels are ignored in
favour of the observation itself. Unsupervised learning isn’t used for classification or
regression; instead, it’s used to uncover underlying patterns, cluster data, denoise it,
detect outliers, and decompose data, among other things.
When working with data x, we must be very careful about whatever features z we use
to ensure that the patterns produced are accurate. It has been observed that having
more data does not always imply having better representations. We must be careful to
develop a model that is both flexible and expressive so that the extracted features can
convey critical information.
Unsupervised feature learning learns features from unlabeled input data by following
the methods such as Dictionary learning, independent component analysis,
autoencoders, matrix factorization, and various forms of clustering are among
examples.
In the next section, we will see more about these methods and workflow, how they
learn the representation in detail.
Supervised Methods
Multi-Layer Perceptron
The perceptron is the most basic neural unit, consisting of a succession of inputs and
weights that are compared to the ground truth. A multi-layer perceptron, or MLP, is a
feed-forward neural network made up of layers of perceptron units. MLP is made up
of three-node layers: an input, a hidden layer, and an output layer. MLP is commonly
referred to as the vanilla neural network because it is a very basic artificial neural
network.
This notion serves as a foundation for hidden variables and representation learning.
Our goal in this theorem is to determine the variables or required weights that can
represent the underlying distribution of the entire data so that when we plug those
variables or required weights into unknown data, we receive results that are almost
identical to the original data. In a word, artificial neural networks (ANN) assist us in
extracting meaningful patterns from a dataset.
Neural Networks
Neural networks are a class of learning algorithms that employ a “network” of
interconnected nodes in various layers. It’s based on the animal nervous system, with
nodes resembling neurons and edges resembling synapses. The network establishes
computational rules for passing input data from the network’s input layer to the
network’s output layer, and each edge has an associated weight.
The relationship between the input and output layers, which is parameterized by the
weights, is described by a network function associated with a neural network.
Various learning tasks can be achieved by minimizing a cost function over the
network function (w) with correctly defined network functions.
Unsupervised Methods
Learning Representation from unlabeled data is referred to as unsupervised feature
learning. Unsupervised Representation learning frequently seeks to uncover
low-dimensional features that encapsulate some structure beneath the
high-dimensional input data.
K-Means Clustering
K-means clustering is a vector quantization approach. An n-vector set is divided into
k clusters (i.e. subsets) via K-means clustering, with each vector belonging to the
cluster with the closest mean. Despite the use of inferior greedy techniques, the
problem is computationally NP-hard.
There are two major steps in LLE. The first step is “neighbour-preserving,” in which
each input data point Xi is reconstructed as a weighted sum of K nearest neighbour
data points, with the optimal weights determined by minimizing the average squared
reconstruction error (i.e., the difference between an input point and its reconstruction)
while keeping the weights associated with each point equal to one.
The second stage involves “dimension reduction,” which entails searching for vectors
in a lower-dimensional space that reduce the representation error while still using the
optimal weights from the previous step.
The weights are optimized given fixed data in the first stage, which can be solved as
a least-squares problem. Lower-dimensional points are optimized with fixed weights
in the second phase, which can be solved using sparse eigenvalue decomposition.
When the number of vocabulary items exceeds the dimension of the input data,
sparse coding can be used to learn overcomplete dictionaries. K-SVD is an algorithm
for learning a dictionary of elements that allows for sparse representation.
Autoencoders
Deep network representations have been found to be insensitive to complex noise or
data conflicts. This can be linked to the architecture to some extent. The employment
of convolutional layers and max-pooling, for example, can be proven to produce
transformation insensitivity.
NEURAL NETWORKS:
Each processing node has its own small sphere of knowledge, including what it has
seen and any rules it was originally programmed with or developed for itself. The
tiers are highly interconnected, which means each node in tier n will be connected to
many nodes in tier n-1 -- its inputs -- and in tier n+1, which provides input data for
those nodes. There may be one or multiple nodes in the output layer, from which the
answer it produces can be read.
Artificial neural networks are notable for being adaptive, which means they modify
themselves as they learn from initial training and subsequent runs provide more
information about the world. The most basic learning model is centered on weighting
the input streams, which is how each node weights the importance of input data from
each of its predecessors. Inputs that contribute to getting right answers are weighted
higher.
Input Layer
Information from the outside world enters the artificial neural network from the input
layer. Input nodes process the data, analyze or categorize it, and pass it on to the next
layer.
Hidden Layer
Hidden layers take their input from the input layer or other hidden layers. Artificial
neural networks can have a large number of hidden layers. Each hidden layer
analyzes the output from the previous layer, processes it further, and passes it on to
the next layer.
Output Layer
The output layer gives the final result of all the data processing by the artificial
neural network. It can have single or multiple nodes. For instance, if we have a
binary (yes/no) classification problem, the output layer will have one output node,
which will give the result as 1 or 0. However, if we have a multi-class classification
problem, the output layer might consist of more than one output node.
Deep neural networks, or deep learning networks, have several hidden layers with
millions of artificial neurons linked together. A number, called weight, represents the
connections between one node and another. The weight is a positive number if one
node excites another, or negative if one node suppresses the other. Nodes with higher
weight values have more influence on the other nodes.
Theoretically, deep neural networks can map any input type to any output type.
However, they also need much more training as compared to other machine learning
methods. They need millions of examples of training data rather than perhaps the
hundreds or thousands that a simpler network might need.
Artificial neural networks can be categorized by how the data flows from the input
node to the output node. Below are some examples:
Feedforward neural networks process data in one direction, from the input node to
the output node. Every node in one layer is connected to every node in the next layer.
A feedforward network uses a feedback process to improve predictions over time.
Backpropagation algorithm
1. Each node makes a guess about the next node in the path.
2. It checks if the guess was correct. Nodes assign higher weight values to paths
that lead to more correct guesses and lower weight values to node paths that
lead to incorrect guesses.
3. For the next data point, the nodes make a new prediction using the higher
weight paths and then repeat Step 1.
● Parallel processing abilities mean the network can perform more than one
job at a time.
● Fault tolerance means the corruption of one or more cells of the ANN will
not stop the generation of output.
● Gradual corruption means the network will slowly degrade over time,
instead of a problem destroying the network instantly.
● The ability to produce output with incomplete knowledge with the loss of
performance being based on how important the missing information is.
● No restrictions are placed on the input variables, such as how they should
be distributed.
● Machine learning means the ANN can learn from events and make
decisions based on the observations.
● The lack of rules for determining the proper network structure means the
appropriate artificial neural network architecture can only be found through
trial and error and experience.
Image recognition was one of the first areas to which neural networks were
successfully applied, but the technology uses have expanded to many more areas,
including:
● Chatbots
These are just a few specific areas to which neural networks are being applied today.
Prime uses involve any process that operates according to strict rules or patterns and
has large amounts of data. If the data involved is too large for a human to make sense
of in a reasonable amount of time, the process is likely a prime candidate for
automation through artificial neural networks.
ACTIVE LEARNING:
Active learning is the name used for the process of prioritising the data which needs
Active learning can be used in situations where the amount of data is too large to be
labelled and some priority needs to be made to label the data in a smart way.
But, why don’t we just choose a random subset of data to manually label them?
Let’s look at a very simple example to motivate the discussion. Assume we have
millions of data points which need to be classified based on two features. The actual
As one can see, both classes (red and purple) can quite nicely be separated by a
vertical blue line crossing at 0. The problem is that none of the data points are
Unfortunately, we don’t have enough time to label all of the data and we randomly
chose a subset of the data to label and train a binary classification model on it. The
result is not great, as the model prediction deviates quite a lot from the optimal
boundary.
This is where active learning can be used to optimise the data points chosen for
labelling and training a model based on them. The following plot shows an example
of training a binary classification model after choosing the training of the model
Making a smart choice of which data points to prioritise when labelling can save data
There are multiple approaches studied in the literature on how to prioritise data
points when labelling and how to iterate over the approach. We will nevertheless only
trained on it. The model is of course not going to be great but will help us
get some insight on which areas of the parameter space need to be labelled
3. After the model is trained, the model is used to predict the class of each
the model. In the next subsection we will present some of the possible
5. Once the best approach has been chosen to prioritise the labelling, this
labelled data set, which has been labelled based on the priority score. Once
the new model has been trained on the subset of data, the unlabelled data
points can be ran through the model to update the prioritisation scores to
continue labelling. In this way, one can keep optimising the labelling
Prioritisation scores
There are several approaches to assign a priority score to each data point. Below we
This is probably the most simple method. It takes the highest probability for each
data point’s prediction, and sorts them from smaller to larger. The actual expression
Let’s use an example to see how this would work. Assume we have the following
point, hence:
● X1: 0.9
● X2: 0.87
● X3:0.5
● X4:0.99.
The second step is to sort the data based on this maximum probability (from smaller
Margin sampling:
This method takes into account the difference between the highest probability and the
second highest probability. Formally, the expression to prioritise would look like:
The data points with the lower margin sampling score would be the ones labelled the
first; these are the data points the model is least certain about between the most
Following the example of Table 1, the corresponding scores for each data point are:
Hence the data points would be shown to label as follows: X3, X1, X2 and X4. As
one can see the priority in this case is slightly different to the least confident one.
Entropy:
Finally, the last scoring function that we are gonna present here is the entropy score.
The higher the entropy the more disorder there is, whereas if the entropy is low, it
means that the gas might be mainly in one particular area such as a corner of the box
(maybe when the experiment started, before expanding across the box).
This concept can be reused to measure the certainty of a model. If a model is highly
certain about a class for a given data point, it will probably have a high certainty for a
particular class, whereas all the other classes will have low probability. Isn’t this very
similar to having a gas in the corner of a box? In this case we have most of the
probability assigned to a particular class. In the case of high entropy it would mean
that the model distributes equally the probability for all classes as it is not certain at
all which class that data point belongs to, similarly to having the gas distributed
equally in all parts of the box. It is therefore straightforward to prioritise data points
Note that for X4, 0 should be changed for a small epsilon (e.g. 0.00001) for
numerical stability.
In this case the data points should be shown in the following order: X3, X2, X1 and
X4, which coincides with the order of the least confident scoring method.
ENSEMBLE LEARNING:
● Majority Vote
● Bagging and Random Forest
● Randomness Injection
● Feature-Selection Ensembles
● Error-Correcting Output Coding
● Boosting
● Stacking
BOOTSTRAP AGGREGATION:
Bagging, also known as bootstrap aggregation, is the ensemble learning method that
is commonly used to reduce variance within a noisy dataset. In bagging, a random
sample of data in a training set is selected with replacement—meaning that the
individual data points can be chosen more than once. After several data samples are
generated, these weak models are then trained independently, and depending on the
type of task—regression or classification, for example—the average or majority of
those predictions yield a more accurate estimate.
Ensemble learning
Ensemble learning gives credence to the idea of the “wisdom of crowds,” which
suggests that the decision-making of a larger group of people is typically better than
that of an individual expert. Similarly, ensemble learning refers to a group (or
ensemble) of base learners, or models, which work collectively to achieve a better
final prediction. A single model, also known as a base or weak learner, may not
perform well individually due to high variance or high bias. However, when weak
learners are aggregated, they can form a strong learner, as their combination reduces
bias or variance, yielding better model performance.
Ensemble methods are frequently illustrated using decision trees as this algorithm
can be prone to overfitting (high variance and low bias) when it hasn’t been pruned
and it can also lend itself to underfitting (low variance and high bias) when it’s very
small, like a decision stump, which is a decision tree with one level. Remember,
when an algorithm overfits or underfits to its training set, it cannot generalize well to
new datasets, so ensemble methods are used to counteract this behavior to allow for
generalization of the model to new datasets. While decision trees can exhibit high
variance or high bias, it’s worth noting that it is not the only modeling technique that
leverages ensemble learning to find the “sweet spot” within the bias-variance
tradeoff.
Bagging and boosting are two main types of ensemble learning methods. The main
difference between these learning methods is the way in which they are trained. In
bagging, weak learners are trained in parallel, but in boosting, they learn sequentially.
This means that a series of models are constructed and with each new model
iteration, the weights of the misclassified data in the previous model are increased.
This redistribution of weights helps the algorithm identify the parameters that it
needs to focus on to improve its performance. AdaBoost, which stands for “adaptive
boosting algorithm,” is one of the most popular boosting algorithms as it was one of
the first of its kind. Other types of boosting algorithms include XGBoost,
GradientBoost, and BrownBoost.
Another difference in which bagging and boosting differ are the scenarios in which
they are used. For example, bagging methods are typically used on weak learners
which exhibit high variance and low bias, whereas boosting methods are leveraged
when low variance and high bias is observed.
How bagging works
In 1996, Leo Breiman introduced the bagging algorithm, which has three basic steps:
There are a number of key advantages and challenges that the bagging method
presents when used for classification or regression problems. The key benefits of
bagging include:
Loss of interpretability: It’s difficult to draw very precise business insights through
bagging because of the averaging involved across predictions. While the output is
more precise than any individual data point, a more accurate or complete dataset
could also yield more precision within a single classification or regression model.
Computationally expensive: Bagging slows down and grows more intensive as the
number of iterations increases. Thus, it’s not well-suited for real-time applications.
Clustered systems or a large number of processing cores are ideal for quickly
creating bagged ensembles on large test sets.
Less flexible: As a technique, bagging works particularly well with algorithms that
are less stable. One that is more stable or subject to high amounts of bias do not
provide as much benefit as there’s less variation within the dataset of the model.
Applications of Bagging
The bagging technique is used across a large number of industries, providing insights
for both real-world value and interesting perspectives, such as in the GRAMMY
Debates with Watson. Key use cases include:
● Healthcare: Bagging has been used to form medical data predictions. For
example, ensemble methods have been used for an array of bioinformatics problems,
such as gene and/or protein selection to identify a specific trait of interest.
● IT: Bagging can also improve the precision and accuracy in IT systems, such
as ones network intrusion detection systems.
● Environment: Ensemble methods, such as bagging, have been applied within
the field of remote sensing.
● Finance: Bagging has also been leveraged with deep learning models in the
finance industry, automating critical tasks, including fraud detection, credit risk
evaluations, and option pricing problems.
BOOSTING:
Weak learners
Weak learners have low prediction accuracy, similar to random guessing. They are
prone to overfitting—that is, they can't classify data that varies too much from their
original dataset. For example, if you train the model to identify cats as animals with
pointed ears, it might fail to recognize a cat whose ears are curled.
Strong learners
Strong learners have higher prediction accuracy. Boosting converts a system of weak
learners into a single strong learning system. For example, to identify the cat image,
it combines a weak learner that guesses for pointy ears and another learner that
guesses for cat-shaped eyes. After analyzing the animal image for pointy ears, the
system analyzes it once again for cat-shaped eyes. This improves the system's overall
accuracy.
To understand how boosting works, let's describe how machine learning models
make decisions. Although there are many variations in implementation, data
scientists often use boosting with decision-tree algorithms:
Decision trees
Decision trees are data structures in machine learning that work by dividing the
dataset into smaller and smaller subsets based on their features. The idea is that
decision trees split up the data repeatedly until there is only one class left. For
example, the tree may ask a series of yes or no questions and divide the data into
categories at every step.
Boosting and bagging are the two common ensemble methods that improve
prediction accuracy. The main difference between these learning methods is the
method of training. In bagging, data scientists improve the accuracy of weak learners
by training several of them at once on multiple datasets. In contrast, boosting trains
weak learners one after another.
The training method varies depending on the type of boosting process called the
boosting algorithm. However, an algorithm takes the following general steps to train
the boosting model:
Step 1
The boosting algorithm assigns equal weight to each data sample. It feeds the data to
the first machine model, called the base algorithm. The base algorithm makes
predictions for each data sample.
Step 2
The boosting algorithm assesses model predictions and increases the weight of
samples with a more significant error. It also assigns a weight based on model
performance. A model that outputs excellent predictions will have a high amount of
influence over the final decision.
Step 3
The algorithm passes the weighted data to the next decision tree.
Step 4
The algorithm repeats steps 2 and 3 until instances of training errors are below a
certain threshold.
Adaptive boosting
Adaptive Boosting (AdaBoost) was one of the earliest boosting models developed. It
adapts and tries to self-correct in every iteration of the boosting process.
AdaBoost initially gives the same weight to each dataset. Then, it automatically
adjusts the weights of the data points after every decision tree. It gives more weight
to incorrectly classified items to correct them for the next round. It repeats the
process until the residual error, or the difference between actual and predicted values,
falls below an acceptable threshold.
You can use AdaBoost with many predictors, and it is typically not as sensitive as
other boosting algorithms. This approach does not work well when there is a
correlation among features or high data dimensionality. Overall, AdaBoost is a
suitable type of boosting for classification problems.
Gradient boosting
Gradient Boosting (GB) is similar to AdaBoost in that it, too, is a sequential training
technique. The difference between AdaBoost and GB is that GB does not give
incorrectly classified items more weight. Instead, GB software optimizes the loss
function by generating base learners sequentially so that the present base learner is
always more effective than the previous one. This method attempts to generate
accurate results initially instead of correcting errors throughout the process, like
AdaBoost. For this reason, GB software can lead to more accurate results. Gradient
Boosting can help with both classification and regression-based problems.
Ease of implementation
Reduction of bias
Boosting models are vulnerable to outliers or data values that are different from the
rest of the dataset. Because each model attempts to correct the faults of its
predecessor, outliers can skew results significantly.
Real-time implementation
You might also find it challenging to use boosting for real-time implementation
because the algorithm is more complex than other processes. Boosting methods have
high adaptability, so you can use a wide variety of model parameters that
immediately affect the model's performance.
The ensemble consists of N trees. Tree1 is trained using the feature matrix X and the
labels y. The predictions labelled y1(hat) are used to determine the training set
residual errors r1. Tree2 is then trained using the feature matrix X and the residual
errors of Tree1 as labels. The predicted results r1(hat) are then used to determine the
residual r2. The process is repeated until all the N trees forming the ensemble are
trained.
Deep Learning
Deep learning is a subset of machine learning, which is essentially a neural network
with three or more layers. These neural networks attempt to simulate the behavior of
the human brain—albeit far from matching its ability—allowing it to “learn” from
large amounts of data.
Architectures :
1. Deep Neural Network – It is a neural network with a certain level of
complexity (having multiple hidden layers in between input and output
layers). They are capable of modeling and processing non-linear
relationships.
2. Deep Belief Network(DBN) – It is a class of Deep Neural Network. It is a
multi-layer belief network. Steps for performing DBN : a. Learn a layer of
features from visible units using the Contrastive Divergence algorithm. b.
Treat activations of previously trained features as visible units and then
learn features of features. c. Finally, the whole DBN is trained when the
learning for the final hidden layer is achieved.
3. Recurrent (perform same task for every element of a sequence) Neural
Network – Allows for parallel and sequential computation. Similar to the
human brain (large feedback network of connected neurons). They are able
to remember important things about the input they received and hence
enables them to be more precise.