0% found this document useful (0 votes)
27 views20 pages

AI Lecture 12-b

The document discusses various concepts in artificial intelligence, including the application of algorithms like 3-Nearest Neighbor and decision trees for classification tasks. It also covers knowledge representation, types of agents, and the characteristics of different environments in AI. Additionally, it includes exercises and examples related to these topics.

Uploaded by

dekukunmc
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)
27 views20 pages

AI Lecture 12-b

The document discusses various concepts in artificial intelligence, including the application of algorithms like 3-Nearest Neighbor and decision trees for classification tasks. It also covers knowledge representation, types of agents, and the characteristics of different environments in AI. Additionally, it includes exercises and examples related to these topics.

Uploaded by

dekukunmc
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/ 20

ARTIFICIAL

INTELLIGENCE
DR. MANAL TANTAWI
ASSOCIATE PROFESSOR
IN
SCIENTIFIC COMPUTING DEPARTMENT
FACULTY OF COMPUTER & INFORMATION
SCIENCES
AIN SHAMS UNIVERSITY
PART 12-B

➢Revision
• REGARDING A DATASET OF FIVE EXAMPLES. EACH EXAMPLE IS REPRESENTED BY
TWO FEATURES (X1, X2) AS FOLLOWS :

Use 3-Nearest Neighbor to know the class of a X1 X2 Target Y


new input (2,2) using Euclidean distance 1 1 A
2 1 A
1. Compute Euclidean distance between new input and training 1 2 A
examples
3 4 B
Sqrt ( (2-1)2 + (2-1)2) = 1.414
Sqrt ( (2-2)2 + (2-1)2) = 1 3 3 B
Sqrt ( (2-1)2 + (2-2)2) = 1
Sqrt ( (2-3)2 + (2-4)2) = 2.23
Sqrt ( (2-3)2 + (2-3)2) = 1.414
Choose the nearest three examples
Vote for the winner class of these three
examples
The class will be A
The following dataset is used to train a decision tree to take a “yes” or “No” decision
based on three features A1, A2 and A3.Apply the decision tree algorithm to construct
the optimal possible tree using information gain. Show your calculations.

A1 A2 A3 Decision

F F F NO
F F T YES
F T F YES
F T T YES
T F F NO
T F T YES
T T F NO
• LOG SHOULD BE BASE 2
• 4 YES 3 NO TOTAL 7
ENTROPY (4+, 3-) = -4/7 LOG (4/7) – 3/7 LOG 3/7 =0.9851
FOR A3 => 0.9851 – 3/7 * 0 – 4/7 [ - ¾ LOG ¾ - ¼ LOG ¼ ]=
0.9851 – 0 – 0.4634 = 0.5221
FOR A2 => 0.9851- 4/7 (1) – 3/7 [ -2/3 LOG2/3 - 1/3 LOG 1/3] =
0.9851 – 0.5714 – 0.393 =0.0206
FOR A1 => 0.9851 – 4/7 [ - ¾ LOG ¾ - ¼ LOG ¼ ] -3/7 [ -2/3 LOG2/3 - 1/3 LOG 1/3]=
0.9851 - 0.463 - 0.393 = 0.1291
THE WINNER IS A3
• TOTAL 4 1 YES 3 NO
• ENTROPY (1+, 3-) =[-1/4 LOG ¼ - 3/4LOG ¾] =0.811
FOR A1 => 0.811 – 2/4 (0) – 2/4 (1) = 0.311
FOR A2 => 0.811 – 2/4 (1) – 2/4 (0) = 0.311
WE CAN TAKE A1 OR A2
LET’S TAKE A1

T F

T F
2) If an input is added to the training set with missing value for A3 as follows
A1 A2 A3 Decision
T T ? YES

Suggest a value T or F for A3 and show why you choose this value.

The value will be T because the value T for this


feature is YES for most cases
•Regarding a new continuous feature A4 is added to the dataset where binary splits
in the form of A4 < A versus A4 >= A are allowed. Find the optimum value for A.
Show your calculations. A1 A2 A3 A4 Decision
F F F 55 NO
F F T 40 YES
F T F 50 YES
F T T 30 YES
T F F 20 NO
T F T 45 YES
T T F 5 NO

5 20 30 40 45 50 55
No No Yes Yes Yes Yes No
Average for decision changing cases (20 + 30)/2 =25 (50 +55) /2 = 52.5
For A4>25 => 0.9851- 2/7 (0) – 5/7 [ -4/5 log 4/5 – 1/5 log 1/5]= 0.469
For A4 > 52.5 => 0.9851- 1/7 (0) – 6/7 [ -4/6 log 4/6 – 2/6 log 2/6]= 0.198
The optimum value of d is 25 (better information gain)
THE FOLLOWING TABLE CONTAINS DATA ABOUT ANIMALS IF THEY ARE MAMMALS OR
NOT AND THE CORRESPONDING FULL DECISION TREE IS GIVEN. APPLY THE POST-
PRUNING ALGORITHM TO SHOW IF THE TREE IS OPTIMUM OR NOT
( LET LAMBDA = 0.03)
• COST FUNCTION = 0 + 0.03 (4) =0.12

Cost function for smaller tree =


0.2 + 0.03 (3) = 0.29

X no pruning needed it is optimum

Mammals
Regarding a dataset of seven examples. Each example is represented by two features (A, B)
as follows:

Consider applying K means algorithm to know the optimum position for the center of two clusters C1 and C2,
show the calculations for the first iteration.
COMPLETE THE FOLLOWING SENTENCES:

1) ………………… provides the necessary information, facts, while …………. is the ability to learn, reason,
and adapt, using knowledge to perform tasks and solve complex problems.
2) “ sky is clear” is example for ………………… knowledge.
3) ………………. is knowing when to use a specific algorithm based on the problem at hand.
4) ……………… is a popular programming language that utilizes propositional and predicate logic to
represent knowledge.
5) Regarding knowledge representation approaches, ……………………representation are data structures
that encapsulate knowledge about objects, situations, or events in a structured format. On the other hand,
……………….. represent knowledge in the form of graphical networks.
6) ……………....... express knowledge in the form of conditions and corresponding actions. They are a key
component of rule-based systems.
7) The ………….. is known as the brain of the expert system as it is the main processing unit of the system.
8) …………… based expert systems don’t learn and can easily suffer from overfitting.
9) ……………… means low train error and high-test error.
10) ……………… data set used to avoid overfitting. The inference engine is known as the brain of the
expert system as it is the main processing unit of the system.
COMPLETE THE FOLLOWING SENTENCES:

1. Knowledge provides the necessary information, facts, while intelligence is the ability to learn, reason, and
adapt, using knowledge to perform tasks and solve complex problems.
2. “ sky is clear” is example for declarative knowledge.
3. Meta knowledge is knowing when to use a specific algorithm based on the problem at hand.
4. Prolog is a popular programming language that utilizes propositional and predicate logic to represent
knowledge.
5. Regarding knowledge representation approaches, Frames representation are data structures that
encapsulate knowledge about objects, situations, or events in a structured format. On the other hand,
semantic networks represent knowledge in the form of graphical networks.
6. Production rules express knowledge in the form of conditions and corresponding actions. They are a key
component of rule-based systems.
7. The inference engine is known as the brain of the expert system as it is the main processing unit of the
system.
8. rules based expert systems don’t learn and can easily suffer from overfitting.
9. overfitting means low train error and high-test error.
10. validation data set used to avoid overfitting.
COMPLETE THE FOLLOWING SENTENCES:

11) ………….. is partially observable environment, while ………………. Is fully observable environment.
12) If the next state of the environment is completely determined by the current state and the action executed
by the agent, then we say the environment is …………..; otherwise, it is …………..
COMPLETE THE FOLLOWING SENTENCES:

11) Taxi driving is partially observable environment, while crossword puzzle Is fully observable environment.
12) If the next state of the environment is completely determined by the current state and the action executed
by the agent, then we say the environment is deterministic; otherwise, it is stochastic.
CHOOSE THE CORRECT ANSWER
1) Video games are example for ……….. Agent
a) Simple reflex
b) Utility based
c) Goal based
d) Hierarchical based

2) …………. agent recommends songs based on how likely you are to click on it.
a) Simple reflex
b) Utility based
c) Goal based
d) Hierarchical based

3) ……………….. Is fully observable environment, single agent, deterministic, sequential, static, and discrete.
a) Poker
b) Crossword puzzle
c) Backgammon
d) Chess
CHOOSE THE CORRECT ANSWER
1) Video games are example for ……….. Agent
a) Simple reflex
b) Utility based
c) Goal based
d) Hierarchical based

2) …………. agent recommends songs based on how likely you are to click on it.
a) Simple reflex
b) Utility based
c) Goal based
d) Hierarchical based

3) ……………….. Is fully observable environment, single agent, deterministic, sequential, static, and discrete.
a) Poker
b) Crossword puzzle
c) Backgammon
d) Chess
THANK YOU

You might also like