# Lecture 2: CBR Case Retrieval

## Presentation on theme: "Lecture 2: CBR Case Retrieval"— Presentation transcript:

Lecture 2: CBR Case Retrieval
Case Based Reasoning Lecture 2: CBR Case Retrieval

Outline Case Representation Nearest Neighbour Retrieval
Calculating similarity Similarity in CBR-Works Reading

R4 Cycle CBR RETRIEVE RETAIN REUSE REVISE find similar problems
integrate in case-base CBR REUSE propose solutions from retrieved cases REVISE adapt and repair proposed solution

CBR Assumption New problem can be solved by
retrieving similar problems adapting retrieved solutions Similar problems have similar solutions P ? S X

Car Diagnosis Example Symptoms are observed Goal Engine does not start
Battery voltage = 7v Goal Cause of failure: flat battery Repair strategy: charge battery

Case-Based Diagnosis Case describes diagnostic situation
Description of symptoms Description of fault Description of repair strategy Case-base stores a collection of cases CBR finds case in case-base similar to new symptoms Re-uses diagnosis of fault repair strategy

Car Diagnosis Case Each case describes one diagnostic situation
Described by a list of features Contains a list of feature values Problem Symptom: headlight does not work Car: Ford Mondeo Year: 2001 Solution Diagnosis: headlight fuse blown Repair: replace headlight fuse This is not a rule - why not? Feature Value Battery: 10.4v Headlights: undamaged HeadlightSwitch: on Case 1

Car Diagnosis Case-Base
A collection of independent cases Problem Symptom: headlight does not work Car: Ford Mondeo Year: 2001 Solution Diagnosis: headlight fuse blown Repair: replace headlight fuse Car: Ford Ka Year: 2003 Diagnosis: defective bulb Repair: replace headlight Battery: 10.4v Headlights: undamaged HeadlightSwitch: on Battery: 9.5v Headlights: surface damage Case 1 Case 2

Case Representation Depends on problem domain Flat structure
A list of feature values (car diagnosis example) Easy to store and retrieve Specialised representations Graphs - nodes and arcs Plans - partially ordered set of actions Object-oriented - objects (instances of classes) More difficult to store and retrieve

Case Representation Object-oriented representation: A case is a set of objects An object is described by a set of features Classes are arranged in a hierarchy Relations between objects (e.g. part-of) Combine similarities of parts Car Brakes Engine Transmission Ignition System Fuel Injection Coil Spark Plug Colour: dark grey Gap: 1.2mm

New Car Diagnosis Problem
A new problem is a case without a solution part Not all problem features must be known same for cases Problem Symptom: brakelight does not work Car: Ford Fiesta Year: 1997 Battery: 9.2v Headlights: undamaged HeadlightSwitch: ? New Feature Value

Retrieving A Car Diagnosis Case
Compare new problem to each case Select most similar Similarity is most important concept in CBR When are two cases similar? How are cases ranked according to similarity? Similarity of cases Similarity for each feature Depends on feature values Case Case Case Similar? Case Case Case New Problem Case Case 1

Nearest Neighbour Retrieval
Retrieve most similar k-nearest neighbour (k-NN) like scoring in bowls or curling Example 5-NN 1-NN

Calculating Feature Similarity
Distances between values of individual features problem and case have values p and c for feature f Distance for Numeric features df(problem,case) = |p - c|/(max difference) Distance for Symbolic features df(problem,case) = 0 if p = c = 1 otherwise Similarityf(problem,case) = 1 - d Degree of similarity is between 0 and 1

Calculating Case Similarity
Similarity(problem,case) = weighted sum of Similarityf(problem,case) for all features f High importance features have large weight symptom, battery, headlights weight = 6 Low importance features have low weight car, year weight = 1 Case similarity = si is similarity of ith feature wi is weight of ith feature w1*s1 + w2 * s2 + …… + wn*sn w1 + w2 + …… + wn

New Problem and Case 1 Similarity(New, Case 1) =
Symptom: brakelight does not work Car: Ford Fiesta Year: 1997 Battery: 9.2v Headlights: undamaged HeadlightSwitch: ? weight = 6 1 Similarity Problem Symptom: headlight does not work Car: Ford Mondeo Year: 2001 Battery: 10.4v Headlights: undamaged HeadlightSwitch: on Solution Diagnosis: headlight fuse blown Repair: replace headlight fuse Case 1 0.8 0.6 1.0 0.9 Similarity(New, Case 1) = 6* * * * *1 = 17.4 / 20 = 0.87

New Problem and Case 2 Similarity(New, Case 2) =
Symptom: brakelight does not work Car: Ford Fiesta Year: 1997 Battery: 9.2v Headlights: undamaged HeadlightSwitch: ? weight = 6 1 Similarity Problem Symptom: headlight does not work Car: Ford Ka Year: 2003 Battery: 9.5v Headlights: surface damage HeadlightSwitch: on Solution Diagnosis: defective bulb Repair: replace headlight Case 2 0.8 0.0 0.975 0.4 Similarity(New, Case 2) = 6* * * * *0 = / 20 = 0.59

Reuse Solution from Case 1
Problem Symptom: headlight does not work Solution Diagnosis: headlight fuse blown Repair: replace headlight fuse Solution to New Problem After Adaptation Diagnosis: brakelight fuse blown Repair: replace brakelight fuse Case 1 New Problem Symptom: brakelight does not work Car: Ford Fiesta Year: 1997 Battery: 9.2v Headlights: undamaged HeadlightSwitch: ?

CBR-Works Similarity Calculation in tool used in the Lab
Unordered Symbols Ordered Symbols Numbers Intervals Strings Taxonomy

Symbols (Unordered) Similarity defined by developer
Similarity values stored in a decision table

Symmetric vs Asymmetric Similarity
In symmetric similarity the result is independent of the role of the values being compared Sim (amber, green) = 0.8 Sim (green, amber) = 0.8 In asymmetric similarity the role is important Sim (amber, green) = 0.3

Ordered Symbols The symbols are mapped to a numeric range
Colour Brightness Light Medium Dark 1.0 0.5 0.0

Numbers df(query,case) = |q - c|/range Similarityf(query,case) = 1 – d
Example: Query (New Problem): Mileage = 60,000 Case: Mileage = 50,000 Range (Mileage) = ,000 dMileage(query,case) = |60,000 – 50,000|/10, = 0.1 SimilarityMileage(query,case) = 1 – 0.1 = 0.9

Intervals if the intervals in query and case do not intersect the similarity is higher the closer the gap if the intervals intersect the similarity is higher the closer the bounds if the case completely covers the query the similarity is 1 if the query completely covers the case the similarity is higher the closer the bounds

Strings exact match: two strings are similar if they are spelled the same way spelling check: compares the number of letters which are the same in two strings (Useful for strings consisting of one word only) word-count: counts the number of matching words of two cases. (Useful for strings consisting of several words).

Taxonomy A classification hierarchy defines similarity for concepts
Inner nodes of the tree are assigned similarity values Leaves under a node will share the nodes similarity

Example from CBR-Works

Example from CBR-Works
dMileage(query,case1) = | |/(100000) =0.1 SMileage(query,case1) = 1 – 0.1 = 0.9 dTowbar(query,case1) = 0 STowbar(query,case1) = 1 – 0 = 1 S(query,case1) = ( ) / (1 + 1) = 0.95 Note that the missing values (?) do not contribute to the calculation