public void Execute(IExampleInterface app) { // build the bayesian network structure BayesianNetwork network = new BayesianNetwork(); BayesianEvent BlueTaxi = network.CreateEvent("blue_taxi"); BayesianEvent WitnessSawBlue = network.CreateEvent("saw_blue"); network.CreateDependency(BlueTaxi, WitnessSawBlue); network.FinalizeStructure(); // build the truth tales BlueTaxi.Table.AddLine(0.85, true); WitnessSawBlue.Table.AddLine(0.80, true, true); WitnessSawBlue.Table.AddLine(0.20, true, false); // validate the network network.Validate(); // display basic stats Console.WriteLine(network.ToString()); Console.WriteLine("Parameter count: " + network.CalculateParameterCount()); EnumerationQuery query = new EnumerationQuery(network); //SamplingQuery query = new SamplingQuery(network); query.DefineEventType(WitnessSawBlue, EventType.Evidence); query.DefineEventType(BlueTaxi, EventType.Outcome); query.SetEventValue(WitnessSawBlue, false); query.SetEventValue(BlueTaxi, false); query.Execute(); Console.WriteLine(query.ToString()); }
public void TestCount() { BayesianNetwork network = new BayesianNetwork(); BayesianEvent a = network.CreateEvent("a"); BayesianEvent b = network.CreateEvent("b"); BayesianEvent c = network.CreateEvent("c"); BayesianEvent d = network.CreateEvent("d"); BayesianEvent e = network.CreateEvent("e"); network.CreateDependency(a, b, d, e); network.CreateDependency(c, d); network.CreateDependency(b, e); network.CreateDependency(d, e); network.FinalizeStructure(); Assert.AreEqual(16, network.CalculateParameterCount()); }
public void Validate(BayesianNetwork network) { Assert.AreEqual(3, network.CalculateParameterCount()); }