Professional Documents
Culture Documents
&
Machineth
Learning
5 Semester
CSE, 21CS54
Bhaktavatsala Shivaram
Adjunct Faculty
21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 2
21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 3
21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 4
21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 5
21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 6
21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 7
Module 2
Informed Search Strategies
• Greedy best-first search
• A* search
• Heuristic function
Machine Learning
• Introduction
• Understanding Data
S
e
a
r
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 13
Model 2: Informed Search Strategies – Greedy Best First Search
G Greedy Search Example1
r
e A 75 f(n) = h(n) = straight Open Closed
118 B
e 140 Line distance heuristic 1. [A] []
d [A]
C 2. [E,C,B]
y E
111
99 3. [F,G,C,B] [A, E]
B D 80
F 4. [I,G,C,B] [A, E, F]
e
G
s 211 5. [E,B,D] [A, E, F, I]
97
t
H 101
S I Traverse Path = A -> E -> F-> I
e Distance (A-E-F-I) =253+178+0 = 431
a
r
Path Cost (A-E-F-I) =140+99+211 = 450
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 14
Model 2: Informed Search Strategies – Greedy Best First Search
G Greedy Search Example2
r
e A 75 f(n) = h(n) = straight Open Closed
118 B
e 140 Line distance heuristic 1. [A] []
d [A]
C 2. [C,E,B]
y E
111
99 3. [D,E,B] [A, C]
80 ** 220
B D
F
e
s G
211 INFINITE LOOP
97
t
H 101
S I
e
a
r
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 15
Model 2: Informed Search Strategies – Greedy Best First Search
G • Greedy best first search can start down an infinite path and never
r return to try other possibilities, it is incomplete
e
e • Because of its greediness the search makes choice that can lead to a
d dead end; then one backs up in the search tree to the deepest
y unexpanded node.
▪ Greedy best first search resembles depth-first search in the way it prefers to follow
B
a single path all the way to the goal, but will back up when it hits a dead end.
e
s ▪ The quality of the heuristic function determines the practical usability of greedy
t search
S
e
a
r
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 16
Model 2: Informed Search Strategies – Greedy Best First Search
G Greedy Search Example3
r
e A 7 Straight Line Distance Open Closed
11 D
e 14 Given (say): 1. [A] []
d B 18 A -> G = 40 2. [C,B,D] [A]
25
y C B -> G = 32
10 C -> G = 25 3. [F,E,B,D] [A, C]
15
8
B
F
D -> G = 35 4. [G,E,B,D] [A, C, F]
e E E -> G = 19
s 20 F -> G = 17 5. [E,B,D] [A, C, F, G]
9
t G -> G = 0
H 10 H -> G = 10
S G Traverse Path = A -> C -> F-> G
e Path Cost (A-C-F-G) = 14+10+20 = 44
a
r
Distance (A-C-F-G) = 40+19+17 = 66
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 17
Model 2: Informed Search Strategies – Greedy Best First Search
G Greedy Search Example4
r
e S Node (n) ->H(n) Open Closed
3
e 2
A -> 12 1. [S] []
d B -> 4 [S]
A B 2. [B,A]
y 4 C -> 7
1
3 1
D -> 3 3. [F,E,A] [S, B]
B E -> 8 4.
C E F [G,I,E,A] [S, B, F]
e D 5 F -> 2
2 3
s G -> 0 5. [I,E,A] [S, B, F, G]
t H -> 4
H I
G I -> 9
S Traverse Path = S -> B -> F-> G
S -> 13
e Path Cost (S-B-F-G) = 2+1+3 = 6
a
r
Distance (S-B-F-G) = 13+4+2+0 = 19
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 18
Model 2: Informed Search Strategies – Greedy Best First Search
G • Greedy search is not optimal
r
e
• Greedy search is incomplete without systematic checking of repeated
e states.
d • In the worst case, the Time and Space Complexity of Greedy Search
y
are both same = O (bm)
B
where b – branching factor and m – max path length
e
s
t
S
e
a
r
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 19
Model 2: Informed Search Strategies – Greedy Best First Search
G
Advantages: Disadvantages:
r
e • Simple and Easy to • Inaccurate Results
e
Implement • Local Optima
d
y • Fast and Efficient • Heuristic Function
• Low Memory Requirements • Lack of Completeness
B
• Flexible
e
s • Efficiency
t
S
e
a
r
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 20
Model 2: Informed Search Strategies – Greedy Best First Search
G Few applications of Greedy Best First Search
r
Pathfinding: used to find the shortest path between two points in a graph. It is used
e
in many applications such as video games, robotics, and navigation systems.
e
Machine Learning: used in machine learning algorithms to find the most promising
d
path through a search space.
y
Optimization: used to optimize the parameters of a system in order to achieve the
desired result.
B
Game AI: used in game AI to evaluate potential moves and chose the best one.
e
Navigation: used to navigate to find the shortest path between two locations.
s
Natural Language Processing: used in natural language processing tasks such as
t
language translation or speech recognition to generate the most likely sequence of
words.
S
Image Processing: used in image processing to segment image into regions of
e
interest.
a
r
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 21
Model 2: Informed Search Strategies – A*Search
A A* Search
*
Greedy Best First Search minimizes a heuristic h(n) which is an
S estimated cost from a current state n to the goal state
e Greedy Best First Search is efficient but it is not optimal and not
a complete
r
Uniform Cost Search minimizes the cost g(n) from the initial state to
c
h the current state n.
Uniform cost search is optimal and complete but not efficient
A* SEARCH:
It combines Greedy Best Search and Uniform Cost Search to
get an efficient algorithm which is complete and optimal.
H 101
I
H 101
[415] I
H 101
[415] I Traverse Path = A -> E -> G-> H->I
[418]
City A City B
(Start) (Goal)
20 Km 215 Km
R2
[215]
21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 34
Model 2: Heuristic Function
B
a
Types of Heuristic
c
k
Admissible Non-Admissible
g • Never overestimates the • Overestimates
r cost of reaching the goal • h(n) is always greater than
o
u
• H(n) is always less than or the actual cost of lowest
n equal to actual cost of cost path from node n to
d lowest cost path from goal
node n to goal
Machine Learning
• Introduction
• Understanding Data