Ch. 02 - Rule-Based Expert Systems
Ch. 02 - Rule-Based Expert Systems
Expert Systems
2
1. Understanding Rule-
Based Systems (Forward
and Backward Chaining)
Rule-based expert systems use "rules"
to make decisions based on data. They
often employ two main inference
methods:
1. Forward Chaining
2. Backward Chaining
3
Forward Chaining
What is Forward Chaining?
4
Backward Chaining
What is Backward Chaining?
5
Forward vs. Backward Chaining
6
Forward Chaining in MYCIN - Theory
7
Forward Chaining in MYCIN - Theory
1. Begin with Patient Data: MYCIN starts with known symptoms and lab results.
2. Apply Rules: It checks if each rule’s conditions match the known data.
3. Generate New Facts: When a rule is satisfied, MYCIN infers a new fact.
5. Repeat Process: Newly inferred facts trigger more rules, creating a chain of
inferences.
8
Examples
Implementing a forward-chaining system focused on
diagnosing COVID-19 based on common symptoms.
9
Examples
Implementing a forward-chaining system focused on
diagnosing COVID-19 based on common symptoms.
10
2. Backward Chaining - Theory
and Use Cases
Backward Chaining is a goal-driven inference method in which
the system starts with a hypothesis (goal) and works backward to
determine if existing data supports it. It checks the rules and
searches for conditions that could confirm the goal, then evaluates
if those conditions are met by known facts.
11
Use Cases
Unlike forward contact tracing, backward contact tracing
identifies the source of newly detected cases.
• Medical Diagnosis: Begins with a suspected disease and works
backward through symptoms and test results to confirm it.
12
Use Cases
Unlike forward contact tracing, backward contact tracing
identifies the source of newly detected cases.
13
Introduction to Backward Chaining in MYCIN
14
Theory of Backward Chaining
• The system checks rules that would achieve the goal and attempts to
satisfy the conditions of these rules by searching for supporting data.
15
Example of Backward Chaining
16
Example of Backward Chaining
Result:
17
3. Practical Exercise
Implement an expert medical system, is trying to determine if a patient
has pneumonia by using backward chaining.
System could diagnoses pneumonia as below:
1. Pneumonia diagnosis requires:
• Cough
• Chest pain
2. Cough is confirmed if:
• The patient has a persistent cough
3. Chest pain is confirmed if:
• The patient experiences sharp pain when breathing
Given: The patient reports persistent cough and sharp pain when
breathing.
18
Solution:
19
Solution:
20
Homework:
Create a backward-chaining expert system that can diagnose multiple
conditions based on user-input symptoms. Use the following
conditions:
5. Chest Pain is confirmed if:
1. Pneumonia requires: • Sharp Pain when Breathing
• Cough and Chest Pain 6. Sneezing is confirmed if:
2. Cold requires: • Frequent Sneezing
• Sneezing and Runny Nose 7. Runny Nose is confirmed if:
3. Flu requires: • Nasal Congestion
• Fever and Body Aches 8. Fever is confirmed if:
4. Cough is confirmed if: • Temperature above 100°F
• Persistent Cough 9. Body Aches are confirmed if:
• Muscle Pain
21
Homework:
Tasks:
1. Implement the system using backward
chaining to confirm a diagnosis based on
symptoms entered by the user.
2. Ensure the system can confirm multiple
conditions based on the symptoms
provided in each session.
3. Use while True to continuously gather
symptoms until the user decides to stop.
22
Homework:
Questions:
1. How does backward chaining help in
narrowing down the possible diagnoses
based on user input?
2. Explain the output of the program when
the user inputs symptoms for both a Cold
and Flu.
3. How would you modify the system to give
a confidence score for each diagnosis?
23
Thank You
SEK SocheaT
socheatsek@norton-u.com