21csc206t Unit 5
21csc206t Unit 5
UNIT V
• Planning – planning problem – Simple planning agent – Blocks world
problem – Mean Ends analysis
• Learning - Machine learning - Learning concepts, methods and models
• Introduction to expert system – architecture of expert systems.
Planning and Learning
Table of Contents
• Planning- Planning problems, Simple planning agent, Planning languages
Planning
• Find a sequence of actions that achieves a given goal when executed from a given
initial world state.
That is, given
• a set of operator descriptions (defining the possible primitive actions by the agent),
• an initial state description, and
• a goal state description or predicate,
• compute a plan, which is a sequence of operator instances, such that executing them
in the initial state will change the world to a state satisfying the goal-state
description.
• Goals are usually specified as a conjunction of subgoals to be achieved
Planning vs. Problem Solving
• Planning and problem solving methods can often solve the same sorts of
problems
• Planning is more powerful because of the representations and methods used.
• States, goals, and actions are decomposed into sets of sentences (usually in
first-order logic)
• Search often proceeds through plan space rather than state space (though
there are also state-space planners)
• Subgoals can be planned independently, reducing the complexity of the
planning problem
Planning Problem
Given:
•Initial state:
•Initial state: The agent is at home without tea, biscuits, book
• Goal state: Goal state: The agent is at home with tea, biscuits, book biscuits,
book
Planning Problem
▪The planner is free to add actions to the plan wherever they are required,
rather than wherever they are required, rather than in an incremental way
starting from the initial state. incremental way starting from the initial state.
▪Most parts of the world are independent of most other parts – hence divide
& conquer works well.
Situation Calculus
Initial state:
At(Home, s0) ∧ ¬ Have(Tea, s0) ∧ ¬ Have(Biscuits, s0) ∧ ¬Have(Book, s0)
Goal state:
∃ s At(Home, s) ∧ Have(Tea, s) ∧ Have(Biscuits, s) ∧ Have(Book, s)
Operators:
∀ a,s Have(Tea, Result(a,s)) ⇔ [(a = Buy(Tea) ∧ At(Tea-shop,s))
∨ (Have(Tea, s) ∧ a ≠ Drop(Tea))]
Result(a,s) names the situation resulting from executing the action a in the
situation s
Simple Planning Agent
STRIPS (STanford Research Institute Problem Solver) -an action language which was a part
of the first major planning system with the same name.
ADL (Action Description Language) is one of STRIPS extension which supports negative
literals, quantified variables in goals (e.g. ∃x At (P1, x) ∧ At(P2, x)), conditional effects and
disjunctions in goals (all not allowed in STRIPS)
GOAL = G1 ^ G2 ^ … ^Gn
Sub-goals G1, G2, … Gn are stacked with compound goal G1 ^ G2 ^ …^ Gn at the
bottom.
Top G1
G2
:
Gn
Bottom G1 ^ G2 ^ … ^ G4
At each step of problem solving process, the top goal on the stack is pursued.
GOAL STACK PROBLEM- The Idea!
:Place goal in goal stack
Goal1
,Considering top Goal1
place onto it its sub-
:goals GoalS1-2
GoalS1-1
Goal1
Algorithm
1. Find an operator that satisfies sub goal G1 (makes it true) and replace G1
by the operator.
2. If more than one operator satisfies the sub goal then apply some
heuristic to choose one.
3. In order to execute the top most operation, its preconditions are added
onto the stack.
4. Once preconditions of an operator are satisfied, then we are guaranteed
that operator can be applied to produce a new state.
5. New state is obtained by using ADD and DELETE lists of an operator to
the existing database.
6. Problem solver keeps tract of operators applied.
7. This process is continued till the goal stack is empty and problem solver
returns the plan of the problem.
GOAL STACK PROBLEM- Complete
v
solution
(UNSTACK(C,D),PUTDOWN(C),UNSTACK(D,A),STACK(D,B)
,PICKUP(A),STACK(A,D))
GOAL STACK PROBLEM-
Example
The Working!
Initial state Goal state
A
C C
A B B
:Database CLEAR(B)
ON(C,A)
CLEAR(C)
ONTABLE(A)
ONTABLE(B)
HANDEMPTY
GOAL STACK PROBLEM-
The Working!
2. Since top goal is unsatisfied compound
goal, list its unsatisfied subgoals on top of it:
On(C,B)
:Stack On(A,C)
CLEAR(B)
ON(C,A)
Database CLEAR(C)
ONTABLE(A)
:)unchanged( ONTABLE(B)
HANDEMPTY
GOAL STACK PROBLEM-
The Working!
3. Since top goal is unsatisfied single-literal goal, find rule whose
instantiated add-list includes the goal, and: a. Replace the goal with
the instantiated rule; b. Place the rule’s instantiated precondition
formula on top of stack
CLEAR(B)
Database ON(C,A)
:)unchanged( CLEAR(C)
ONTABLE(A)
ONTABLE(B)
HANDEMPTY
GOAL STACK PROBLEM-
The Working!
4. Since top goal is unsatisfied compound goal, list its subgoals on top
of it:
Clear(B)
Holding(C)
:Stack
Holding(C) & Clear(B)
stack(C,B)
stack(C,B)
On(A,C)
CLEAR(B)
Database ON(C,A)
:)unchanged( CLEAR(C)
ONTABLE(A)
ONTABLE(B)
HANDEMPTY
GOAL STACK PROBLEM-
The Working!
5. Single goal on top of stack matches data base, so remove it:
Clear(B)
Holding(C)
:Stack
Holding(C) & Clear(B)
stack(C,B)
stack(C,B)
On(A,C)
CLEAR(B)
Database ON(C,A)
:)unchanged( CLEAR(C)
ONTABLE(A)
ONTABLE(B)
HANDEMPTY
GOAL STACK PROBLEM-
The Working!
6. Since top goal is unsatisfied single-literal goal, find rule whose
instantiated add-list includes the goal, and: a. Replace the goal with
the instantiated rule; b. Place the rule’s instantiated precondition
formula on top of stack
On(A,C) &On(C,B)
Database: (unchanged)
GOAL STACK PROBLEM-
The Working!
7. Compound goal on top of stack matches data base, so remove it:
On(A,C) &On(C,B)
CLEAR(B)
Database ON(C,A)
:)unchanged( CLEAR(C)
ONTABLE(A)
ONTABLE(B)
HANDEMPTY
!STEPS CONTINUES UNTIL STACK IS EMPTY
Means - Ends Analysis
• Search strategies either reason forward of backward
• Mixed strategy - solve the major parts of problem first and solve
the smaller problems the arise when combining them together.
• Such a technique is called "Means - Ends Analysis".
• The means -ends analysis process centers around finding the
difference between current state and goal state.
• The problem space of means - ends analysis has
– an initial state and one or more goal state,
– a set of operate with a set of preconditions their application
and
– difference functions computes the difference between two
state a(i) and s(j).
Problem Solving using
Means - Ends Analysis
The algorithm for MEA consists of the following steps:
Step 1: Measure the current state of things by doing as is the study and
capture the status at a macro level and to a possible micro level.
Step 2: Capture the deficiency in the current state and avenues for
improvements (wish list) and define the goal state (to-be state).
Define the to-be state at a macro level and to a possible micro level.
Step 3: Compare the Current state and Goal state and if they are at the
same level the problem is resolved.
Step 4: List the differences between the current state and goal state at
macro and micro levels.
Step 5: Convert the differences into deletions/modifications to current
state and new additions.
Step 6: Define the action to implement the changes as defined in step-
5.
Step 7: Implement the changes and measure the actual results with
the planned goals.
Step 8: Do course correction and achieve the final goal.
Problem Solving using
Means - Ends Analysis - Example
Example 1:
• If in your current state you are hungry, and in your goal state you are not
hungry
• Preconditions of visit_cafeteria: you know where the cafeteria is.
Postconditions of visit_cafeteria: you are no longer hungry.
Example 2:
MEA – To do Exercise!
Example:
An electronics business company aims to get a turnover of Rs. 10 crores
per annum. How do you do?
Planning and Learning
Table of Contents
• Planning- Planning problems, Simple planning agent, Planning languages
• Blocks world ,Goal stack planning, Mean Ends Analysis
• Non-linear Planning, Conditional planning, Reactive planning
• Learning- Machine learning, Goals and Challenges of machine learning
• Learning concepts, models, Artificial neural network based learning- Back
propagation, Support vector machines,
• Reinforcement learning, Adaptive learning, Multi_agent based learning, Ensemble
learning, Learning for decision making, Distributed learning, Speedup learning
Planning and Learning
Partial-order planning
Belief state: The set of possible states that the agent can be in
“Alternate double Murphy world”: dirt can sometimes be left
behind when the agent leaves a clean square
Example –Part of the Search
Reactive planning
•Reactive planning is planning under uncertainty.
•A group of techniques for action selection by autonomous agents.
• Differs from classical planning in two aspects:
➤ operate in a timely fashion and hence can cope with highly dynamic
and unpredictable environments.
➤ compute just one next action in every instant, based on the current
context.
•Reactive planners often (but not always) exploit reactive plans, which are stored
structures describing the agent's priorities and behaviour.
•Makes use of the if-then rules.
•The rule which is at present in execution is said to be active whereas the others
are inactive.
21-04-2021 18CSC305J_AI_UNIT3 47
REACTIVE PLAN REPRESENTATION
➤ Connectionists approaches
21-04-2021 18CSC305J_AI_UNIT3 48
Reactive Plan – If then, Conflict Resolution
1. If A Then B & C
2. If B Then E
3. If C Then A
4. If B& C Then E
5. If E Then G
1, 4, 2,3,5
21-04-2021 18CSC305J_AI_UNIT3 49
REACTIVE PLAN REPRESENTATION
➤ Finite State Machines (FSMs) and Behavior trees
21-04-2021 18CSC305J_AI_UNIT3 50
REACTIVE PLAN REPRESENTATION
➤ Fuzzy approaches (Utility Systems)
21-04-2021 18CSC305J_AI_UNIT3 51
REACTIVE PLAN REPRESENTATION
Connectionists approaches
21-04-2021 18CSC305J_AI_UNIT3 52
Planning and Learning
Table of Contents
• Planning- Planning problems, Simple planning agent, Planning languages
• Blocks world ,Goal stack planning, Mean Ends Analysis
• Non-linear Planning, Conditional planning, Reactive planning
• Learning- Machine learning, Goals and Challenges of machine learning
• Learning concepts, models, Artificial neural network based learning- Back
propagation, Support vector machines
• Reinforcement learning, Adaptive learning, Multi_agent based learning, Ensemble
learning, Learning for decision making, Distributed learning, Speedup learning
Learning
An agent is learning if it improves its performance on future tasks after
making observations about the world.
The improvements, and the techniques used to make them, depend on four major
factors:
• Which component is to be improved.
• What prior knowledge the agent already has.
• What representation is used for the data and the component.
• What feedback is available to learn from.
Machine Learning Defined
The oft quoted and widely accepted formal definition of machine learning as stated
by field pioneer Tom M. Mitchell is:
A computer program is said to learn from experience E with respect to some
class of tasks T and performance measure P if its performance at tasks in T, as
measured by P, improves with experience E
21-04-2021 18CSC305J_AI_UNIT4 60
Learning concepts
Supervised learning
Classification Regression
65
REGRESSION
66
REGRESSION
67
Un-Supervised Learning
68
Un -Supervised Learning
69
Un -Supervised Learning
70
Semi Supervised Learning
71
Reinforcement Learning
The idea behind Reinforcement Learning is that an agent will learn from the environment by
interacting with it and receiving rewards for performing actions.
CATEGORICAL:
• Finite number of categories of
classes
• Gender, age group, Presence or
absence of something
CONTINOUS:
• Infinite number of values
• Age, height, weight, price
73
Introduction to simple linear regression
74
Examples
Dependent Independent
variables variables
Retail price of petrol in
The price of crude oil.
Chennai
(Education) x y y (Income)
(Education) x1
(Gender) x2
y (Income)
(Experience) x3
(Age) xModel
4
with simultaneous relationship
Price of wheat Quantity of wheat produced
76
Bivariate or simple linear regression
• Amount of change in a dependent variable that results from changes in the independent
variable(s) – can be used to estimate elasticities, returns on investment in human capital,
etc.
• Attempt to determine causes of phenomena.
78
Classification Techniques
What is Classification?
It is a process of categorizing a given set
of feature vectors into two or more classes.
Classification Techniques:
• Logistic Regression
• Artificial Neural Networks (ANN)
• Support Vector Machine (SVM)
• Deep Neural Network (DNN)
• Convolution Neural Network (1D-CNN and
2D-CNN)
79
Logistic Regression
•Logistic Regression is a Machine Learning classification algorithm that is used to predict
the probability of a categorical dependent variable.
• In logistic regression, the dependent variable is a binary variable that contains data coded
as 1 (yes, success, etc.) or 0 (no, failure, etc.). In other words, the logistic regression model
predicts P(Y=1) as a function of X.
1. Binary Logistic Regression: The categorical response has only two 2 possible
outcomes. E.g.: Spam or Not
2. Multinomial Logistic Regression: Three or more categories without ordering.
E.g.: Predicting which food is preferred more (Veg, Non-Veg, Vegan)
3. Ordinal Logistic Regression: Three or more categories with ordering. E.g.:
Movie rating from 1 to 5
81
Math behind Binary Logistic Regression
Demo
82
Logistic Regression
Applications of classification
Demo
9. Voice recognition.
10.Medical diagnostic test.
11.Customer behavior prediction. 84
Clustering Techniques
What is Clustering?
• It is a process of dividing the given set of feature vectors into two or more groups
(clusters). The data points in each cluster are somehow related to each other.
Applications of Clustering
• Recommendation engines
• Market segmentation
• Social network analysis
• Search result grouping
• Image segmentation
Clustering Techniques:
• k-means Clustering
• Hierarchical Clustering
85
K-means Clustering Algorithm
Start
Initialize k centroids (k
mean vectors)
Yes
Compute distance between each feature vector to all
the centroids
Is there any No
Assign each feature vector to any one of the Centroid change in End
based on minimum Euclidean distance Centroid?
86
K-means Clustering Algorithm
• K-Means clustering is an unsupervised iterative clustering technique.
• It partitions the given data set into k predefined distinct clusters.
• A cluster is defined as a collection of data points exhibiting certain
similarities.
87
K-means Clustering Algorithm
• It partitions the data set such that-
• Each data point belongs to a cluster with the nearest mean.
• Data points belonging to one cluster have high degree of similarity.
• Data points belonging to different clusters have high degree of dissimilarity.
88
Use K-Means Algorithm to create two clusters
C1
A 2 2 C1 1.5 1.166667
C1 1 1
E 1.5 0.5
C2
B 3 2 C2 3 1.5
D 3 1
Demo
89
Machine Learning Models
• Artificial neural networks
• Decision trees
• Support-vector machines
• Regression analysis
• Bayesian networks
• Genetic algorithms
21-04-2021 18CSC305J_AI_UNIT4 90
Artificial neural network based learning
• Artificial Neural Network ANN is an efficient computing system whose central theme is borrowed from the
analogy of biological neural networks.
• ANNs are also named as “artificial neural systems” acquires a large collection of units that are
interconnected in some pattern to allow communication between the units. These units, also referred to as
nodes or neurons, are simple processors which operate in parallel.
• Every neuron is connected with other neuron through a connection link. Each connection link is associated
with a weight that has information about the input signal. This is the most useful information for neurons to
solve a particular problem because the weight usually excites or inhibits the signal that is being
communicated.
• Each neuron has an internal state, which is called an activation signal. Output signals, which are produced
after combining the input signals and activation rule, may be sent to other units.
21-04-2021 18CSC305J_AI_UNIT4 91
Model of Artificial Neural Network
21-04-2021 18CSC305J_AI_UNIT4 92
Back Propagation Method
▪ Back propagation is a common method for training a neural network.
▪ It is the method of fine-tuning the weights of a neural net based on the error rate obtained
in the previous epoch (i.e., iteration).
▪ Proper tuning of the weights allows you to reduce error rates and to make the model
reliable by increasing its generalization
• TWO STEPS:
• Forward pass phase: computes ‘functional signal’, feed forward propagation of input
pattern signals through network
• Backward pass phase: computes ‘error signal’, propagates the error backwards through
network starting at output units (where the error is the difference between actual and
desired output values
21-04-2021 18CSC305J_AI_UNIT4 93
Back Propagation Algorithm
21-04-2021 18CSC305J_AI_UNIT4 94
Back Propagation Algorithm
21-04-2021 18CSC305J_AI_UNIT4 95
Back Propagation Algorithm
A neural network with two inputs, two hidden neurons, two output neurons. Additionally,
the hidden and output neurons will include a bias.
The initial weights, the biases, and training inputs/outputs are given as follows:
22-04-2021 18CSC305J_AI_UNIT4 96
The Forward Pass
• First, we’ll feed the inputs 0.05 and 0.10 forward through the network.
• We figure out the total net input to each hidden layer neuron, squash the total net input
using an activation function (here we use the logistic function), then repeat the process with
the output layer neurons.
22-04-2021 18CSC305J_AI_UNIT4 97
The Forward Pass contd…
22-04-2021 18CSC305J_AI_UNIT4 98
The Forward Pass contd…
22-04-2021 18CSC305J_AI_UNIT4 99
The Backward Pass
Our goal with back propagation is to update each of the weights in the network so that they cause the
actual output to be closer the target output, thereby minimizing the error for each output neuron and the
network as a whole.
Reward values:
• Idling is -1. We don't want the mouse to wander.
• Collecting a cheese is +100.
• The cat hits the mouse -100.
• The mouse hits the walls -100. We don't want to see the
Catch the Cheese Game
• AI agent (mouse) itself learns to run away from the mouse trying to go out of the game field.
cat and collect cheeses in the game.
Two years ago we introduced the first widely successful algorithm for deep
reinforcement learning. The key idea was to use deep neural networks to
represent the Q-network, and to train this Q-network to predict total
reward.
We applied DQN to learn to play games on the Atari 2600 console. At each
time-step the agent observes the raw pixels on the screen, a reward signal
corresponding to the game score, and selects a joystick direction.
Demystifying AI algorithms
Reinforcement Learning Example
Q- Learning
Q(s1, a12) = r(s1,a12) + 0.5 (Max (s2, a21), (s2,a23), (s2, a25))
Q(s2, a25) = r(s2,a25) + 0.5 (Max (s5,a52), (s5,a54), (s5, a56));
Q(s5, a52) = r(s5, a52) + 0.5(Max(s2, a21), (s2,a23), (s2,a25))
Q(s2, a23) = r(s2,a23) + 0.5 (Max (s3,a36), (s3,a32));
Q(s3, a36) = r(s3, a36) = 100
-----------------------------------------------------
Q(s3, a36) = r(s3, a36) = 100
Q(s2, a23) = r(s2,a23) + 0.5 (Max (s3,a36), (s3,a32));
Q(s2, a23) = 0 + 0.5( Max (100,0)) = 50
Q(s5, a52) = r(s5, a52) + 0.5(Max(s2, a21), (s2,a23), Q(s2, a25) = r(s2,a25) + 0.5 (Max
(s2,a25)) (s5,a52), (s5,a54), (s5, a56));
Q(s5, a52) = 0 + 0.5(Max (50,0)) = 25 Q(s2, a25) = 0 + 0.5( Max(25, 0,0)) = 12.5;
Q(s1, a12) = r(s1,a12) + 0.5 (Max (s2, a21),
(s2,a23), (s2, a25))
Q(s1, a12) = 0 + 0.5(Max (0, 0,12.5)) = 6.25
Demystifying AI algorithms
Reinforcement Learning Algorithm
• 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.
Knowledge Base
Stores all relevant information, data, rules, cases, and
relationships used by the expert system.
Uses
•Rules
•If-then Statements
•Fuzzy Logic
Inference Engine
Seeks information and relationships from the knowledge
base and provides answers, predictions, and suggestions
the way a human expert would.
Uses
•Backward Chaining
•Forward Chaining
Architecture of Expert Systems
Explanation Facility
Allows a user to understand how the expert system arrived at certain conclusions or results.
For example: it allows a doctor to find out the logic or rationale of the diagnosis made by a medical expert
system
User Interface
Specialized user interface software employed for designing, creating, updating, and using expert
systems.
The main purpose of the user interface is to make the development and use of an expert system easier
for users and decision makers
General Methods of Inferencing
• Forward chaining (data-driven)– reasoning from facts to the conclusions
resulting from those facts – best for prognosis, monitoring, and control.
– Examples: CLIPS, OPS5
• Programs
• Both human experts and expert systems must be able to deal with
uncertainty.
• It is easier to program expert systems with shallow knowledge
than with deep knowledge.
• Shallow knowledge – based on empirical and heuristic
knowledge.
• Deep knowledge – based on basic structure, function, and
behavior of objects.
Early Expert Systems
•MYCIN was a stand alone system that required a user to enter all relevant
information about a patient by typing in responses to questions MYCIN posed.
•MYCIN operated using a fairly simple inference engine, and a knowledge base of
~600 rules.
•It would query the physician running the program via along series of simple yes/no
or textual questions.
Tasks and Domain
•Disease DIAGNOSIS and Therapy SELECTION
• Given a customer's purchase order, XCON determines substitutions and additions to make the order
consistent and produces a number of diagrams showing the spatial and logical relationships among the
components.
• The decisions to be made concern component types and properties, placement of components into boxes
and cabinets, electrical connections among components, etc.
• XCON is a very large rule-based system. It currently contains more than 6200 rules which draw on a
database of approximately 20,000 parts. Furthermore, each year about half of the rules are expected to
change.
• XCON is used to configure customer orders and to guide the assembly of these orders at the customer site.
Using the customer order as input, it provides the following functionality:
• Configures CPUs, memory, cabinets, power supplies, disk, tapes and so on.
• Determines and list cabling information.
• List components ordered with configuration related comments.
• Generate warning messages on issues affecting technical validity.
XCON: Expert Configurer