48 lines
		
	
	
		
			778 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			778 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| /* Learn distribution for professor database. */
 | |
| 
 | |
| :- use_module(library(pfl)).
 | |
| 
 | |
| :- use_module(library(clpbn/learning/em)).
 | |
| 
 | |
| %:- set_em_solver(ve).
 | |
| %:- set_em_solver(hve).
 | |
| %:- set_em_solver(bdd).
 | |
| %:- set_em_solver(bp).
 | |
| %:- set_em_solver(cbp).
 | |
| 
 | |
| professor(p0).
 | |
| professor(p1).
 | |
| professor(p2).
 | |
| professor(p3).
 | |
| professor(p4).
 | |
| professor(p5).
 | |
| professor(p6).
 | |
| professor(p7).
 | |
| professor(p8).
 | |
| 
 | |
| bayes abi(K)::[h,m,l] ; abi_table ; [professor(K)].
 | |
| 
 | |
| bayes pop(K)::[h,m,l], abi(K) ; pop_table ; [professor(K)].
 | |
| 
 | |
| abi_table([0.3, 0.3, 0.4]).
 | |
| 
 | |
| pop_table([0.3, 0.3, 0.4, 0.3, 0.3, 0.4, 0.3, 0.3, 0.4]).
 | |
| 
 | |
| goal_list([
 | |
| 	abi(p0,h),
 | |
| 	abi(p1,m),
 | |
| 	abi(p2,m),
 | |
| 	abi(p3,m),
 | |
| 	abi(p4,l),
 | |
| 	pop(p5,h),
 | |
| 	abi(p5,_),
 | |
| 	abi(p6,_),
 | |
| 	pop(p7,_)
 | |
| ]).
 | |
| 
 | |
| main :-
 | |
| 	goal_list(L),
 | |
| 	em(L, 0.01, 10, CPTs, Lik),
 | |
| 	writeln(Lik:CPTs).
 | |
| 
 |