Disclaimer: Dieser Thread wurde aus dem alten Forum importiert. Daher werden eventuell nicht alle Formatierungen richtig angezeigt. Der ursprüngliche Thread beginnt im zweiten Post dieses Threads.
Assignment 5 Tests
I’d like to be able to test my implementation, but I don’t have the result for the given test case P(TBC | ~Asia, Xray, Dysp).
Can someone post this probability here?
Thanks in advance.
I have the same problem:
System.out.println(Musterloesung.query(net,TBC,evidence));
“Musterloesung” is missing.
Well to fix that you just replace [m]Musterloesung[/m] with [m](new YourFancyUniqueClass())[/m] and the test should work. However, the original problem was that we do not know what probability is right for the testcase.
Hi all,
I’ve translated the MaryCalls/JohnCalls example (“Inference for Mary and John”) into a smaller test, where we know the correct results based on the lecture, namely P(B|j,m) = 0.284 (see Slide 631 “Inference by Enumeration: John and Mary, ctd.”, there also the unnormalized values given, which might helps you debugging):
package info.kwarc.teaching.bayes;
import java.util.ArrayList;
public class Test {
public static void main(String[] args) {
Node[] NilNode = {};
Boolean[] NilBool = {};
Boolean[] tr = {true};
Boolean[] fa = {false};
Boolean[] trtr = {true,true};
Boolean[] trfa = {true,false};
Boolean[] fatr = {false,true};
Boolean[] fafa = {false,false};
Network net = new Network();
Node Burglary = new Node("Burglary",NilNode);
Burglary.setProb(NilBool, 0.001);
net.addNode(Burglary);
Node Earthquake = new Node("Earthquake",NilNode);
Earthquake.setProb(NilBool, 0.002);
net.addNode(Earthquake);
Node[] EBpre = {Burglary, Earthquake};
Node Alarm = new Node("Alarm", EBpre);
Alarm.setProb(trtr, 0.95);
Alarm.setProb(trfa, 0.94);
Alarm.setProb(fatr, 0.29);
Alarm.setProb(fafa, 0.001);
net.addNode(Alarm);
Node[] Apre = {Alarm};
Node JohnCalls = new Node("JohnCalls", Apre);
JohnCalls.setProb(tr, 0.90);
JohnCalls.setProb(fa, 0.05);
net.addNode(JohnCalls);
Node MaryCalls = new Node("MaryCalls", Apre);
MaryCalls.setProb(tr, 0.70);
MaryCalls.setProb(fa, 0.01);
net.addNode(MaryCalls);
Pair<Node,Boolean> e1 = new Pair<>(JohnCalls,true);
Pair<Node,Boolean> e2 = new Pair<>(MaryCalls,true);
ArrayList<Pair<Node,Boolean>> evidence = new ArrayList<>();
evidence.add(e1);
evidence.add(e2);
System.out.println(Query.query(net,Burglary,evidence));
}
}
Happy Coding :)!
Thank you! Has helped me a lot!
I have the following probabilities for the given test case P(TBC | ~Asia, Xray, Dysp):
Unnormalized: <8.272370479999999E-4, 0.09858442888800001>
Normalized: <0.008321327685349975, 0.99167867231465>
So the final result is \approx 0.008
@atomico: thank you for posting your numbers because I have the same results. Even the very last digits match with your numbers.
Thanks a lot Fuxicus!!
Just to make sure:
I have
0.2841718353643929
as solution for that testcase. Anybody else also?