When to run update_beliefs()

The engine.
Post Reply
legoleg
Posts: 1
Joined: Mon May 18, 2020 11:53 pm

When to run update_beliefs()

Post by legoleg »

Hello,
I'm just learning about Bayesfusion and followed the tutorial for the python wrapper. I have a network learned from a data set of about 7000 columns. I have a test file with the same 7000 columns that I want to go through and set the corresponding evidence for those nodes in the network, to see the outcome of the target "Section" node. My code looks like this:

Code: Select all

for stem in dictEvidence.keys(): # about 7000 stems in each row of my Test file
	if stem != "Section":
		self.net.set_evidence(stem, dictEvidence[stem][key])
		
		#Where should this line be???
		self.net.update_beliefs()
My question is about where I should call update_beliefs... at the end of each iteration of the for loop, or just once after I've completed the for loop? Can I update_beliefs() once after multiple calls to set-evidence(), or after each time? It is much, much slower if I do it after each time. Thank you!

Oleg
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: When to run update_beliefs()

Post by shooltz[BayesFusion] »

You need to call update_beliefs when you have set the evidence and want to calculate and retrieve the calculated posterior probabilities. In your case, for each of the records in the test file you should remove the evidence, set new evidence with multiple calls to set_evidence, then call update_beliefs.

Please consider reading the "Validation" chapter in SMILE Wrappers Manual (https://support.bayesfusion.com/docs) - SMILE implements network validation via k-fold, leave-one-out or simple testing, so you don't need to write manual loops over the training set. This functionality is also exposed in GeNIe.
Post Reply