0% found this document useful (0 votes)
4 views82 pages

AI Unit 4 Aktu

Complete ppt class notes

Uploaded by

ATUL SHUKLA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views82 pages

AI Unit 4 Aktu

Complete ppt class notes

Uploaded by

ATUL SHUKLA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 82

Artificial

Intelligence
Unit 4

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Syllabus
Uncertainty & Learning Techniques:
● Introduction to uncertainty and probabilistic reasoning,
● Bayes' Rule, Bayesian Networks,
● Fuzzy logic and handling imprecision,
● Neural Networks (basics only):Perceptron, Backpropagation (intro level),
● Fundamentals of Machine Learning in AI context,
● Introduction to supervised and unsupervised learning.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Introduction to Uncertainty
● An agent working in real environment almost never has access to whole
truth of the environment. Therefore agent need to work under
uncertainty.
● Suppose A and B are two statements, we might write A→B, which means
if A is true then B is true. But consider a situation where we are not sure
about whether A is true or not then we cannot express this statement,
this situation is called uncertainty.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Causes of uncertainty
1. Incomplete information: The agent may not have access to all facts (e.g., missing sensor
data).

2. Noisy or unreliable data: Observations may be corrupted by noise.

3. Ambiguous interpretation: The same data can have multiple possible explanations.

4. Randomness in the environment: Some outcomes are inherently unpredictable

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Probabilistic reasoning
• Probabilistic reasoning is a way of knowledge representation where we
apply the concept of probability to indicate the uncertainty in
knowledge.
• In probabilistic reasoning, we combine probability theory with logic to
handle the uncertainty.
• In the real world, there are lots of scenarios, where the certainty of
something is not confirmed, such as "It will rain today." In this sentence
we can assume that rain will happen but not sure about it, so here we use
probabilistic reasoning.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Need of probabilistic reasoning in AI
• When there are unpredictable outcomes.
• When specifications or possibilities of predicates becomes too large to handle.
• When an unknown error occurs during an experiment.

In probabilistic reasoning, there are two ways to solve problems with uncertain knowledge:
• Bayes' rule
• Bayesian Statistics

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Probability
• Probability can be defined as a chance that an uncertain event will occur. It is the numerical
measure of the likelihood that an event will occur. The value of probability always remains
between 0 and 1 that represent ideal uncertainties.
1. 0 ≤ P(A) ≤ 1, where P(A) is the probability of an event A.
2. P(A) = 0, indicates total uncertainty in an event A.
3. P(A) =1, indicates total certainty in an event A.

We can find the probability of an uncertain event by using the below formula.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Conditional probability
• Conditional probability is a probability of occurring an event when another event has already
happened.
• Let's suppose, we want to calculate the event A when event B has
already occurred, "the probability of A under the conditions of B", it can be written as:

Joint probability of A
and B

Marginal Probability of B
• If the probability of A is given and we need to find the probability of B, then it will be given as

BCS 701 Ankita Singh, Dept. of IT, AKGEC


• Example:
• In a class, there are 70% of the students who like English and 40% of the students who likes
English and mathematics, and then what is the percent of students likes Mathematics given
that they like English.

• Solution:
• Let, A is an event that a student likes Mathematics
• B is an event that a student likes English

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Bayes theorem
● Bayes' theorem is a fundamental concept in probability theory that plays a crucial role in various
machine learning algorithms, especially in the fields of Bayesian statistics and probabilistic
modelling.

● It provides a way to update probabilities based on new evidence or information.

● In the context of machine learning, Bayes' theorem is often used in Bayesian inference and
probabilistic models.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


The theorem can be mathematically expressed as:
where

● P(A) and P(B) are the probabilities of events A and B; also, P(B) is never equal to zero.
● P(A|B) is the probability of event A when event B have already occurred
● P(B|A) is the probability of event B when A have already occurred

Example: Pick a random card and you know its diamond. What is the probability that card is queen.
Total diamond =13,
Probability (Queen/ Diamond)= 1/13

BCS 701 Ankita Singh, Dept. of IT, AKGEC


This is the Bayes’ Theorem.

Here, P(A) and P(B) are probabilities of observing A and B independently of each other.

That’s why we can say that they are marginal probabilities. P(B|A) and P(A|B) are conditional
probabilities.

P(A) is called Prior probability and P(B) is called Evidence.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


likelihood
prior probability
Posterior probability

Marginal

Technical Terms of Bayes Theorem:

● P(A∣B) is the posterior probability- probability of hypothesis A given we have some data /
evidence(B)
● (B∣A) is the likelihood- probability of evidence given hypothesis is true
● P(A) is the prior probability- probability of hypothesis without observing evidence
● P(B) is the total probability / Marginal- Probability of evidence

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Question: what is the probability that a patient has diseases meningitis with a stiff neck?
Given Data:
– A doctor is aware that disease meningitis causes a patient to have a stiff neck, and it occurs
80% of the time. He is also aware of some more facts, which are given as follows:
– The Known probability that a patient has meningitis disease is 1/30,000.
– The Known probability that a patient has a stiff neck is 2%.
• Let a be the proposition that patient has stiff neck and b be the proposition that patient has meningitis. , so we
can calculate the following as:
– P(a|b) = 0.8
– P(b) = 1/30000
– P(a)= .02

• Hence, we can assume that 1 patient out of 750 patients has meningitis disease with a stiff neck.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Bayesian Belief Networks
• Bayesian belief networks (BBNs) are probabilistic graphical models that are used to
represent uncertain knowledge and make decisions based on that knowledge.
• A Bayesian network represents a set of variables and their conditional dependencies
through a directed acyclic graph (DAG).
• The nodes in the graph represent variables, while the edges indicate the probabilistic/
causal relationships between them.

• Bayesian belief networks are particularly suited to the target recognition problem, where
the category, identity and class of a target track are to be determined.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Bayesian Network Consists Of Two Parts:

Directed Acyclic Graph


● This is a graphical representation of the variables in the network and the causal relationships between them.
● The nodes in the DAG represent variables, and the edges represent the dependencies between the variables.
● The arrows in the graph indicate the direction of causality.

Table of Conditional Probabilities


● For each node in the DAG, there is a corresponding table of conditional probabilities that specifies the
probability of each possible value of the node given the values of its parents in the DAG.
● These tables encode the probabilistic relationships between the variables in the network.

Together, the DAG and the conditional probability tables allow us to perform probabilistic inference in the network,
such as computing the probability of a particular variable given the values of other variables in the network

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Example
1. To prevent break-ins, Harry put a brand-new burglar alarm at his house.
2. The alarm consistently reacts to a break-in, but it also reacts to little earthquakes.
3. David and Sopia, two of Harry's neighbours, have agreed to call Harry at work when they hear the
alarm.
4. David always calls Harry when the alarm goes off, but occasionally he confuses phone ringing with
alarm and calls too.
5. Sopia, on the other hand, enjoys listening to loud music, so occasionally she doesn't hear the alarm.
Here, we'd want to calculate the likelihood of a burglar alarm.

Problem:

Determine the probability that the alarm went off but that neither a burglary nor an
earthquake had taken place, and that both David and Sopia had called Harry.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


P(B) P(E)
P(~B) P(~E)

0.31

0.001

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Determine the probability that the alarm went off but that neither a burglary nor an
earthquake had taken place, and that both David and Sopia had called Harry.

P(D ⋀ S ⋀ A ⋀ ~B ⋀ ~E) =
P(D|A) P(S|A) P(A|~B~E) P(~B) P(~E)

= 0.91X 0.75 X 0.001 X 0.998 X 0.999

=0.00068045

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Advantages:
• Intuitive, graphical, and efficient
• Accounts for sources of uncertainty
• Allows for information updating
• Models multiple interdependencies
• Models distributed & interacting systems
• Identifies critical components & cut sets
• Includes utility and decision nodes

Disadvantages:

• Not ideally suited for computing small probabilities


• Practical limitations on the type of distributions and the form of statistical dependence
• Computationally demanding for systems with a large number of random variables
• Exponential growth of computational effort with increased number of states

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Fuzzy logic
Fuzzy Logic is used to handle uncertainty and imprecision in
situations where things are not clear.
For example:

● “The weather is hot.”


● “The road is somewhat crowded.”

These statements cannot be expressed precisely as true or


false.
Fuzzy Logic helps us deal with such imprecise or ambiguous
situations by modeling degrees of truth instead of binary
values.

Fuzzy Logic (FL) is an extension of classical (Boolean) logic


that allows truth values to range between 0 and 1 instead of
being only 0 or 1.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Concepts of Fuzzy Logic
1. Membership Function: It defines how much an input belongs to a particular category. For
example, in a fuzzy temperature control system, a temperature of 70°F might belong 0.8 to the
"warm" category and 0.2 to the "cool" category.
2. Fuzzy Sets: These are sets where elements have degrees of membership. For example, the
"young" age group might include someone who is 30 with 0.7 membership (mostly young) and
someone who is 50 with 0.3 membership (partly young).
3. Linguistic Variables: These are variables defined using terms rather than precise numbers. For
example, "temperature" could be a linguistic variable with terms like "cold," "warm" and "hot."

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Fuzzy Logic Architecture

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Fuzzy Logic systems are made up of four main components that work together to process
imprecise or uncertain data:
1. Fuzzification: It is the process of converting precise input values(such as temperature
or pressure readings) into fuzzy sets. This step is important because real-world inputs
like those from sensors aren’t perfect or exact.
2. Rule Base: A collection of "if-then" rules created by experts to guide the system's
decisions. These rules use natural language terms (like "high," "low," "warm") to
describe conditions and actions.
3. Inference Engine: It evaluates the fuzzified input data and applies the relevant rules
from the rule base. It find which rules are most appropriate and then combines the
results to generate a control action.
4. Defuzzification: Once the inference engine processes the rules and generates fuzzy
outputs, it converts these fuzzy results back into a precise, crisp value. This final step
ensures that the system can take clear actions based on the fuzzy logic outputs

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Membership Functions

A membership function describes how much an input value belongs to a fuzzy set. It assigns a value
between 0 and 1 to each point in the input space also called the universe of discourse:
● 0 -> the value does not belong to the set
● 1 -> the value fully belongs to the set
● Values in between -> partial membership

These functions are a key part of fuzzification, helping translate precise real-world data into fuzzy
values that can be processed by the system.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Common Types of membership functions:

1. Singleton: Represents a crisp value as a fuzzy value at one specific point.


2. Gaussian: Based on the Gaussian curve, this allows smooth transitions between
membership degrees.
3. Trapezoidal or Triangular: It uses straight-line shapes to define how membership changes
across a range of values.

By choosing the right membership function, we can represent uncertainty more naturally and make
fuzzy logic systems respond in a way that feels closer to human reasoning.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Defuzzification Methods

To convert fuzzy outputs into crisp values:


● Centroid Method (Center of Gravity): Most common
● Mean of Maximum (MOM)
● Bisector Method

Applications of Fuzzy Logic

● Home appliances: ACs, washing machines, refrigerators

● Automobiles: Gear shifting, braking systems

● Medical diagnosis: Handling uncertain symptoms

● Control systems: Industrial process control

● Decision support systems: Evaluating vague or subjective data

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Advantages

● Handles imprecision and vagueness effectively.

● Mimics human reasoning and natural language.

● Flexible and tolerant to noisy data.

● Simple and interpretable rule-based systems.

Limitations

● Rule explosion (too many rules for large systems).

● Requires expert knowledge for rule formation.

● Not suitable when precise mathematical modeling is possible.

● Performance depends on design of membership functions.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Neural Networks
● A neural network is a machine learning program, or model, that makes decisions in a
manner similar to the human brain by using processes that mimic the way biological
neurons work together to identify phenomena, weigh options and arrive at conclusions.
● Artificial Neural Networks work collectively and concurrently, imitating biological neural
networks. They are used in many different fields, like regression problems, pattern
recognition, recommendation systems, and weather forecasting.
● Tasks in speech recognition or image recognition can take minutes versus hours when
compared to the manual identification by human experts. One of the best-known
examples of a neural network is Google’s search algorithm.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Structure of a Biological Neuron:

• Dendrite (Input):

Receives signals from other neurons.

• Cell Body (Summing Unit):

Sums up all the incoming input signals.

Contains the threshold unit.

• Axon (Output):

When the sum reaches a threshold level, the neuron generates an output signal which travels down to
other neurons.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Similar to the human brain that has neurons interconnected to one another,
artificial neural networks also have neurons that are interconnected to one another
in various layers of the networks. These neurons are known as nodes.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Artificial Neuron
An artificial neuron is a mathematical function based on the model of biological neurons.

The model of an artificial neuron has five components:

• Input Values/Input Layer: Input values are passed to a neuron using this layer. Similar to dendrites in biological
neurons.

• Synapses/Weighted Connection Links: Each connection link is characterized by a weight or strength (wi). Each input
(xi) is multiplied by its weight to get the synaptic strength.

• Summing Function:The summing function takes the sum of all weighted connection links: Σwi xi. A bias value (b) is
also added to this weighted sum.

• Activation Function: The activation function decides whether or not a neuron is fired based on the output value
produced.

• Output/Output Layer: The output layer gives the final output of a neuron which can then be passed to other
neurons in the network.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Perceptron
● The first neural network model ‘Perceptron’, was designed in 1958

● Perceptron is a type of neural network that performs binary classification, that maps input
features to an output decision, usually classifying data into one of two categories, such as 0 or 1.

● Perceptron consists of a single layer of input nodes that are fully connected to a layer of output
nodes. It is particularly good at learning linearly separable patterns.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Types of Perceptron
1. Single-Layer Perceptron is a type of perceptron is limited to learning linearly separable
patterns. It is effective for tasks where the data can be divided into distinct categories
through a straight line. While powerful in its simplicity, it struggles with more complex
problems where the relationship between inputs and outputs is non-linear.
2. Multi-Layer Perceptron possess enhanced processing capabilities as they consist of two or
more layers, adept at handling more complex patterns and relationships within the data.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Single Layer Perceptron
● A perceptron is the earliest form of a neural network unit, introduced by Frank
Rosenblatt in 1958.
● It is a binary classifier that makes predictions based on a linear combination of input
features.
● The perceptron algorithm was one of the first algorithms used to implement a simple
neural network.
● Perceptrons are supervised learning algorithms and is a type of an ANN

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Components of a Perceptron:
● Inputs: The perceptron takes several inputs (x1,x2,…,xn) each representing a feature of
data.
● Weights: Each input is associated with a weight (w1,w2,…,wn) that represents its
importance in the decision making process.
● Bias: A bias term (b) is added to shift the decision boundary.
● Activation Function: A function that processes the sum of weighted inputs and bias to
produce an output.The perceptron uses a step function (a simple thresholding function) to
determine whether the weighted sum of inputs plus the bias is above or below a certain
threshold to give the result.
The mathematical representation is:

BCS 701 Ankita Singh, Dept. of IT, AKGEC


BCS 701 Ankita Singh, Dept. of IT, AKGEC
Perceptron Learning Algorithm

BCS 701 Ankita Singh, Dept. of IT, AKGEC


AND function using Perceptron Rule Solved Example

Initially b=0, w1=0, w2=0

x1 x2 target yin y Error w1 w2 b


(t-y)

1 1 1 0 0 1 1 1 1

1 -1 -1 1 1 -2 -1 3 -1

-1 1 -1 1 1 -2 1 1 -3

-1 -1 -1 -5 -1 0 1 1 -3

BCS 701 Ankita Singh, Dept. of IT, AKGEC


AND function using Perceptron Rule Solved Example

x1 x2 target yin y error(t w1 w2 b


-y)

1 1 1 -1 -1 2 3 3 -1

1 -1 -1 -1 -1 0 3 3 -1

-1 1 -1 -1 -1 0 3 3 -1

-1 -1 -1 -7 -1 0 3 3 -1

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Gradient Descent and Delta Rule

A set of data points are said to be linearly separable if the data can be divided into two classes using a
straight line. If the data is not divided into two classes using a straight line, such data points are said to be
called non-linearly separable data.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


● Although the perceptron rule finds a successful weight vector when the training examples are
linearly separable, it can fail to converge if the examples are not linearly separable.

● The perceptron rule works well for gates like AND, OR, and NAND, since their outputs are
linearly separable, allowing the algorithm to find a clear decision boundary. However, it fails
for gates such as XOR , where the outputs are not linearly separable — no single straight line
can divide the classes correctly. Hence, the perceptron converges for linearly separable gates
but fails to converge for non-linearly separable ones.

● A second training rule, called the delta rule, is designed to overcome this difficulty.

● If the training examples are not linearly separable, the delta rule converges toward a best-fit
approximation to the target concept.

● The key idea behind the delta rule is to use gradient descent to search the hypothesis space
of possible weight vectors to find the weights that best fit the training examples.

● This rule is important because gradient descent provides the basis for the BACKPROPAGATON
algorithm, which can learn networks with many interconnected units.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


BCS 701 Ankita Singh, Dept. of IT, AKGEC
Delta Rule
● The delta training rule is best understood by considering the task of training an unthresholded perceptron; that
is, a linear unit for which the output o is given by

● Thus, a linear unit corresponds to the first stage of a perceptron, without the threshold.
● In order to derive a weight learning rule for linear units, let us begin by specifying a measure for the training
error of a hypothesis (weight vector), relative to the training examples.
● Although there are many ways to define this error, one common measure is

where D is the set of training examples, ‘td’ is the target output for training example ‘d’, and od is the output of the
linear unit for training example ‘d’.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


How to calculate the direction of steepest descent along the error surface?

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Multi-layer Perceptron
A multi-layer perceptron is a type of Feed Forward Neural Network with multiple neurons
arranged in layers.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


The network has at least three layers:

● Input Layer: Each neuron or node in this layer corresponds to an input feature. For
instance, if you have three input features the input layer will have three neurons.
● Hidden Layers: MLP can have any number of hidden layers with each layer containing any
number of nodes. These layers process the information received from the input layer.
● Output Layer: The output layer generates the final prediction or result. If there are multiple
outputs, the output layer will have a corresponding number of neurons.

Every connection in the diagram is a representation of the fully connected nature of an MLP. This
means that every node in one layer connects to every node in the next layer.
As the data moves through the network each layer transforms it until the final output is generated in
the output layer

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Working of Multi-Layer Perceptron
The key mechanisms such as forward propagation, loss function, backpropagation and optimization.

1. Forward Propagation

In forward propagation the data flows from the input layer to the output layer, passing through any
hidden layers. Each neuron in the hidden layers processes the input as follows:
a. Weighted Sum: The neuron computes the weighted sum of the inputs:

b. Activation Function: The weighted sum z is passed through an activation function to introduce
non-linearity. Common activation functions include: Sigmoid, ReLU(Rectified Linear Unit),
Tanh(Hyperbolic Tangent)

BCS 701 Ankita Singh, Dept. of IT, AKGEC


2. Loss Function
● Once the network generates an output the next step is to calculate the loss using a loss
function. In supervised learning this compares the predicted output to the actual label.
● A loss/error is computed using functions like MSE (for regression) or Cross-Entropy (for
classification).
● This loss indicates how far the prediction is from the expected answer.

3. Backpropagation
● The goal of training an MLP is to minimize the loss function by adjusting the network's weights
and biases. This is achieved through backpropagation
● Error is propagated backward from output layer to input layer.
● Gradients (partial derivatives) are computed using chain rule.
● Weights and biases are updated using an optimization method like Gradient Descent to
reduce loss.
● The process repeats across many epochs until the network learns the correct mapping

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Example
x1, x2: input to the perceptron

t : expected output / target

η: learning rate

w : weights

BCS 701 Ankita Singh, Dept. of IT, AKGEC


y3

y4

BCS 701 Ankita Singh, Dept. of IT, AKGEC


y3

y5
y4

Minimize this error, and


propagate it backwards to
update the weights

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Backpropagation
● Backpropagation, short for Backward Propagation of Errors, is a key algorithm used to train neural
networks by minimizing the difference between predicted and actual outputs.

● It works by propagating errors backward through the network, using the chain rule of calculus to
compute gradients and then iteratively updating the weights and biases.

● Combined with optimization techniques like gradient descent, backpropagation enables the model
to reduce loss across epochs and effectively learn complex patterns from data.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


BCS 701 Ankita Singh, Dept. of IT, AKGEC
BCS 701 Ankita Singh, Dept. of IT, AKGEC
y3 Example Continued….

y5
y4

δk =

BCS 701 Ankita Singh, Dept. of IT, AKGEC


BCS 701 Ankita Singh, Dept. of IT, AKGEC
y3

y5
y4

BCS 701 Ankita Singh, Dept. of IT, AKGEC


BCS 701 Ankita Singh, Dept. of IT, AKGEC
BCS 701 Ankita Singh, Dept. of IT, AKGEC
Fundamentals of Machine Learning in AI context
● Artificial Intelligence in general refers to the simulation of human intelligence processes by machines

● AI enables machine to think, without human intervention machine will be able to take own decision.

● Machine learning focuses on developing models and algorithms that let computers learn from data and
improve from previous experience without being explicitly programmed for every task.

● Deep learning is a subset of machine learning in which multi-layered neural networks learn from vast amount
of data.
● The main difference between ML and DL technologies is of presentation of data. ML uses structured and
unstructured data for learning, while deep learning uses neural networks for learning models.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


BCS 701 Ankita Singh, Dept. of IT, AKGEC
BCS 701 Ankita Singh, Dept. of IT, AKGEC
BCS 701 Ankita Singh, Dept. of IT, AKGEC
Supervised learning:
Supervised learning is the types of
machine learning in which machines
are trained using well "labelled"
training data, and on basis of that
data, machines predict the output. The
labelled data means some input data is
already tagged with the correct output.

ex-Image classification, fraud detection,


filtering.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Supervised learning:
● Suppose we have a dataset of different types of
shapes which includes square, rectangle, triangle,
and Polygon. Now the first step is that we need to
train the model for each shape.
● 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.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Types of supervised learning
1.Regression-
● Regression algorithms are used to solve regression problems in which
there is a linear relationship between input and output variables.
● These are used to predict continuous output variables, such as market
trends, weather prediction, etc.
● Some popular Regression algorithms are Simple Linear Regression
Algorithm, Multivariate Regression Algorithm, Decision Tree Algorithm ,
Lasso Regression

BCS 701 Ankita Singh, Dept. of IT, AKGEC


2.Classification-
● A Classification problem is when the output variable is categorical, which
means there are two classes such as Yes-No, Male-Female, True-false, red
or blue, disease or no diseases etc.
● Some real-world examples of classification algorithms are Spam
Detection, Email filtering, etc.
● Some popular classification algorithms are Random Forest Algorithm,
Decision Tree Algorithm , Logistic Regression Algorithm, Support Vector
Machine Algorithm

BCS 701 Ankita Singh, Dept. of IT, AKGEC


BCS 701 Ankita Singh, Dept. of IT, AKGEC
Advantages of Supervised learning:
● With the help of supervised learning, the model can predict the output on
the basis of prior experiences.
● In supervised learning, we can have an exact idea about the classes of
objects.
● Supervised learning model helps us to solve various real-world problems
such as fraud detection, spam filtering, etc.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Disadvantages of supervised learning:
● Supervised learning models are not suitable for handling the complex tasks.
● Supervised learning cannot predict the correct output if the test data is
different from the training dataset.
● Training required lots of computation time.
● In supervised learning, we need enough knowledge about the classes of
object.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Unsupervised Machine Learning
● 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 patterns and insights from the given
data.
● It can be defined as:
Unsupervised learning is a type of machine learning in which models are
trained using unlabeled dataset and are allowed to act on that data without any
supervision.
● The goal of unsupervised learning is to find the underlying structure of
dataset, group that data according to similarities, and represent that dataset
in a compressed format.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Example
● Suppose the unsupervised learning algorithm is given an input dataset containing images of different types of
cats and dogs.
● The algorithm is never trained upon the given dataset, which means it does not have any idea about the
features of the dataset.
● The task 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.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Types of Unsupervised Learning
1. Clustering:
● Clustering is a method of grouping the objects into clusters such that
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 between the data objects and
categorizes them as per the presence and absence of those commonalities.
● An example of the clustering algorithm is grouping the customers by their
purchasing behavior.
● Some Popular Clustering algorithms are K-Means Clustering algorithm,
Mean-shift algorithm, DBSCAN Algorithm, Principal Component Analysis,
Independent Component Analysis

BCS 701 Ankita Singh, Dept. of IT, AKGEC


2. Association:
● An association rule is an unsupervised learning method which is used for
finding the relationships between variables in the large dataset. It
determines the set of items that occurs together in the dataset.
● Association rule makes marketing strategy more effective. Such as people
who buy X item (suppose a bread) are also tend to purchase Y (Butter/Jam)
item. A typical example of Association rule is Market Basket Analysis.
● Some popular algorithms of Association rule learning are Apriori
Algorithm, Eclat, FP-growth algorithm.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Advantages of Unsupervised Learning
• Unsupervised learning is used for more complex tasks as compared to
supervised learning because, in unsupervised learning, we don't have
labeled input data.
• Unsupervised learning is preferable as it is easy to get unlabeled data in
comparison to labeled data.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Disadvantages of Unsupervised Learning
• Unsupervised learning is intrinsically more difficult than supervised learning
as it does not have corresponding output.
• The result of the unsupervised learning algorithm might be less accurate as
input data is not labeled, and algorithms do not know the exact output in
advance.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Supervised Learning Unsupervised Learning
Supervised learning algorithms are trained using Unsupervised learning algorithms are trained using
labeled data. unlabeled data.
The goal of supervised learning is to train the model The goal of unsupervised learning is to find the
so that it can predict the output when it is given new hidden patterns from the unknown dataset.
data.
Supervised learning can be categorized Unsupervised Learning can be classified
in Classification and Regression problems. in Clustering and Associations problems.
Supervised learning can be used for those cases Unsupervised learning can be used for those cases
where we know the input as well as corresponding where we have only input data and no
outputs. corresponding output data.
Supervised learning model produces an accurate Unsupervised learning model may give less
result. accurate result as compared to supervised
learning.
Supervised learning is not close to true Artificial Unsupervised learning is more close to the true
intelligence as in this, we first train the model for each Artificial Intelligence as it learns similarly as a child
data, and then only it can predict the correct output. learns daily routine things by his experiences.
It includes various algorithms such as Linear It includes various algorithms such as Clustering,
Regression, Logistic Regression, Support Vector KNN, and Apriori algorithm.
Machine, Multi-class Classification, Decision tree,
Bayesian Logic, etc.
BCS 701 Ankita Singh, Dept. of IT, AKGEC
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.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


● As compared to unsupervised learning, reinforcement learning is different in
terms of goals. While the goal in unsupervised learning is to find similarities and
differences between data points. RL is a technique that enables an agent to learn
in an interactive environment by trial and error feedback from its own actions
and experiences.
● Environment can be real world (robot) or simulated world ( ex. Video game).
● In reinforcement learning the goal is to find a suitable action model that would
maximize the total cumulative reward of the agent.
● The agent learns without intervention from a human by maximizing its reward
and minimizing its penalty.
● RL can guide an agent on how to act in the real world (robot that vacuum your
house, robot that learn to walk).

● Military is interested in this tech: RL agent can replace soldiers not just
walk, but fight, diffuse bombs, make important decisions.
BCS 701 Ankita Singh, Dept. of IT, AKGEC
It is Inspired by human brain. We have eyes and nose
as sensory organ but machine has sensors as
sensory organ.

• Agent- an important component to process the


information, thing that senses the
environment.
• Environment – real world or simulated
world that the agent lives in.
• State- different configuration of the
environment that the agent can sense.
• Actions: are what an agent does in its
environment. Notation (s,a,r).
• Rewards- positive or negative.

BCS 701 Ankita Singh, Dept. of IT, AKGEC


Types of Reinforcement learning
Reinforcement learning is categorized mainly into two types of
methods/algorithms:
• Positive Reinforcement Learning: Positive reinforcement learning
specifies increasing the tendency that the required behavior would
occur again by adding something. It enhances the strength of the
behavior of the agent and positively impacts it.

• Negative Reinforcement Learning: Negative reinforcement learning


works exactly opposite to the positive RL. It increases the tendency that
the specific behavior would occur again by avoiding the negative
condition.

BCS 701 Ankita Singh, Dept. of IT, AKGEC

You might also like