ML-KULeuven / problog

ProbLog is a Probabilistic Logic Programming Language for logic programs with probabilities.
https://dtai.cs.kuleuven.be/problog/
317 stars 35 forks source link

Parameter learning behaviour on BN example #98

Open plison opened 1 year ago

plison commented 1 year ago

I've noticed a strange result when doing parameter learning, where I get a different result depending on whether the parameter to tune is (a) directly associated with the rule or is (b) associated to a probabilistic fact included in the clauses of the rule.

From the Bayesian network example:

t(0.5)::burglary.
0.2::earthquake.
t(0.5)::p_alarm1.
t(0.5)::p_alarm2.
t(0.5)::p_alarm3.

alarm :- burglary, earthquake, p_alarm1.
alarm :- burglary, \+earthquake, p_alarm2.
alarm :- \+burglary, earthquake, p_alarm3.

with the following evidence:

evidence(burglary,false).
evidence(alarm,false).
-----
evidence(earthquake,false).
evidence(alarm,true).
evidence(burglary,true).
-----
evidence(burglary,false).

In this case, I get P(burglary) = 0.3333, P(alarm1) = 0.5, P(alarm2) = 1 and P(alarm3) = 0.

However, if I try to attach those tunable parameters to the rule directly, I do not the get the same results when running LFI on the same evidence:

t(0.5)::burglary.
0.2::earthquake.

t(0.5)::alarm :- burglary, earthquake.
t(0.5)::alarm :- burglary, \+earthquake.
t(0.5)::alarm :- \+burglary, earthquake.

P(burglary) is still equal to 0.3333 and P(alarm2) is still equal to 1, but this time the probability of the first alarm is set to 0, even though no case of burglary + alarm was observed in the evidence (so the probability should not be modified from the initial 0.5).

Any idea why this is the case?

rmanhaeve commented 1 year ago

Hi Pierre. This seems to be a bug indeed. We'll look into it.

wenchiyang commented 1 year ago

Thank you for your input! It is indeed a bug that the algorithm blindly assigns a 0 to parameters whose value cannot be inferred in the evidence instead of choosing not to update, just like p_alarm1 in your illustration. I have fixed it here which will soon be integrated in the current repo as well.