Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:dydaktyka:problog:intro [2017/05/15 13:02]
msl [First Assignment]
en:dydaktyka:problog:intro [2019/06/27 15:49] (current)
Line 12: Line 12:
  
   - from command line: ''​problog <path to file with model>''​   - from command line: ''​problog <path to file with model>''​
-  - from [[https://​dtai.cs.kuleuven.be/​problog/​editor.html''​| interactive web environment]] ​+  - from [[https://​dtai.cs.kuleuven.be/​problog/​editor.html| interactive web environment]] ​
    
 ===== First Model ===== ===== First Model =====
Line 45: Line 45:
 0.4::​student_knows_the_answer. 0.4::​student_knows_the_answer.
  
-pass_exam :- \+ illegible_handwriting, student_knows_the_answer.+pass_exam :- student_knows_the_answer, ​\+ illegible_handwriting.
 </​code>  ​ </​code>  ​
  
Line 136: Line 136:
  
 <code prolog> <code prolog>
-pass_exam(Student) :- has_illegible_writing(Student), ​heads(Student). +pass_exam(Student) :- heads(Student), ​has_illegible_writing(Student). 
-pass_exam(Student) :- \+ has_illegible_writing(Student), ​knows_the_answer(Student).+pass_exam(Student) :- knows_the_answer(Student), ​\+ has_illegible_writing(Student).
 </​code>  ​ </​code>  ​
 +
 +<WRAP center round tip 95%>
 +Good advice: if you use negation (''​\+''​) together with variables in the rule body, be sure that the variable has been already used in the same rule body in a positive context, e.g. don't write 
 +
 +''​\+ has_illegible_writing(Student),​ knows_the_answer(Student)'', ​
 +
 +because variable ''​Student''​ is used here first in the negative context. If you want to know details, learn more about Prolog ;)
 +</​WRAP>​
  
 Try to run the following model and check what is the probability of passing the exam by Joan. Try to add some evidence to the model. Try to run the following model and check what is the probability of passing the exam by Joan. Try to add some evidence to the model.
Line 174: Line 182:
 0.7::​pass_exam(Student) :- handwriting(Student,​ partly_legible),​ knows_the_answer(student). 0.7::​pass_exam(Student) :- handwriting(Student,​ partly_legible),​ knows_the_answer(student).
 </​code>  ​ </​code>  ​
- 
  
 Update rest of the rules accordingly and check if the model still works. What is the chance of passing the exam by Maxwell, who knows the answer but his handwriting is only partly legible? Update rest of the rules accordingly and check if the model still works. What is the chance of passing the exam by Maxwell, who knows the answer but his handwriting is only partly legible?
 +
 +==== Last Fixes ====
 +
 +There is one problem with the approach we've used with ''​handwriting''​ predicate. Have you noticed? All three facts ''​handwriting(Student,​ illegible), handwriting(Student,​ partly_legible),​ handwriting(Student,​ legible)''​ can be true at the same time. In other words, our model has a flaw we need to fix!
 +
 +There are to ways to take care of that:
 +
 +  - (not recommended) we add additional rules that say that only one value can be true.
 +  - (recommended) use so called //annotated disjunctions//,​ which will be explained briefly.
 +
 +If we have three facts that only one of them can be true at the time, we can write them as:
 +
 +<code prolog>
 +fact1; fact2; fact3.
 +</​code> ​
 +
 +The same we can due with a rule:
 +<code prolog>
 +fact1; fact2; fact3 :- rule_body.
 +</​code>​
 +
 +Which in our case translates to:
 +<code prolog>
 +0.5::​handwriting(Name,​ illegible); ​
 +0.4::​handwriting(Name,​ partly_legible); ​
 +0.1::​handwriting(Name,​ legible ):- student(Name).
 +</​code>​
 +
 +Try to use that instead of the previous notation. Is there any difference?
  
 ===== First Assignment ===== ===== First Assignment =====
Line 184: Line 220:
 //You live in the Los Angeles, beautiful city where earthquakes are not uncommon. You've installed a new alarm system in your house that was meant to protect you from burglaries. Unfortunately alarm is too sensitive and sometimes it get startled by an earthquake. Because of that you've set the alarm to not call the police. Instead of that your neighbors Joan and Maxwell are calling you as soon as they hear the alarm (if they are around). Unfortunately both Joan and Maxwell love pranks and sometimes call you only for fun.// //You live in the Los Angeles, beautiful city where earthquakes are not uncommon. You've installed a new alarm system in your house that was meant to protect you from burglaries. Unfortunately alarm is too sensitive and sometimes it get startled by an earthquake. Because of that you've set the alarm to not call the police. Instead of that your neighbors Joan and Maxwell are calling you as soon as they hear the alarm (if they are around). Unfortunately both Joan and Maxwell love pranks and sometimes call you only for fun.//
  
-Question: what is the probability of burglary, if you are called by Joan only? How much probable is that it was  +Question: what is the probability of burglary, if you are called by Joan only and you didn't receive call from Maxwell? How much probable is that it was only an earthquake?
-only an earthquake?+
  
 ==== Priors ==== ==== Priors ====
Line 203: Line 238:
   * there is small probability (''​0.1''​) that neighbor calls you only to prank you   * there is small probability (''​0.1''​) that neighbor calls you only to prank you
  
-==== Priors ==== 
- 
-The tables below contain information about prior probabilities of events. 
- 
-  
en/dydaktyka/problog/intro.1494846132.txt.gz · Last modified: 2019/06/27 16:00 (external edit)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0