rule based representation
play

Rule based representation M Sasikumar 1 Overview Background - PowerPoint PPT Presentation

Rule based representation M Sasikumar 1 Overview Background What/Why RBR Forms of rules Uncertainty Certainty factor Issues 2 Sasikumar M, IIT Bombay Background One of the most well known representation mechanisms.


  1. Rule based representation M Sasikumar 1

  2. Overview ● Background ● What/Why RBR ● Forms of rules ● Uncertainty – Certainty factor ● Issues 2 Sasikumar M, IIT Bombay

  3. Background ● One of the most well known representation mechanisms. – Model for how human brain works?! ● Easy to externalise and interpret. ● Good inferencing mechanisms. ● Theoretical basis available to some extent. 3 Sasikumar M, IIT Bombay

  4. What is a rule ● If arrival time > 9.30 and arrival time < 10.00 then insert casual_leave(0.5) ● If symptoms include headache and headache_duration > 7 days and fever not present then investigate disease_x ● If value_1 > value_2 and ans = value_2- value_1 then misconception = order_problem 4 Sasikumar M, IIT Bombay

  5. Form of a rule ● If <condition> then <conclusion> ● If <condition> is known to be true then <conclusion> can be claimed to hold ● Many variations possible on this format. ● Very popular with expert systems literature. – Can be used for capturing domain knowledge and student/tutor models in ATS. 5 Sasikumar M, IIT Bombay

  6. Why rules? ● They can be read like English (usually!). ● And hence with minor rewrite makes sense to the user. ● (Usually) rules are independent of each other. – Can insert and delete without worrying about other rules (!) – No control flow embedded. ● Can be built from outside 6 Sasikumar M, IIT Bombay

  7. Using rules ● Choose a rule whose conditions match with the current problem state, and perform the action. – Forward chaining ● Set a goal. Choose a rule whose conclusion matches with our goal, and check if the conditions can be made true. – Each condition becomes a sub-goal – Backward chaining ● Can mix them in a system. 7 Sasikumar M, IIT Bombay

  8. Using rules Rule Rule Base Interpreter Working Memory 8 Sasikumar M, IIT Bombay

  9. Using rules... ● What if there are multiple rules that match? ● Some sense of priority to be used – Rule order in the system – Manually assigned priority numbers – Specificity ● If A and B then C1 ● If A then C2 – Semantic analysis of the candidates ● Who uses what parameters, dependencies, etc 9 Sasikumar M, IIT Bombay

  10. Forms of rules ● Around the basic theme, many variations proposed and used. ● Variation on – Structure of a condition – Combining conditions in to a rule – Structure of conclusion – Multiple conclusions – Annotations 10 Sasikumar M, IIT Bombay

  11. Condition ● Matches with information collected in the working memory. ● Model-1: atomic condition – heavy_rain, take_umbrella, top_higher_than_bottom ● Model-2: attribute operator value – Age > 40, fever is true, current_column is “col1” – What kind of operators, and their meaning? ● Model-3: value can also be an attribute – Top > bottom ● Model-4: add context also – P1.age > 40, thisvisit.fever is true, column1.top > column1.bottom 11 Sasikumar M, IIT Bombay

  12. … ● More logic based formations – Richer operations in the form of predicates – severe(P,pain_intensity) and high(bloodpressure,P) – parent(P,P1), cardiac(P1) → ● Richer operations (e.g. OPS5) – (student ^age >40 ^name “%iar”) – ((student ^name n1 ^mark m), -(student ^name n2 ^mark >m)) → (winner ^name n1) – 12 Sasikumar M, IIT Bombay

  13. Combining conditions ● Single condition is too restrictive ● Conjunction supported by most – If A and B then …. ● Disjunction also possible. – If A or B then … – Can be done by two separate rules. ● Negation permitted with some restriction – Negation may raise semantic problems – student(X) and not passed(X,s1) – not student(X) 13 Sasikumar M, IIT Bombay

  14. Structure of conclusion ● Purpose – Just infer something is true or false ● Disease includes meningitis – Compute something ● Increase severity by 0.4 ● No side effect... – Perform an action ● Display message 13 ● Side effects? ● Multiple pieces – Conjunction (usual meaning) – Disjunction ● Complexities of managing multiple paths 14 Sasikumar M, IIT Bombay

  15. Annotations ● A number of annotations can add value to the simple rule structure. ● Rule groups are often used to manage interactions and provide structure. ● Rule ID, and priority tags. ● Attributes can be linked to ontologies. ● Applicability context as annotation vs as additional clauses (Guidon story). ● Translation mappings for display, etc. 15 Sasikumar M, IIT Bombay

  16. Explaining with rules ● Keeping track of which rules were used when, we can produce meaningful traces to user. ● is(fever,true), less(age,40), is(headache,false) => set(disease,abc) ● If fever is true and age less 40 and headache is false then infer that disease is abc ● If patient has fever and his age is less than 40 and he is not having head ache, then it is possible he may be having abc disease. ● …. 16 Sasikumar M, IIT Bombay

  17. …. ● Attach translation to attributes, operators, conclusions, and so on. ● Translation can be simple mapping, or contextual mapping. ● Possible to generate fairly good readable paraphrasing of the rule automatically. ● Similarly, the control structure can also be translated... 17 Sasikumar M, IIT Bombay

  18. …. ● Where are you? Why do you want to know? – I am trying to check if you have disease abc, and there is a rule R1 which can be used for this. I am verifying its conditions. ● How did you know... – This information was provided by you earlier for my question … – This information was arrived at from rules r1, r14, and r20. 18 Sasikumar M, IIT Bombay

  19. Rules in an uncertain world.. ● Symptom disease mapping, behaviour error mapping, etc usually not fully certain. ● Uncertainty part of life in these cases. ● Rules need to factor this in. ● Certainty factor based model is common. ● Probability based systems, fuzzy rules etc also used. 19 Sasikumar M, IIT Bombay

  20. Certainty factor in rules ● If A then B with confidence cf ● What does cf mean? – Maximum confidence B can get from here ● A itself may be uncertain – Should reflect in the confidence of B ● Multiple rules may suggest B – Some way to aggregate support from multiple sources. 20 Sasikumar M, IIT Bombay

  21. Certainty factor ● A bounded number: 0 to 1, -1 to 1, 0 to 100, etc – -1 to +1: negative indicates false, positive indicates true. – 0 to 1: rules of probability can be used. ● Increasing CF means increasing belief in its truth, and reverse for decrease. 21 Sasikumar M, IIT Bombay

  22. CF calculus If A then B with CF=x1. A has CF = y1. ------------------------ CF of B (b1) = x1 * y1 If C then B with CF= x2. B gets CF = b2 Net: b1+b2? b1+b2*(1-b1)? max(b1,b2)? etc 22 Sasikumar M, IIT Bombay

  23. The rule! ● If a1 and a2 or a3 then c1 and c2 with confidence cf1 and cf2 respectively, priority class B. ● Various syntactic frameworks possible – Usually well delimited to make parsing easy – OPS-5 rich production rules ● Almost like a programming language – Prolog format ● Logic programming model 23 Sasikumar M, IIT Bombay

  24. The rule Context: col = 1, top = 5, bottom = 3, ans = ?, carry = ? current_focus(col) and greater(top, bottom) and first_column(col) => ans = top – bottom, carry = 0 (rule (and ( current_focus ^col) ( values ^col ^top ^bottom) (> ^top ^bottom) ( first_column ^col)) (insert (result ^col (- ^top ^bottom) /* ans */ 0 /* carry */)) 24 Sasikumar M, IIT Bombay

  25. …. In a procedural language, this could be: get_values(current_focus, &top, &bot); if (top > bot) && (current_focus == 1) ans = top – bottom; carry = 0; set_values(current_focus, top, bot, ans, carry); current_focus++; 25 Sasikumar M, IIT Bombay

  26. Rules in ATS ● Rules as knowledge units provide a lot of flexibility. ● Useful for domain model, student model and tutor model. ● Eg.: can build student model around this. – Does he know rule x? ● The simple and uniform structure facilitates – Malrules, error diagnosis, corrective action, etc 26 Sasikumar M, IIT Bombay

  27. More on rules ● Store rules externally, and build a parser to build an internal representation. – For languages like python, can do as part of program itself! ● Sample python rulebase: rules = { "r1":([("age",">",40),("fever","is","true")], ("disease","abc")), "r2":(2,2), "r3":(3,3) } ● Dictionary → tuple → list → tuple ● Inspectable, and executable. 27 Sasikumar M, IIT Bombay

  28. …. def display(rid): rule = rules[rid]; (ante,conse) = rule; print “Rule “+rid+”: “; print “IF “; for i in ante: /* each condition */ (attr, opr, value) = I; print attr+” “+opr+” “+value+” and”; print “Then conclude that ..”; ….. 28 Sasikumar M, IIT Bombay

  29. ... ● Can perform automated analysis for consistency, completeness, subsumption, etc – Common problems with knowledge bases ● Can also be induced from examples – Rule induction in machine learning 29 Sasikumar M, IIT Bombay

Recommend


More recommend