Skip to content
Tutorials Center
My learning

Topics

Lesson 29 of 36 ยท Rule-based Expert Systems

Certainty Factors and Explanations

Handle uncertainty in rule-based expert systems with MYCIN-style certainty factors, combine evidence from several rules, and generate how and why explanations. Runnable Python.

Real knowledge is rarely certain. "If the patient has a fever and a cough, the illness is probably the flu" is a good rule, but "probably" is not "always". An expert system that can only say true or false would either overclaim or refuse to help. Two features make a system usable in the real world: a way to attach uncertainty to facts and rules, and a way to explain conclusions so users can trust or challenge them.

Certainty factors

The medical system MYCIN (1970s) introduced certainty factors (CF). A CF is a number from -1 to +1:

  • +1 means the fact is certainly true.
  • -1 means it is certainly false.
  • 0 means no evidence either way.

Both facts and rules carry a CF. A rule such as IF fever AND cough THEN flu (CF 0.7) says "if the conditions were certain, we would believe flu to degree 0.7".

Three formulas do all the work.

1. Evaluating a rule. The strength of the conditions is the minimum CF of the conditions joined by AND (the weakest link) or the maximum for OR. The conclusion's CF is that value multiplied by the rule's CF. (Evidence below zero does not trigger a rule; only conditions with CF above a small threshold such as 0.2 are normally used.)

TEXT
cf_conclusion = min(cf_conditions) * cf_rule

2. Combining two rules that support the same conclusion. For two certainty factors a and b on the same hypothesis:

TEXT
both positive:  a + b * (1 - a)
both negative:  a + b * (1 + a)
mixed signs:    (a + b) / (1 - min(|a|, |b|))

Two independent pieces of positive evidence push the belief up, but never past 1. Positive and negative evidence cancel partly.

Python Combining certainty factors

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Evidence of 0.6 and 0.5 combine to 0.8, higher than either, but below 1. The combination formula is commutative and associative, so the order in which the rules fire does not change the result.

Certainty factors

Range -1 false to +1 true
AND / OR min and max
Rule strength Multiply by rule CF
Combine a + b(1 - a)

More evidence, higher belief, never above 1

1 / 2

An uncertain diagnosis system

Below, several rules support three diseases with different strengths. Facts have CFs too (how sure we are the patient has a symptom). The engine evaluates all rules, combines evidence for each hypothesis and ranks the results.

Python Diagnosis with certainty factors

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

flu gets contributions from two rules (0.56 from R1 and 0.27 from R2) and ends up with the highest belief. measles is not listed because its only rule needs rash, which the user denied.

Explanation: how and why

An expert system that just prints "flu" is hard to trust. Two standard explanation questions are:

  • How? "How did you conclude flu?" The answer is the proof tree: which rules fired and from which facts.
  • Why? "Why are you asking me this question?" The answer is the rule that needs the answer (and the goal it serves).

To support them you record a trace while reasoning. Each trace entry stores the rule, the facts it used and the conclusion. The explanation facility then turns the trace into sentences.

Python A 'how' explanation from a trace

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Good explanations are short, use the user's vocabulary and show the evidence, not the machinery. When a result is surprising ("why is the loan refused?") the how-trace is also the way to find a wrong rule.

Certainty factors, probability and fuzzy logic

Certainty factors Probability Fuzzy membership
Meaning Degree of belief Chance of an event Degree of truth of a vague concept
Example "Probably flu (0.8)" "80% of such patients have flu" "Temperature is high (0.8)"
Needs data? Expert estimate Statistics Expert shape
Weakness Ad hoc; assumes independence Needs many numbers Not about chance

A CF of 0.8 is not an 80% probability. It is a convenient bookkeeping number that works surprisingly well when rules are roughly independent. Today many systems use Bayesian networks for chance and fuzzy sets for vague concepts, but certainty factors remain a simple and instructive tool.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. A rule has CF 0.8 and its conditions have CFs 0.9 and 0.5 joined by AND. What is the conclusion CF?

    AND takes the minimum condition CF (0.5), then multiplies by the rule CF: 0.5 x 0.8 = 0.4.
  2. 2. Two independent positive CFs 0.6 and 0.5 for the same hypothesis combine to...

    0.6 + 0.5 x (1 - 0.6) = 0.8.
  3. 3. What does a 'why' explanation tell the user?

    'Why' explains the purpose of a question; 'how' explains a conclusion.
  4. 4. Is a certainty factor of 0.8 the same as an 80% probability?

    CFs are not probabilities; they are an ad hoc but practical measure of belief.

Summary

  • Certainty factors run from -1 to +1 and attach to facts and rules.
  • AND = min, OR = max, conclusion = condition strength times rule CF.
  • Evidence for the same hypothesis combines with a + b(1 - a) (both positive), keeping the result below 1.
  • Record a trace to answer how and why questions and to debug the knowledge base.
  • CFs are not probabilities; fuzzy membership describes vagueness, not chance.

Next: Fuzzy Medical Diagnosis Support