This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/packages/CLPBN/learning/example/school_params.yap

72 lines
70 KiB
Plaintext
Raw Normal View History

% learn distribution for school database.
% we do not consider the aggregates yet.
:- [pos:train].
2012-03-22 19:10:15 +00:00
:- ['../../examples/School/sch32'].
2011-05-20 23:56:12 +01:00
:- use_module(library(clpbn/learning/em)).
2009-10-21 00:05:23 +01:00
%:- clpbn:set_clpbn_flag(em_solver,gibbs).
2011-05-20 23:56:12 +01:00
%:- clpbn:set_clpbn_flag(em_solver,jt).
2011-06-14 09:39:19 +01:00
%:- clpbn:set_clpbn_flag(em_solver,ve).
:- clpbn:set_clpbn_flag(em_solver,bp).
2009-10-21 00:05:23 +01:00
timed_main :-
statistics(runtime, _),
findall(X,goal(X),L),
em(L,0.01,10,_,Lik),
statistics(runtime, [T,_]),
format('Took ~d msec and Lik ~3f~n',[T,Lik]).
main :-
findall(X,goal(X),L),
em(L,0.01,10,CPTs,Lik),
writeln(Lik:CPTs).
2011-05-20 23:56:12 +01:00
debug_school :-
graph(L),
em(L,0.01,10,CPTs,Lik),
writeln(Lik:CPTs).
run_queries([]).
run_queries(Q.L) :-
call(Q),
run_queries(L).
graph([professor_ability(p0,_G131367),professor_ability(p1,h),professor_ability(p2,_G131377),professor_ability(p3,_G131382),professor_ability(p4,_G131387),professor_ability(p5,_G131392),professor_ability(p6,_G131397),professor_ability(p7,l),professor_ability(p8,m),professor_ability(p9,h),professor_ability(p10,m),professor_ability(p11,_G131422),professor_ability(p12,_G131427),professor_ability(p13,_G131432),professor_ability(p14,_G131437),professor_ability(p15,_G131442),professor_ability(p16,_G131447),professor_ability(p17,m),professor_ability(p18,l),professor_ability(p19,h),professor_ability(p20,h),professor_ability(p21,_G131472),professor_ability(p22,m),professor_ability(p23,m),professor_ability(p24,l),professor_ability(p25,m),professor_ability(p26,_G131497),professor_ability(p27,h),professor_ability(p28,h),professor_ability(p29,_G131512),professor_ability(p30,_G131517),professor_ability(p31,_G131522),professor_popularity(p0,h),professor_popularity(p1,h),professor_popularity(p2,_G131537),professor_popularity(p3,h),professor_popularity(p4,h),professor_popularity(p5,h),professor_popularity(p6,l),professor_popularity(p7,l),professor_popularity(p8,_G131567),professor_popularity(p9,_G131572),professor_popularity(p10,l),professor_popularity(p11,_G131582),professor_popularity(p12,h),professor_popularity(p13,l),professor_popularity(p14,_G131597),professor_popularity(p15,h),professor_popularity(p16,m),professor_popularity(p17,_G131612),professor_popularity(p18,_G131617),professor_popularity(p19,_G131622),professor_popularity(p20,_G131627),professor_popularity(p21,h),professor_popularity(p22,_G131637),professor_popularity(p23,_G131642),professor_popularity(p24,l),professor_popularity(p25,_G131652),professor_popularity(p26,_G131657),professor_popularity(p27,h),professor_popularity(p28,h),professor_popularity(p29,_G131672),professor_popularity(p30,m),professor_popularity(p31,_G131682),registration_grade(r0,a),registration_grade(r1,_G131692),registration_grade(r2,_G131697),registration_grade(r3,c),registration_grade(r4,c),registration_grade(r5,c),registration_grade(r6,_G131717),registration_grade(r7,a),registration_grade(r8,b),registration_grade(r9,_G131732),registration_grade(r10,_G131737),registration_grade(r11,a),registration_grade(r12,_G131747),registration_grade(r13,a),registration_grade(r14,_G131757),registration_grade(r15,b),registration_grade(r16,a),registration_grade(r17,b),registration_grade(r18,_G131777),registration_grade(r19,_G131782),registration_grade(r20,c),registration_grade(r21,_G131792),registration_grade(r22,_G131797),registration_grade(r23,_G131802),registration_grade(r24,b),registration_grade(r25,a),registration_grade(r26,_G131817),registration_grade(r27,_G131822),registration_grade(r28,c),registration_grade(r29,b),registration_grade(r30,c),registration_grade(r31,b),registration_grade(r32,_G131847),registration_grade(r33,a),registration_grade(r34,c),registration_grade(r35,c),registration_grade(r36,a),registration_grade(r37,a),registration_grade(r38,c),registration_grade(r39,a),registration_grade(r40,_G131887),registration_grade(r41,_G131892),registration_grade(r42,_G131897),registration_grade(r43,a),registration_grade(r44,a),registration_grade(r45,a),registration_grade(r46,a),registration_grade(r47,_G131922),registration_grade(r48,_G131927),registration_grade(r49,b),registration_grade(r50,b),registration_grade(r51,b),registration_grade(r52,_G131947),registration_grade(r53,a),registration_grade(r54,_G131957),registration_grade(r55,a),registration_grade(r56,c),registration_grade(r57,_G131972),registration_grade(r58,_G131977),registration_grade(r59,_G131982),registration_grade(r60,_G131987),registration_grade(r61,a),registration_grade(r62,_G131997),registration_grade(r63,b),registration_grade(r64,b),registration_grade(r65,b),registration_grade(r66,_G132017),registration_grade(r67,b),registration_grade(r68,a),registration_grade(r69,_G132032),registration_grade(r70,_G132037),registration_grade(r71,_G132042),registration_grade(r72,_G132047),registration_grade(r73,_G132052),registration_grade(r74,a),registration_grad
%
2009-10-21 00:05:23 +01:00
% change to 0.0, 0.1, 0.2 to make things simpler/harder
2011-06-14 09:39:19 +01:00
%%
missing(0.99).
% miss 30% of the examples.
goal(professor_ability(P,V)) :-
pos:professor_ability(P,V1),
missing(X),
( random > X -> V = V1 ; true).
% miss 10% of the examples.
goal(professor_popularity(P,V)) :-
pos:professor_popularity(P,V1),
missing(X),
( random > X -> V = V1 ; true).
goal(registration_grade(P,V)) :-
pos:registration_grade(P,V1),
missing(X),
( random > X -> V = V1 ; true).
goal(student_intelligence(P,V)) :-
pos:student_intelligence(P,V1),
missing(X),
( random > X -> V = V1 ; true).
goal(course_difficulty(P,V)) :-
pos:course_difficulty(P,V1),
missing(X),
( random > X -> V = V1 ; true).
goal(registration_satisfaction(P,V)) :-
pos:registration_satisfaction(P,V1),
missing(X),
( random > X -> V = V1 ; true).