Unit 2 Soft
Unit 2 Soft
• Supervised learning is the types of machine learning in which machines are • In supervised learning, models are trained using labelled dataset, where the model learns
trained using well "labelled" training data, and on basis of that data, machines about each type of data. Once the training process is completed, the model is tested on the
predict the output. The labelled data means some input data is already tagged basis of test data (a subset of the training set), and then it predicts the output.
with the correct output. • The working of Supervised learning can be easily understood by the below example and
• In supervised learning, the training data provided to the machines work as the diagram:
supervisor that teaches the machines to predict the output correctly. It applies
the same concept as a student learns in the supervision of the teacher.
• Supervised learning is a process of providing input data as well as correct
output data to the machine learning model. The aim of a supervised learning
algorithm is to find a mapping function to map the input variable(x) with the
output variable(y).
• In the real-world, supervised learning can be used for Risk Assessment,
Image classification, Fraud Detection, spam filtering, etc.
•If the given shape has four sides, and all the sides are equal, then it will be
labelled as a Square.
•If the given shape has three sides, then it will be labelled as a triangle.
•If the given shape has six equal sides then it will be labelled as hexagon.
Now, after training, we test our model using the test set, and the task of the model
is to identify the shape.
The machine is already trained on all types of shapes, and when it finds a new
shape, it classifies the shape on the bases of a number of sides, and predicts the
output.
For instance, suppose you are given a basket filled with different kinds of fruits. Now Types of supervised Machine learning Algorithms:
the first step is to train the machine with all the different fruits one by one like this:
Supervised learning can be further divided into two types of problems:
•If the shape of the object is rounded and has a depression at the top, is red in color,
then it will be labeled as –Apple.
•If the shape of the object is a long curving cylinder having Green-Yellow color, then
it will be labeled as –Banana.
Now suppose after training the data, you have given a new separate fruit, say Banana
from the basket, and asked to identify it.
Since the machine has already learned the things from previous data and this time
has 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 the Banana category. Thus the
machine learns the things from training data(basket containing fruits) and then
applies the knowledge to test data(new fruit).
1.it is the gradient descent method as used in the case of simple perceptron network
with the differentiable unit.
1.it is different from other networks in respect to the process by which the weights are
calculated during the learning period of the network.
2.training is done in the three stages :
Neural networks use supervised learning to generate output vectors from input
vectors that the network operates on. It Compares generated output to the desired
output and generates an error report if the result does not match the generated
output vector. Then it adjusts the weights according to the bug report to get your Parameters :
desired output. •x = inputs training vector x=(x1,x2,…………xn).
•t = target vector t=(t1,t2……………tn).
•δk = error at output unit.
Backpropagation Algorithm: •δj = error at hidden layer.
Step 1: Inputs X, arrive through the preconnected path. •α = learning rate.
Step 2: The input is modeled using true weights W. Weights are usually chosen •V0j = bias of hidden unit j.
randomly.
Step 3: Calculate the output of each neuron from the input layer to the hidden
layer to the output layer.
Step 4: Calculate the error in the outputs
Backpropagation Error= Actual Output – Desired Output
Step 5: From the output layer, go back to the hidden layer to adjust the weights to
reduce the error.
Step 6: Repeat the process until the desired output is achieved.
Training Algorithm :
Step 1: Initialize weight to small random values. Backpropagation Error :
Step 2: While the stopping condition is to be false do step 3 to 10. Step 6: Each output unit yk (k=1 to n) receives a target pattern
Step 3: For each training pair do step 4 to 9 (Feed-Forward). corresponding to an input pattern then error is calculated as:
Step 4: Each input unit receives the signal unit and transmits the signal xi signal to all δk = ( tk – yk ) + yink
the units. Step 7: Each hidden unit Zj (j=1 to a) sums its input from all units in the
Step 5 : Each hidden unit Zj (z=1 to a) sums its weighted input signal to calculate its layer above
net input δinj = Σ δj wjk
zinj = v0j + Σxivij ( i=1 to n) The error information term is calculated as :
Applying activation function zj = f(zinj) and sends this signals to all units in the layer δj = δinj + zinj
about i.e output units
For each output l=unit yk = (k=1 to m) sums its weighted input signals.
Updation of weight and bias :
yink = w0k + Σ ziwjk (j=1 to a)
yk = f(yink)
Step 8: Each output unit yk (k=1 to m) updates its bias and weight (j=1 to Input values
a). The weight correction term is given by : X1=0.05
Δ wjk = α δk zj X2=0.10
and the bias correction term is given by Δwk = α δk. Initial weight
therefore wjk(new) = wjk(old) + Δ wjk W1=0.15 w5=0.40
w0k(new) = wok(old) + Δ wok W2=0.20 w6=0.45
for each hidden unit zj (j=1 to a) update its bias and weights (i=0 W3=0.25 w7=0.50
to n) the weight connection term W4=0.30 w
Δ vij = α δj xi 8=0.55
and the bias connection on term Bias Values
Δ v0j = α δj b1=0.35 b2=0.60
Therefore vij(new) = vij(old) + Δvij Target Values
v0j(new) = v0j(old) + Δv0j T1=0.01
T2=0.99
Step 9: Test the stopping condition. The stopping condition can be the
minimization of error, number of epochs.
Unsupervised Learning
Advantages:
As the name suggests, unsupervised learning is a machine learning technique in which
models are not supervised using training dataset. Instead, models itself find the hidden
•It is simple, fast, and easy to program.
patterns and insights from the given data. It can be compared to learning which takes place
•Only numbers of the input are tuned, not any other parameter.
in the human brain while learning new things.
•It is Flexible and efficient.
•No need for users to learn any special functions.
The goal of unsupervised learning is to find the underlying structure of dataset, group
Disadvantages:
that data according to similarities, and represent that dataset in a compressed format.
•It is sensitive to noisy data and irregularities. Noisy data can lead to inaccurate results.
Example: Suppose the unsupervised learning algorithm is given an input dataset containing
•Performance is highly dependent on input data.
images of different types of cats and dogs. The algorithm is never trained upon the given
•Spending too much time training.
dataset, which means it does not have any idea about the features of the dataset. The task
•The matrix-based approach is preferred over a mini-batch.
of the unsupervised learning algorithm is to identify the image features on their own.
Unsupervised learning algorithm will perform this task by clustering the image dataset into
the groups according to similarities between images.
•Unsupervised learning is helpful for finding useful insights from the data. Here, we have taken an unlabeled input data, which means it is not categorized and
corresponding outputs are also not given. Now, this unlabeled input data is fed to the
•Unsupervised learning is much similar as a human learns to think by their own machine learning model in order to train it. Firstly, it will interpret the raw data to find the
experiences, which makes it closer to the real AI. hidden patterns from the data and then will apply suitable algorithms such as k-means
clustering, Decision tree, etc.
•Unsupervised learning works on unlabeled and uncategorized data which make
unsupervised learning more important. Once it applies the suitable algorithm, the algorithm divides the data objects into
groups according to the similarities and difference between the objects.
•In real-world, we do not always have input data with the corresponding output so to solve
such cases, we need unsupervised learning.
Types of Unsupervised Learning Algorithm:
Advantages of Unsupervised learning
•No labeled data required: Unlike supervised learning, unsupervised learning does not
require labeled data, which can be expensive and time-consuming to collect.
•Can uncover hidden patterns: Unsupervised learning algorithms can identify patterns
and relationships in data that may not be obvious to humans.
•Can be used for a variety of tasks: Unsupervised learning can be used for a variety of
•Clustering: Clustering is a method of grouping the objects into clusters such that
tasks, such as clustering, dimensionality reduction, and anomaly detection.
objects with most similarities remains into a group and has less or no similarities
with the objects of another group. Cluster analysis finds the commonalities
•Can be used to explore new data: Unsupervised learning can be used to explore new
between the data objects and categorizes them as per the presence and absence
data and gain insights that may not be possible with other methods.
of those commonalities.
• To illustrate how one can use competitive learning, imagine an eCommerce business
wants to segment its customer base for targeted marketing, but they have no prior
labels or segmentation. By feeding customer data (purchase history, browsing
pattern, demographics, etc.) to a competitive learning model, they could
automatically find distinct clusters (like high spenders, frequent buyers, discount
lovers) and tailor marketing strategies accordingly.
For this simple illustration, let's assume we have a dataset composed of 1-dimensional input
vectors ranging from 1 to 10 and a competitive learning network with two neurons.
Step 1: Initialization
We start by initializing the weights of the two neurons to random values. Let's assume:
•Neuron 1 weight: 2
•Neuron 2 weight: 8
It follows an unsupervised learning approach and trained its network through a competitive
learning algorithm. SOM is used for clustering and mapping (or dimensionality reduction)
techniques to map multidimensional data onto lower-dimensional which allows people to
reduce complex problems for easy interpretation.
SOM has two layers, one is the Input layer and the other one is the Output layer.
Trying SOM algorithm for a particular data
Bidirectional associative memory (BAM), first proposed by Bart Kosko in the year 1988.
The BAM network performs forward and backward associative searches for stored
stimulus responses. The BAM is a recurrent hetero associative pattern-marching
nerwork that encodes binary or bipolar patterns using Hebbian learning rule. It
associates patterns, say from set A to patterns from set B and vice versa is also
performed. BAM neural nets can respond to input from either layers (input layer and
output layer).
Bidirectional Associative Memory Architecture
The architecture of BAM network consists of two layers of neurons which are connected
by directed weighted pare interconnecrions. The network dynamics involve two layers of
interaction. The BAM network iterates by sending the signals back and forth between the
two layers until all the neurons reach equilibrium. The weights associated with the Figure shows a BAM network consisting of n units in X layer and m units in Y layer. The layers can
network are bidirectional. Thus, BAM can respond to the inputs in either layer. be connected in both directions(bidirectional) with the result the weight matrix sent from the X layer
to the Y layer is W and the weight matrix for signals sent from the Y layer to the X layer is WT. Thus,
the Weight matrix is calculated in both directions.
3. Healthcare:
Applications of Artificial Neural Networks
• Artificial Neural Networks are used in Oncology to train algorithms that can identify cancerous
1.Social Media: tissue at the microscopic level at the same accuracy as trained physicians. Various rare diseases
• Artificial Neural Networks are used heavily in Social Media. For example, let’s take the ‘People may manifest in physical characteristics and can be identified in their premature stages by
you may know’ feature on Facebook that suggests people that you might know in real life so using Facial Analysis on the patient photos.
that you can send them friend requests. Well, this magical effect is achieved by using Artificial • So the full-scale implementation of Artificial Neural Networks in the healthcare environment
Neural Networks that analyze your profile, your interests, your current friends, and also their can only enhance the diagnostic abilities of medical experts and ultimately lead to the overall
friends and various other factors to calculate the people you might potentially know. improvement in the quality of medical care all over the world.
• Another common application of Machine Learning in social media is facial recognition. This is • Convolutional Neural Networks are actively employed in the healthcare industry for X ray
done by finding around 100 reference points on the person’s face and then matching them with detection, CT Scan and ultrasound.
those already available in the database using convolutional neural networks.
2. Marketing and Sales: 4. Personal Assistants:
• When you log onto E-commerce sites like Amazon and Flipkart, they will recommend your • I am sure you all have heard of Siri, Alexa, Cortana, etc., and also heard them based on the
products to buy based on your previous browsing history. Similarly, suppose you love Pasta, then phones you have!!! These are personal assistants and an example of speech recognition that
Zomato, Swiggy, etc. will show you restaurant recommendations based on your tastes and uses Natural Language Processing to interact with the users and formulate a response
previous order history. This is true across all new-age marketing segments like Book sites, Movie accordingly.
services, Hospitality sites, etc. and it is done by implementing personalized marketing. This uses
Artificial Neural Networks to identify the customer likes, dislikes, previous shopping history, etc., • Natural Language Processing uses artificial neural networks that are made to handle many tasks
and then tailor the marketing campaigns accordingly. of these personal assistants such as managing the language syntax, semantics, correct speech,
the conversation that is going on, etc.
7. Weather Forecasting
5. Defence
• Multilayer Perceptron (MLP), Convolutional Neural Network (CNN) and Recurrent
• Defence is the backbone of every country. Every country’s state in the international Neural Networks (RNN) are used for weather forecasting. Traditional ANN multilayer
domain is assessed by its military operations. Neural Networks also shape the defence models can also be used to predict climatic conditions 15 days in advance. A
operations of technologically advanced countries. The United States of America, combination of different types of neural network architecture can be used to predict air
Britain, and Japan are some countries that use artificial neural networks for developing temperatures.
an active defence strategy. • Various inputs like air temperature, relative humidity, wind speed and solar radiations were
• Neural networks are used in logistics, armed attack analysis, and for object location. considered for training neural network based models. Combination models (MLP+CNN),
They are also used in air patrols, maritime patrol, and for controlling automated (CNN+RNN) usually works better in the case of weather forecasting.
drones.