public void TestK2Structure() { String[] labels = { "available", "not" }; IMLDataSet data = new BasicMLDataSet(DATA, null); BayesianNetwork network = new BayesianNetwork(); BayesianEvent x1 = network.CreateEvent("x1", labels); BayesianEvent x2 = network.CreateEvent("x2", labels); BayesianEvent x3 = network.CreateEvent("x3", labels); network.FinalizeStructure(); TrainBayesian train = new TrainBayesian(network, data, 10); train.InitNetwork = BayesianInit.InitEmpty; while (!train.TrainingDone) { train.Iteration(); } train.Iteration(); Assert.IsTrue(x1.Parents.Count == 0); Assert.IsTrue(x2.Parents.Count == 1); Assert.IsTrue(x3.Parents.Count == 1); Assert.IsTrue(x2.Parents.Contains(x1)); Assert.IsTrue(x3.Parents.Contains(x2)); Assert.AreEqual(0.714, network.GetEvent("x2").Table.FindLine(1, new int[] { 1 }).Probability, 0.001); }
/// <inheritdoc/> public void Init(TrainBayesian theTrainer, BayesianNetwork theNetwork, IMLDataSet theData) { _network = theNetwork; _data = theData; _train = theTrainer; OrderNodes(); _index = -1; }
/// <inheritdoc/> public void Init(TrainBayesian theTrainer, BayesianNetwork theNetwork, IMLDataSet theData) { }
/// <inheritdoc/> public void Init(TrainBayesian theTrainer, BayesianNetwork theNetwork, IMLDataSet theData) { _network = theNetwork; _data = theData; _index = 0; }