add keys within learning
This commit is contained in:
parent
033f33ad96
commit
b7ef6576a6
@ -36,14 +36,7 @@ main(Lik) :-
|
|||||||
findall(X,scan_data(X),L),
|
findall(X,scan_data(X),L),
|
||||||
em(L,0.01,10,_,Lik).
|
em(L,0.01,10,_,Lik).
|
||||||
|
|
||||||
scan_data(I:[wet_grass(W),sprinkler(S),rain(R),cloudy(C)]) :-
|
scan_data([wet_grass(W),sprinkler(S),rain(R),cloudy(C)]) :-
|
||||||
data(W, S, R, C),
|
data(W, S, R, C).
|
||||||
new_id(I).
|
|
||||||
|
|
||||||
new_id(I) :-
|
|
||||||
retract(id(I)),
|
|
||||||
I1 is I+1,
|
|
||||||
assert(id(I1)).
|
|
||||||
|
|
||||||
id(0).
|
|
||||||
|
|
||||||
|
@ -134,12 +134,15 @@ setup_em_network(Items, state(AllDists, AllDistInstances, MargVars, SolverState)
|
|||||||
clpbn_init_solver(MargVars, AllVars, _, SolverState).
|
clpbn_init_solver(MargVars, AllVars, _, SolverState).
|
||||||
|
|
||||||
run_examples(user:Exs, Keys, Factors, EList) :-
|
run_examples(user:Exs, Keys, Factors, EList) :-
|
||||||
Exs = [_:_|_], !,
|
Exs = [[_]|_], !,
|
||||||
|
foldl(add_key, Exs, ,KExs, 1, _),
|
||||||
findall(ex(EKs, EFs, EEs), run_example(Exs, EKs, EFs, EEs), VExs),
|
findall(ex(EKs, EFs, EEs), run_example(Exs, EKs, EFs, EEs), VExs),
|
||||||
foldl4(join_example, VExs, [], Keys, [], Factors, [], EList, 0, _).
|
foldl4(join_example, VExs, [], Keys, [], Factors, [], EList, 0, _).
|
||||||
run_examples(Items, Keys, Factors, EList) :-
|
run_examples(Items, Keys, Factors, EList) :-
|
||||||
run_ex(Items, Keys, Factors, EList).
|
run_ex(Items, Keys, Factors, EList).
|
||||||
|
|
||||||
|
add_key(Ex, I:Ex, I, I1) :- I1 is I+1.
|
||||||
|
|
||||||
join_example( ex(EKs, EFs, EEs), Keys0, Keys, Factors0, Factors, EList0, EList, I0, I) :-
|
join_example( ex(EKs, EFs, EEs), Keys0, Keys, Factors0, Factors, EList0, EList, I0, I) :-
|
||||||
I is I0+1,
|
I is I0+1,
|
||||||
foldl(process_key(I0), EKs, Keys0, Keys),
|
foldl(process_key(I0), EKs, Keys0, Keys),
|
||||||
@ -188,7 +191,7 @@ em_loop(Its, Likelihood0, State, MaxError, MaxIts, LikelihoodF, FTables) :-
|
|||||||
;
|
;
|
||||||
Its1 is Its+1,
|
Its1 is Its+1,
|
||||||
em_loop(Its1, Likelihood, State, MaxError, MaxIts, LikelihoodF, FTables)
|
em_loop(Its1, Likelihood, State, MaxError, MaxIts, LikelihoodF, FTables)
|
||||||
).
|
).
|
||||||
|
|
||||||
ltables([], []).
|
ltables([], []).
|
||||||
ltables([Id-T|Tables], [Key-LTable|FTables]) :-
|
ltables([Id-T|Tables], [Key-LTable|FTables]) :-
|
||||||
|
Reference in New Issue
Block a user