Sri Raghavendra Educational Institutions Society (R)
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
www.skit.org.in
Title: Artificial Intelligence and Machine Learning
CO addressed: CO1
Course: B.E
Presented by: Prof. Imran Ulla Khan
Department: Computer Science and Engineering
2
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
Module-1
3
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
“The science and engineering of making intelligent machines, especially intelligent computer programs”.
4
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
There are some of the problems contained within AI.
1. Game Playing and theorem proving share the property that people who do them well are considered to be displaying intelligence.
2. Another important foray into AI is focused on Commonsense Reasoning. It includes reasoning about physical objects and their relationships to each other, as well as reasoning about actions and other consequences.
3. To investigate this sort of reasoning Nowell Shaw and Simon built the General Problem Solver (GPS) which they applied to several common sense tasks. But no attempt was made to create a program with a large amount of knowledge about a particular problem domain. Only quite simple tasks were selected.
5
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
6
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
7
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
8
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
Intelligence requires Knowledge - Knowledge possesses some less desirable properties including:
9
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
10
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
11
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
12
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
The algorithm consists of three actions:
1. MAKE2 which returns 5 if the center square is blank; otherwise it returns any blank non corner square, i.e. 2, 4, 6 or 8.
2. POSSWIN (p) returns 0 if player p cannot win on the next move and otherwise returns the number of the square that gives a winning move.
13
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
3. GO (n) makes a move to square n setting BOARD[n] to 3 or 5.
14
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
15
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
Problem - which can be caused for different reasons, and, if solvable, can usually be solved in a number of different ways, is defined in a number of different ways.
To build a system or to solve a particular problem we need to do four things.
1. Define the problem precisely. This definition must include precise specification of what the initial situation will be as well as what final situations constitute acceptable solutions to the problem
2. Analyze the problem
3. Isolate and represent the task knowledge that is necessary to solve the problem
4. Choose the best solving technique and apply it to the particular problem.
16
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
State space - is a set of legal positions, starting at the initial state, using the set of rules to move from one state to another and attempting to end up in a goal state
Methodology of State Space Approach
1. To represent a problem in structured form using different states
2. Identify the initial state
3. Identify the goal state
4. Determine the operator for the changing state
5. Represent the knowledge present in the problem in a convenient form
6. Start from the initial state and search a path to goal state
17
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
Problem is “You are given two jugs, a 4-litre one and a 3-litre one. One neither has any measuring markers on it. There is a pump that can be used to fill the jugs with water. How can you get exactly 2 litres of water into 4-litre jug?”
Solution:
State: (x, y)
– x = number of lts in 4 lts jug
– y = number of lts in 3 lts jug
x = 0, 1, 2, 3, or 4 y = 0, 1, 2, 3
18
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
19
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
It is a basic building block which describes the AI problem and also describes the method of searching the goal.
Its main components are:
o The first requirement of a goal control strategy is that it is cause motion; a control strategy that does not cause motion will never lead to a solution.
o The second requirement of a good control strategy is that it should be systematic.
20
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
iv. A rule applier: Production rule is like below
if(condition) then
consequence or action.
21
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
1. Represent the initial state of the problem
2. If the present state is the goal state then go to step 5 else go to step 3
3. Choose one of the rules that satisfy the present state, apply it and change the state to new state.
4. Go to Step 2
5. Print “Goal is reached ” and indicate the search path from initial state to goal state
6. Stop.
22
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
Based on the direction they can be
1. Forward Production System
2. Backward Production System
23
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
24
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
- In order to choose the most appropriate method (or a combination of methods) for a particular problem, it is necessary to analyze the problem along several key dimensions:
25
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
1. Create a variable called NODE_LIST and set it to the initial state.
2. Until a goal state is found or NODE_LIST is empty:
a. Remove the first element from NODE_LIST and call it E. If NODE_LIST was empty, quit.
b. For each way that each rule can match the state described in E do:
i. Apply the rule to generate a new state.
ii. If the new state is a goal state, quit and return this state.
iii. Otherwise, add the new state to the end of NODE_LIST
26
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
Disadvantages of BFS:
1. All of the connected vertices must be stored in memory. So consumes more memory
27
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
1. If the initial state is a goal state, quit and return success.
2. Otherwise, do the following until success or failure is signaled.
a. Generate successor, E of the initial state. If there are no more successors, signal failure.
b. Call Depth-First Search with E as the initial state.
c. If success is returned, signal success. Otherwise continue in this loop.
28
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
1. Consumes less memory
2. Finds the larger distant element(from initial state) in less time.
Disadvantages of DFS:
2. May get trapped in searching useless path.
29
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
• Uninformed search algorithms or Brute-force algorithms, search through the search space all possible candidates for the solution checking whether each candidate satisfies the problem’s statement.
• Informed search algorithms use heuristic functions that are specific to the problem, apply them to guide the search through the search space to try to reduce the amount of time spent in searching.
30
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
- Some prominent intelligent search algorithms are stated below
31
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
Step1: Place the starting node in the OPEN list.
Step 2: Check if the OPEN list is empty or not, if the list is empty then return failure and stops.
Step 3: Select the node from the OPEN list which has the smallest value of evaluation function (g+h), if node n is goal node then return success and stop, otherwise
Step 4: Expand node n and generate all of its successors, and put n into the closed list. For each successor n', check whether n' is already in the OPEN or CLOSED list, if not then compute evaluation function for n' and place into Open list.
Step 5: Else if node n' is already in OPEN and CLOSED, then it should be attached to the back pointer which reflects the lowest g(n') value.
Step 6: Return to Step 2.
32
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
Generate-and-test search algorithm is a very simple algorithm that guarantees to find a solution if done systematically and there exists a solution.
Algorithm:
1.Generate a possible solution.
2.Test to see if this is the expected solution.
3.If the solution has been found quit else go to step 1.
33
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
34
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
Types of Hill Climbing
2. Steepest-Ascent Hill climbing - It first examines all the neighboring nodes and then selects the node closest to the solution state as next node.
3. Stochastic hill climbing : It does not examine all the neighboring nodes before deciding which node to select. It just selects a neighboring node at random, and decides (based on the amount of improvement in that neighbor) whether to move to that neighbor or to examine another.
35
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
Step 1 : Evaluate the initial state. If it is a goal state then stop and return success. Otherwise, make initial state as current state.
Step 2 : Loop until the solution state is found or there are no new operators present which can be applied to current state.
a) Select a state that has not been yet applied to the current state and apply it to produce a new state.
b) Perform these to evaluate new state
i. If the current state is a goal state, then stop and return success.
ii. If it is better than the current state, then make it current state and proceed further.
iii. If it is not better than the current state, then continue in the loop until a solution is found.
Step 3 : Exit.
36
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
2. Loop until a solution is found or until a complete iteration produces no
change to current state:
a. Let SUCC be a state such that any possible successor of the current state will be better than SUCC.
b. For each operator that applies to the current state do:
i. Apply the operator and generate a new state.
ii. Evaluate the new state. If it is a goal state, then return it and quit. If not compare it to SUCC. If it is better, then set SUCC to this state. If it is not better, leave SUCC alone.
c. IF the SUCC is better than current state, then set current state to SUCC
37
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
38
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
- Hill climbing may fail to find a solution, Either algorithm may terminate by not finding a goal state, when the program has reached a local maximum, a plateau or a ridge
39
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
1. To overcome local maximum problem : Utilize backtracking technique. Maintain a list of visited states. If the search reaches an undesirable state, it can backtrack to the previous configuration and explore a new path.
2. To overcome plateaus : Make a big jump. Randomly select a state far away from current state. Chances are that we will land at a non-plateau region
3. To overcome Ridge : In this kind of obstacle, use two or more rules before testing. It implies moving in several directions at once
40
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
41
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
1. Start with OPEN containing just the initial state
2. Until a goal is found or there are no nodes left on OPEN do:
a. Pick the best node on OPEN
b. Generate its successors
c. For each successor do:
i. If it is not been generated before, evaluate it, add it to OPEN and record its parent.
ii. If it has been generated before, change the parent if this new path is better than the previous one. In that case update the cost of getting to this node and to any successors that this node may already have.
42
10/12/2023
/skit.org.in
(Approved by AICTE, Accredited by NAAC, Affiliated to VTU, Karnataka)
Sri Krishna Institute of Technology
1. Start with OPEN containing just the initial state
2. Until a goal is found or there are no nodes left on OPEN do:
a. Pick the best node on OPEN
b. Generate its successors
c. For each successor do:
i. If it is not been generated before, evaluate it, add it to OPEN and record its parent.
ii. If it has been generated before, change the parent if this new path is better than the previous one. In that case update the cost of getting to this node and to any successors that this node may already have.