Professional Documents
Culture Documents
Lecture 5
Unsupervised Learning
• Unsupervised Learning is a machine learning technique in which the
users do not need to supervise the model. Instead, it allows the
model to work on its own to discover patterns and information that
was previously undetected. It mainly deals with the unlabelled data.
• Unsupervised Learning Algorithms allow users to perform more
complex processing tasks compared to supervised learning. Although,
unsupervised learning can be more unpredictable compared with
other natural learning methods.
• Unsupervised learning algorithms include clustering, anomaly
detection, neural networks, etc.
Example of Unsupervised Machine Learning
• Let's, take the case of a baby and her family dog.
Baby has not seen this dog earlier. But it recognizes many features (2 ears, eyes, walking on 4 legs) are
like her pet dog. She identifies the new animal as a dog. This is unsupervised learning, where you are not
taught but you learn from the data (in this case data about a dog.
Why Unsupervised Learning?
• Unsupervised machine learning finds all kind of unknown patterns in
data.
• Unsupervised methods help you to find features which can be useful
for categorization.
• It is taken place in real time, so all the input data to be analyzed and
labeled in the presence of learners.
• It is easier to get unlabeled data from a computer than labeled data,
which needs manual intervention.
Types of Unsupervised Learning
Clustering
Association
Clustering
• Clustering is an important concept when it comes to unsupervised
learning. It mainly deals with finding a structure or pattern in a
collection of uncategorized data.
• Clustering algorithms will process data and find natural
clusters(groups) if they exist in the data. It is also possible modify how
many clusters your algorithms should identify.
Clustering Example…
Different types of clustering
Exclusive (partitioning)
• In this clustering method, Data are grouped in such a way that one
data can belong to one cluster only.
• Example: K-means
Agglomerative
• In this clustering technique, every data is a cluster.
• Example: Hierarchical clustering
Different types of clustering
Overlapping
• In this technique, fuzzy sets is used to cluster data. Each point may
belong to two or more clusters with separate degrees of membership.
• Here, data will be associated with an appropriate membership value.
Example: Fuzzy C-Means
Different types of clustering
Probabilistic
This technique uses probability distribution to create the clusters
• Example: Following keywords
• "man's shoe."
• "women's shoe."
• "women's glove."
• "man's glove."
can be clustered into two categories "shoe" and "glove" or "man" and
"women."
Different types of clustering
Hierarchical Clustering:
• Hierarchical clustering is an algorithm which builds a hierarchy of clusters.
It begins with all the data which is assigned to a cluster of their own.
• Here, two close cluster are going to be in the same cluster. This algorithm
ends when there is only one cluster left.
Agglomerative clustering:
• This type of K-means clustering starts with a fixed number of clusters. It
allocates all data into the exact number of clusters.
• This clustering method does not require the number of clusters K as an
input. Agglomeration process starts by forming each data as a single
cluster.
Different types of clustering
K-means Clustering
• K means it is an iterative clustering algorithm which helps you to find
the highest value for every iteration. Initially, the desired number of
clusters are selected. In this clustering method, you need to cluster
the data points into k groups.
• The output of the algorithm is a group of "labels." It assigns data
point to one of the k groups. K-mean clustering further defines two
subgroups:
• Agglomerative clustering
• Dendrogram
Association
Association
• Association rules allow you to establish associations amongst data objects inside
large databases.
• This unsupervised technique is about discovering interesting relationships
between variables in large databases.
• For example, people that buy a new home most likely to buy new furniture.
Other Examples:
• A subgroup of cancer patients grouped by their gene expression measurements
• Groups of shopper based on their browsing and purchasing histories
• Movie group by the rating given by movies viewers
Applications of unsupervised learning
• Clustering automatically split the dataset into groups base on their
similarities
• Anomaly detection can discover unusual data points in your dataset.
It is useful for finding fraudulent transactions
• Association mining identifies sets of items which often occur together
in your dataset
Disadvantages of Unsupervised Learning
• You cannot get precise information regarding data sorting, and the output
as data used in unsupervised learning is labeled and not known
• Less accuracy of the results is because the input data is not known and not
labeled by people in advance. This means that the machine requires to do
this itself.
• The spectral classes do not always correspond to informational classes.
• The user needs to spend time interpreting and label the classes which
follow that classification.
• Spectral properties of classes can also change over time so you can't have
the same class information while moving from one image to another.
Summary
• Unsupervised learning is a machine learning technique, where you do
not need to supervise the model.
• Unsupervised machine learning helps you to finds all kind of unknown
patterns in data.
• Clustering and Association are two types of Unsupervised learning.
• Four types of clustering methods are 1) Exclusive 2) Agglomerative 3)
Overlapping 4) Probabilistic.
• Important clustering types are: 1)Hierarchical clustering 2) K-means
clustering 3) K-NN 4) Principal Component Analysis 5) Singular Value
Decomposition 6) Independent Component Analysis.
Summary (contd.)
• Association rules allow you to establish associations amongst data
objects inside large databases.
• In Supervised learning, Algorithms are trained using labelled data
while in Unsupervised learning Algorithms are used against data
which is not labelled.
• Anomaly detection can discover important data points in your dataset
which is useful for finding fraudulent transactions.
• The biggest drawback of Unsupervised learning is that you cannot get
precise information regarding data sorting.
Supervised vs Unsupervised
• Supervised learning as the name indicates the presence of a
supervisor as a teacher.
• Basically supervised learning is a learning in which we teach or train
the machine using data which is well labeled that means some data is
already tagged with the correct answer.
• After that, the machine is provided with a new set of examples(data)
so that supervised learning algorithm analyses the training data(set of
training examples) and produces a correct outcome from labeled
data.
Supervised (Example)
• For instance, suppose you are given a basket filled with different
kinds of fruits. Now the first step is to train the machine with all
different fruits one by one like this
Supervised (Example)
• If shape of object is rounded and depression at top having
color Red then it will be labelled as –Apple.
• If shape of object is long curving cylinder having color Green-
Yellow then it will be labelled as –Banana.
Now suppose after training the data, you have given a new separate
fruit say Banana from basket and asked to identify it.
Supervised (Example)
• Since the machine has already learned the things from previous data
and this time have to use it wisely. It will first classify the fruit with its
shape and color and would confirm the fruit name as BANANA and
put it in Banana category.
• Thus the machine learns the things from training data(basket
containing fruits) and then apply the knowledge to test data(new
fruit).
Unsupervised Learning
• Unsupervised learning is the training of machine using information
that is neither classified nor labeled and allowing the algorithm to act
on that information without guidance. Here the task of machine is to
group unsorted information according to similarities, patterns and
differences without any prior training of data.
• Unlike supervised learning, no teacher is provided that means no
training will be given to the machine. Therefore machine is restricted
to find the hidden structure in unlabeled data by our-self.
Unsupervised Learning (example)
• For instance, suppose it is given an image having both dogs and cats
which have not seen ever.
Thus the machine has no idea about the features of dogs and cat so we can’t categorize it in dogs
and cats. But it can categorize them according to their similarities, patterns, and differences i.e., we
can easily categorize the above picture into two parts. First first may contain all pics having dogs in it
and second part may contain all pics having cats in it. Here you didn’t learn anything before, means
no training data or examples.
Reinforcement Learning
Lecture 6
Reinforcement Learning
Reinforcement learning is an area of Machine Learning. It is about
taking suitable action to maximize reward in a particular situation. It
is employed by various software and machines to find the best
possible behavior or path it should take in a specific situation.
Reinforcement learning differs from the supervised learning in a way
that in supervised learning the training data has the answer key with
it so the model is trained with the correct answer itself whereas in
reinforcement learning, there is no answer but the reinforcement
agent decides what to do to perform the given task.
In the absence of a training dataset, it is bound to learn from its
experience.
Differ from Supervised Learning
• Reinforcement learning differs from supervised learning in not
needing labelled input/output pairs be presented, and in not needing
sub-optimal actions to be explicitly corrected.
Part of Deep Learning…
• Reinforcement Learning is also part of the deep learning method that
helps you to maximize some portion of the cumulative reward.
• This method helps you to learn how to attain a complex objective or
maximize a specific dimension over many steps.
Agent…
Here are some important terms used in
Reinforcement
• Agent: It is an assumed entity which performs actions in an
environment to gain some reward.
• Environment (e): A scenario that an agent has to face.
• Reward (R): An immediate return given to an agent when he or she
performs specific action or task.
• State (s): State refers to the current situation returned by the
environment.
• Policy (π): It is a strategy which applies by the agent to decide the
next action based on the current state.
Example
• The problem is as follows: We have an agent and a reward, with many
hurdles in between. The agent is supposed to find the best possible
path to reach the reward. The following problem explains the
problem more easily.
Example…
• The above image shows the robot, diamond, and fire. The goal of the robot is to
get the reward that is the diamond and avoid the hurdles that are fire.
• The robot learns by trying all the possible paths and then choosing the path
which gives him the reward with the least hurdles.
• Each right step will give the robot a reward and each wrong step will subtract the
reward of the robot.
• The total reward will be calculated when it reaches the final reward that is the
diamond.
How Reinforcement Learning works?
• Consider the scenario of teaching new tricks to your cat
• As cat doesn't understand English or any other human language, we can't
tell her directly what to do. Instead, we follow a different strategy.
• We emulate a situation, and the cat tries to respond in many different
ways. If the cat's response is the desired way, we will give her fish.
• Now whenever the cat is exposed to the same situation, the cat executes a
similar action with even more enthusiastically in expectation of getting
more reward(food).
• That's like learning that cat gets from "what to do" from positive
experiences.
• At the same time, the cat also learns what not do when faced with negative
experiences.
How Reinforcement Learning works
In this case….
• Your cat is an agent that is exposed to the environment. In this case, it
is your house. An example of a state could be your cat sitting, and you
use a specific word in for cat to walk.
• Our agent reacts by performing an action transition from one "state"
to another "state."
• For example, your cat goes from sitting to walking.
• The reaction of an agent is an action, and the policy is a method of
selecting an action given a state in expectation of better outcomes.
• After the transition, they may get a reward or penalty in return.
Main points in Reinforcement learning
• Input: The input should be an initial state from which the model will
start
• Output: There are many possible output as there are variety of
solution to a particular problem
• Training: The training is based upon the input, The model will return a
state and the user will decide to reward or punish the model based
on its output.
• The model keeps continues to learn.
• The best solution is decided based on the maximum reward.
Types of Reinforcement
Positive –
Positive Reinforcement is defined as when an event, occurs due to a
particular behavior, increases the strength and the frequency of the
behavior. In other words, it has a positive effect on behavior.
Advantages of reinforcement learning are:
• Maximizes Performance
• Sustain Change for a long period of time
Disadvantages of reinforcement learning:
• Too much Reinforcement can lead to overload of states which can
diminish the results
Types of Reinforcement
Negative –
Negative Reinforcement is defined as strengthening of a behavior
because a negative condition is stopped or avoided.
Advantages of reinforcement learning
• Increases Behavior
• Provide defiance to minimum standard of performance
Disadvantages of reinforcement learning
• It Only provides enough to meet up the minimum behavior
Various Practical applications of
Reinforcement Learning
• The program takes some input values and pushes them into two fully connected
layers.
• Imagine you have a math problem, the first thing you do is to read the
corresponding chapter to solve the problem. You apply your new knowledge to
solve the problem. There is a high chance you will not score very well.
• It is the same for a network. The first time it sees the data and makes a
prediction, it will not match perfectly with the actual data.
• To improve its knowledge, the network uses an optimizer. In our analogy, an
optimizer can be thought of as rereading the chapter. You gain new
insights/lesson by reading again.
• Similarly, the network uses the optimizer, updates its knowledge, and tests its
new knowledge to check how much it still needs to learn. The program will repeat
this step until it makes the lowest error possible.
ANN is composed of four principal objects
⮚Layers: all the learning occurs in the layers
⮚feature and label :Input data to the network(features) and output
from the network (labels)
⮚loss function: Metric used to estimate the performance of the
learning phase
⮚Optimizer : Improve the learning by updating the knowledge in the
network
Layers
❑A layer is where all the learning takes place. Inside a layer, there are
an infinite amount of weights (neurons). A typical neural network is
often processed by densely connected layers (also called fully
connected layers). It means all the inputs are connected to the
output.
The network takes an input, sends it to all connected nodes and computes the signal with
an activation function. The activation function of a node defines the output given a set of inputs
Layers
❑ The first layer is the input values for the second layer, called the hidden
layer, receives the weighted input from the previous layer.
❑Neural network with lots of layers and hidden units can learn a
complex representation of the data, but it makes the network's
computation very expensive
Loss function
• After you have defined the hidden layers and the activation function,
you need to specify the loss function and the optimizer.
• For binary classification, it is common practice to use a binary cross
entropy loss function. In the linear regression, you use the mean
square error.
• The loss function is an important metric to estimate the performance
of the optimizer. During the training, this metric will be minimized.
You need to select this quantity carefully depending on the type of
problem you are dealing with.
Optimizer
• The loss function is a measure of the model's performance. The optimizer
will help improve the weights of the network in order to decrease the loss.
• There are different optimizers available, but the most common one is the
Stochastic Gradient Descent.
• A neural network with too many layers and hidden units are known to
be highly sophisticated. A straightforward way to reduce the
complexity of the model is to reduce its size.
• There is no best practice to define the number of layers. You need to
start with a small amount of layer and increases its size until you find
the model overfit.
Limitations of Neural Network
Dropout
• Dropout is an odd but useful technique. A network with dropout
means that some weights will be randomly set to zero.
• Imagine you have an array of weights [0.1, 1.7, 0.7, -0.9]. If the neural
network has a dropout, it will become [0.1, 0, 0, -0.9] with randomly
distributed 0.
• The parameter that controls the dropout is the dropout rate. The rate
defines how many weights to be set to zeroes.
Neural Network with Deep
Learning
Lecture 8
What is Deep Learning?
❑Deep learning is a computer software that mimics the network of
neurons in a brain.
❑It is a subset of machine learning and is called deep learning because
it makes use of deep neural networks.