more support for learning
This commit is contained in:
parent
58d4442883
commit
902dafa906
@ -91,7 +91,7 @@ em_solver(vel).
|
|||||||
%output(gviz(user_error)).
|
%output(gviz(user_error)).
|
||||||
output(no).
|
output(no).
|
||||||
suppress_attribute_display(false).
|
suppress_attribute_display(false).
|
||||||
parameter_softening(laplace).
|
parameter_softening(m_estimate(10)).
|
||||||
|
|
||||||
clpbn_flag(Flag,Option) :-
|
clpbn_flag(Flag,Option) :-
|
||||||
clpbn_flag(Flag, Option, Option).
|
clpbn_flag(Flag, Option, Option).
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
get_dist_matrix/5,
|
get_dist_matrix/5,
|
||||||
get_possibly_deterministic_dist_matrix/5,
|
get_possibly_deterministic_dist_matrix/5,
|
||||||
get_dist_domain/2,
|
get_dist_domain/2,
|
||||||
get_dist_params/2,
|
|
||||||
get_dist_domain_size/2,
|
get_dist_domain_size/2,
|
||||||
get_dist_params/2,
|
get_dist_params/2,
|
||||||
get_dist_key/2,
|
get_dist_key/2,
|
||||||
|
@ -100,10 +100,10 @@ clpbn_tabled_clause(Head, Body) :-
|
|||||||
clpbn_tabled_clause(Head, M, Body).
|
clpbn_tabled_clause(Head, M, Body).
|
||||||
|
|
||||||
clpbn_tabled_clause(M:Head, _, Body) :- !,
|
clpbn_tabled_clause(M:Head, _, Body) :- !,
|
||||||
clpbn_table(Head, M, Body).
|
clpbn_tabled_clause(Head, M, Body).
|
||||||
clpbn_tabled_clause(Head, M, Body) :-
|
clpbn_tabled_clause(Head, M, Body) :-
|
||||||
clpbn_table(Head, M, THead),
|
clpbn_table(Head, M, THead),
|
||||||
clause(THead, Body).
|
clause(M:THead, Body).
|
||||||
|
|
||||||
|
|
||||||
clpbn_tabled_assertz(M:Clause) :- !,
|
clpbn_tabled_assertz(M:Clause) :- !,
|
||||||
|
@ -65,7 +65,7 @@
|
|||||||
|
|
||||||
:- user:set(record_testclause_hook, clpbn_aleph:do_nothing).
|
:- user:set(record_testclause_hook, clpbn_aleph:do_nothing).
|
||||||
|
|
||||||
%:- user:set(newbest_hook, clpbn_aleph:store_theory).
|
:- user:set(newbest_hook, clpbn_aleph:store_theory).
|
||||||
|
|
||||||
disable_solver(_) :-
|
disable_solver(_) :-
|
||||||
clpbn_flag(solver, Old, none),
|
clpbn_flag(solver, Old, none),
|
||||||
@ -109,15 +109,17 @@ store_theory(_).
|
|||||||
|
|
||||||
add_correct_cpt((G,B),(G,NB)) :- !,
|
add_correct_cpt((G,B),(G,NB)) :- !,
|
||||||
add_correct_cpt(B,NB).
|
add_correct_cpt(B,NB).
|
||||||
|
add_correct_cpt((clpbn:{V = K with Tab }), ({V = K with NTab})) :-
|
||||||
|
correct_tab(Tab,K,NTab).
|
||||||
add_correct_cpt(({V = K with Tab }), ({V = K with NTab})) :-
|
add_correct_cpt(({V = K with Tab }), ({V = K with NTab})) :-
|
||||||
correct_tab(Tab,K,NTab).
|
correct_tab(Tab,K,NTab).
|
||||||
|
|
||||||
correct_tab(p(Vs,_),K,p(Vs,TDist)) :-
|
correct_tab(p(Vs,_),K,p(Vs,TDist)) :-
|
||||||
get_dist_key(Id, K),
|
get_dist_key(Id, K),
|
||||||
get_dist_parms(Id, TDist).
|
get_dist_params(Id, TDist).
|
||||||
correct_tab(p(Vs,_,Ps),K,p(Vs,TDist,Ps)) :-
|
correct_tab(p(Vs,_,Ps),K,p(Vs,TDist,Ps)) :-
|
||||||
get_dist_key(Id, K),
|
get_dist_key(Id, K),
|
||||||
get_dist_parms(Id, TDist).
|
get_dist_params(Id, TDist).
|
||||||
|
|
||||||
store_cl(Cl) :-
|
store_cl(Cl) :-
|
||||||
recordz(best_theory, Cl, _).
|
recordz(best_theory, Cl, _).
|
||||||
|
@ -90,7 +90,7 @@ init_em(Items, state( AllDists, AllDistInstances, MargVars, SolverVars)) :-
|
|||||||
em_loop(Its, Likelihood0, State, MaxError, MaxIts, LikelihoodF, FTables) :-
|
em_loop(Its, Likelihood0, State, MaxError, MaxIts, LikelihoodF, FTables) :-
|
||||||
estimate(State, LPs),
|
estimate(State, LPs),
|
||||||
maximise(State, Tables, LPs, Likelihood),
|
maximise(State, Tables, LPs, Likelihood),
|
||||||
writeln(Likelihood:Its:Likelihood0:Tables),
|
% writeln(Likelihood:Its:Likelihood0:Tables),
|
||||||
(
|
(
|
||||||
(
|
(
|
||||||
abs((Likelihood - Likelihood0)/Likelihood) < MaxError
|
abs((Likelihood - Likelihood0)/Likelihood) < MaxError
|
||||||
@ -205,7 +205,7 @@ compute_parameters([Id-Samples|Dists], [Id-NewTable|Tables], MDistTable, Lik0,
|
|||||||
empty_dist(Id, Table0),
|
empty_dist(Id, Table0),
|
||||||
add_samples(Samples, Table0, MDistTable),
|
add_samples(Samples, Table0, MDistTable),
|
||||||
soften_sample(Table0, SoftenedTable),
|
soften_sample(Table0, SoftenedTable),
|
||||||
matrix:matrix_sum(Table0,TotM),writeln(Id-TotM),
|
matrix:matrix_sum(Table0,TotM),
|
||||||
normalise_counts(SoftenedTable, NewTable),
|
normalise_counts(SoftenedTable, NewTable),
|
||||||
compute_likelihood(Table0, NewTable, DeltaLik),
|
compute_likelihood(Table0, NewTable, DeltaLik),
|
||||||
dist_new_table(Id, NewTable),
|
dist_new_table(Id, NewTable),
|
||||||
|
@ -68,15 +68,15 @@ soften_sample(T0,T) :-
|
|||||||
|
|
||||||
soften_sample(no,T,T).
|
soften_sample(no,T,T).
|
||||||
soften_sample(m_estimate(M), T0, T) :-
|
soften_sample(m_estimate(M), T0, T) :-
|
||||||
matrix_agg_cols(T0,+,Cols),matrix:matrix_to_list(Cols), writeln(Cols),
|
matrix_agg_cols(T0,+,Cols),
|
||||||
matrix_op_to_all(Cols, *, M, R),
|
matrix_op_to_all(Cols, *, M, R),
|
||||||
matrix_op_to_cols(T0,+,R,T).
|
matrix_op_to_cols(T0,R,+,T).
|
||||||
soften_sample(auto_m, T0,T) :-
|
soften_sample(auto_m, T0,T) :-
|
||||||
matrix_agg_cols(T0,+,Cols),matrix:matrix_to_list(Cols), writeln(Cols),
|
matrix_agg_cols(T0,+,Cols),
|
||||||
matrix_sum(Cols,TotM),
|
matrix_sum(Cols,TotM),
|
||||||
M is sqrt(TotM),
|
M is sqrt(TotM),
|
||||||
matrix_op_to_all(Cols, *, M, R),
|
matrix_op_to_all(Cols, *, M, R),
|
||||||
matrix_op_to_cols(T0,+,R,T).
|
matrix_op_to_cols(T0,R,+,T).
|
||||||
soften_sample(laplace,T0,T) :-
|
soften_sample(laplace,T0,T) :-
|
||||||
matrix_op_to_all(T0, +, 1, T).
|
matrix_op_to_all(T0, +, 1, T).
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user