MI - Unit 1
MI - Unit 1
Unit –I –Session 1
CO2: Apply inference rules to the given knowledge base for theorem proving
CO3: Utilize regression and classification algorithms for data modeling and
prediction
CO4: Model data classification using tree based methods and support vector
machines for solving multi class problems
T1. Stuart Russell, Peter Norvig, “Artificial Intelligence– A modern Approach”, 3rd
Edition,Pearson Education,2014.
T2. James G, Witten D, Hastie T and Tibshirani R, “An Introduction to Statistical Learning
with Applications in R”, Springer,2013.
Reference Books:
Topic • Foundation
AI - Introduction
Artificial Intelligence ?
• Total Turing Test – Includes the video signal so that the interrogator can
test the subjects perceptual abilities
• Computer Vision
• Robotics
Thinking Rationally – Laws of Thought
• Logic Based
• Advantages:
1) More general
• Artificial Intelligence
• Intelligence
• What’s involved in Intelligence?
• What is Intelligent Behavior ?
• Definitions of Artificial Intelligence
• The Foundations of AI
Intelligent Agents
An agent:
• A human agent has eyes, ears, and other organs for sensors and hands, legs,
vocal tract, and so on for actuators.
Robotic agent
• A robotic agent might have cameras and infrared range finders for sensors
and various motors for actuators.
Software agent
• Rational Agent – is one that acts so as to achieve the best outcome or the best
expected outcome. A rational agent is one that does the right thing
Agents and Environment
Agen
Percept
t Sensors s
Environment
?
Actions
Actuato
rs
Agents and Environment
• Percept – Agent’s Perceptual input at any given time
• Rational Agent – Right action is the one that make the agent to be more
successful
• An omniscient agent knows the actual outcome of its actions and can
act accordingly -omniscience is impossible in reality.
• Example: Maze
Environment types
• Static • Dynamic
• The environment is • The environment may change
over time
unchanged while an agent is
• Example: Taxi driving
deliberating.
• Example: Crossword
puzzle
Environment types
• Discrete
• Continuous
• The environment consists of
• The environment in which the
a finite number of actions
action performed cannot be
that can be deliberated in the
numbered ie. is not discrete
environment to obtain the
• Example: Self driving cars
output.
• Example: Chess
Environment types
• Known
• Unknown
• In a known environment, the
• In a Unknown environment, the
outcomes for all actions are
agent needs to know how it works
known to the agent.
in order to perform an action
• Example: Card game
• Example: A new video game
Properties of task environments
to actions
[ B , Clean] Left
return action
[B ,Dirty] Suck
[ A, Clean], [ A, Right
Clean]
[ A, Clean], [ A, Dirty] Suck
.
.
.
[ A, Clean], [ A, Right
Clean],[A, Clean]
[ A, Clean], [ A, Suck
Clean],[A, Dirty]
Agent Types
• Reactive: No memory
• Works based on the current percept-
Action depends only on immediate
percepts.
• Ignores the previous percept
history
• Implement by condition-action
rules
• E.g. If car in front is braking
then initiate braking
Simple Reflex Agents
function SIMPLE-REFLEX-AGENT(percept) returns an action
persistent: rules, a set of condition-action rules
state INTERPRET-INPUT(percept)
rule RULE-MATCH(state, rules)
action rule.ACTION
return action
Problems faced
• Very limited intelligence
• No knowledge about the non perceptual parts of the state
• Operating in a partially observable environment infinite loops are
unavoidable Ex: car in front is braking
• we need some information about how the world evolves independently of the
agent: Overtaking car
• we need some information about how the agent's own actions affect the world:
steering wheel clockwise
Model Based Reflex Agents
desired state
• Example:
•Agent: robot maid
•Environment: house & people.
•Goals: clean clothes, tidy room, table
laid, etc
Utility Based Agents
• Similar to goal based agent but provide
an extra component of utility
measurement which makes them
different by providing a measure of
success at a given state
• It acts based not only goals but also the
best way to achieve the goal
• It is useful when there are multiple
possible alternatives and an agent has
to choose in order to perform the best
action
• The utility function maps each state to
a real number to check how efficiently
Example
each action
Many achieves
action the goals
sequences get taxi to destination
Consider other things. How fast, how safe…..
Learning agents
• The initial state that the agent starts in. For example, the initial
state for our agent in Romania might be described as In(Arad).
• A description of the possible actions available to the agent. For
example, from the state In(Arad), the applicable actions are
• States: The state is determined by both the agent location and the dirt
locations. There are 2 x 22 = 8 world states . In general for n locations
• Actions: each state has just three actions: Left, Right, and Suck.
• Goal Test: This checks whether all the squares are clean
• Path cost: Each step costs 1, so the path cost is the number of steps in the
path
Measuring problem solving performance
Measuring problem solving performance
• The actions one takes to travel from Arad to Bucharest along the shortest
(in time) path
Romania
• estimate of "desirability"
• A* search
Heuristic Function
• Worst case Time and space complexity is O(bm), but a good heuristic can give
dramatic improvement
• Optimal? No
A* Search
A* search
Open List:
Arad
We start with our initial state Arad. We make a node and add it to the open
list. Since it’s the only thing on the open list, we expand the node.
Think of the open list as a priority queue (or heap) that sorts the nodes
inside of it according to their g()+h() score.
A* search example
Open List:
Sibiu
Timisoara
Zerind
Open List:
Rimricu Vicea
Fagaras
Timisoara
We’ve been to
Zerind
Arad before.
Arad Don’t list it
again on the
Oradea open list.
When we expand Sibiu, we run into Arad again. But we’ve already
expanded this node once; so, we don’t add it to the open list again.
A* search example
Open List:
Rimricu Vicea
Fagaras
Timisoara
Zerind
Oradea
We see that Rimricu Vicea is at the top of the open list; so, it’s the next
node we will expand.
A* search example
Open List:
Fagaras
Pitesti
Timisoara
Zerind
Craiova
Sibiu
Oradea
Open List:
Fagaras
Pitesti
Timisoara
Zerind
Craiova
Oradea
Fagaras will be the next node we should expand – it’s at the top of the
sorted open list.
A* search example
Open List:
Pitesti
Timisoara
Zerind
Bucharest
Craiova
Sibiu
Oradea
When we expand Fagaras, we find Sibiu again. We don’t add it to the open
list.
We also find Bucharest, but we’re not done. The algorithm doesn’t end
until we “expand” the goal node – it has to be at the top of the open list.
A* search example
Open List:
Pitesti
Timisoara
Zerind
Bucharest
Craiova
Oradea
Open List:
Bucharest
Timisoara
Zerind
Craiova
Rimricu Vicea
Oradea
We just found a better value for Bucharest; so, it got moved higher in the
list. We also found a worse value for Craiova – we just ignore this.
And of course, we ran into Rimricu Vicea again. Since it’s already been
expanded once, we don’t re-add it to the Open List.
A* search example
Open List:
Bucharest
Timisoara
Zerind
Craiova
Oradea
• Complete? Yes (unless there are infinitely many nodes with f ≤ f(G) , i.e. step-
cost > ε)
• Time/Space? Exponential: bd
| h(n) h * (n) |O (logh * (n))
except if:
• Optimal? Yes
• h = number of pairs of queens that are attacking each other, either directly or indirectly
• However…
• For 8-queens
• However….
• Stochastic hill-climbing
• The selection probability can vary with the steepness of the uphill
move.
• First-choice hill-climbing
• Random-restart hill-climbing
• It conducts a series of hill-climbing searches from randomly generated
initial states
• A Physical Analogy:
• imagine letting a ball roll downhill on the function surface
• this is like hill-climbing (for minimization)
• now imagine shaking the surface, while the ball rolls, gradually
reducing the amount of shaking
• this is like simulated annealing
• Annealing = physical process of cooling a liquid or metal until particles
achieve a certain frozen crystal state
• simulated annealing:
• free variables are like particles
• seek “low energy” (high quality) configuration
• get this by slowly reducing temperature T, which particles
move around randomly
Search using Simulated Annealing
• Simulated Annealing = hill-climbing with non-deterministic search
• Basic ideas:
• like hill-climbing identify the quality of the local improvements
• instead of picking the best move, pick one randomly
• say the change in objective function is d
• if d is positive, then move to that state
• otherwise:
• move to this state with probability proportional to d
• thus: worse moves (very large negative d) are executed less often
• however, there is always a chance of escaping from local maxima
• over time, make it less likely to accept locally bad moves
• (Can also make the size of the move random as well, i.e., allow “large”
steps in state space)
Properties of simulated annealing search
Fitness function: number of non-attacking pairs of queens (min = 0, max = 8 × 7/2 = 28)
24/(24+23+20+11) = 31%
23/(24+23+20+11) = 29% etc
Genetic algorithms
Cross over
variable Xi
• Assignment problems
• e.g., who teaches what class
• Timetabling problems
• e.g., which class is offered when and where?
• Transportation scheduling
• Factory scheduling
• Notice that many real-world problems involve real-valued
variables
• Optimization search methods – Local Search CSP
Inference in CSP
Inference in CSP
• In CSPs there is a choice: an algorithm can search or do a specific type
of inference called constraint propagation
• using the constraints to reduce the number of legal values for a
variable, which in turn can reduce the legal values for another
variable, and so on
• It may be done as a preprocessing step, before search starts
• Different types of local consistency
• Node consistency
• Arc consistency
• Path consistency
• K-consistency
• Global constraints
Node consistency
varSelect_Unassigned_Variable(Variables[csp],assignment, csp)
• Idea:
• Keep track of remaining legal values for unassigned
variables
• Terminate search when any variable has no legal values
Forward checking
Forward checking
Forward checking
Domains
After WA
After Q
After V
Constraint propagation
• Forward checking propagates information from assigned to
unassigned variables, but doesn't provide early detection for all
failures:
• Intelligent Backtracking
• Normally chronological backtracking – when a branch of
search fails – back up to the preceding variable and try a
diff. value for it
• Variable ordering Q,NSW,V,T,SA,WA,NT
• Assignment
{ Q=RED,NSW=GREEN,V=BLUE,T=RED}
Next SA –any value violates constraint
Backtracking – value of T to be changed –it cannot resolve
• A more intelligent approach to backtrack to all the way
back to one of the set of variables that caused the failure –
Conflict set-set of previously assigned variables that are
connected to x by constraint
• For SA conflict set { Q,NSW,V}
• Backjumping method backtracks to the most recent
variable in the conflict set jumps to V
• Can be added to forward checking
• Called “ Conflict Directed backjumping”
Reference(s):