2
$\begingroup$

I implement the same markov logic network in two different ways using the Alchemy2 software. They should yield to the same result smoking-out.mln and smoking.result, but that's not the case. Why?

I use an example from the Alchemy tutorial.

First way:

smoking-train.db:

Friends(Anna, Bob)
Friends(Bob, Anna)
Friends(Anna, Edward)
Friends(Edward, Anna)
Friends(Anna, Frank)
Friends(Frank, Anna)
Friends(Bob, Chris)
Friends(Chris, Bob)
Friends(Chris, Daniel)
Friends(Daniel, Chris)
Friends(Edward, Frank)
Friends(Frank, Edward)
Friends(Gary, Helen)
Friends(Helen, Gary)
Friends(Gary, Anna)
Friends(Anna, Gary)

Smokes(Anna)
Smokes(Edward)
Smokes(Frank)
Smokes(Gary)

Cancer(Anna)
Cancer(Edward)

smoking.mln:

// MLN for social networks section in tutorial

// Evidence
Friends(person, person)

// Some evidence, some query
Smokes(person)

// Query
Cancer(person)

// Rules
// If you smoke, you get cancer
Smokes(x) => Cancer(x)

// People with friends who smoke, also smoke
// and those with friends who don't smoke, don't smoke
Friends(x, y) => (Smokes(x) <=> Smokes(y))

And I run:

$ learnwts -d -i smoking.mln -o smoking-out.mln -t smoking-train.db -ne Smokes,Cancer -queryEvidence

$ infer -ms -i smoking-out.mln -r smoking.result -e smoking-test.db -q Smokes,Cancer -ow Smokes,Cancer -cw Friends

Notice that I use the -queryEvidence option, which means "all the groundings of query preds not in db are assumed false evidence.".

I get this result: smoking-out.mln:

//predicate declarations
Cancer(person)
Friends(person,person)
Smokes(person)

// 0.112381  Smokes(x) => Cancer(x)
0.112381  !Smokes(a1) v Cancer(a1)

// 1.02505  Friends(x,y) => (Smokes(x) <=> Smokes(y))
0.512526  !Friends(a1,a2) v Smokes(a1) v !Smokes(a2)
0.512526  !Friends(a1,a2) v Smokes(a2) v !Smokes(a1)

// 0       Friends(a1,a2)
0       Friends(a1,a2)

// 1.62975  Smokes(a1)
1.62975  Smokes(a1)

// 1.45472  Cancer(a1)
1.45472  Cancer(a1)

smoking.result:

Smokes(John) 0.930957
Smokes(Katherine) 0.916958
Smokes(Lars) 0.907959
Smokes(Michael) 0.977952
Cancer(Ivan) 0.820968
Cancer(John) 0.847965
Cancer(Katherine) 0.80497
Cancer(Lars) 0.831967
Cancer(Michael) 0.883962
Cancer(Nick) 0.849965

Now, the second way:

In the second way, I simulate the -queryEvidence option by adding the false evidence directly in the training database (and then, I don't use the -queryEvidence option).

smoking-train.db:

Friends(Anna, Bob)
Friends(Bob, Anna)
Friends(Anna, Edward)
Friends(Edward, Anna)
Friends(Anna, Frank)
Friends(Frank, Anna)
Friends(Bob, Chris)
Friends(Chris, Bob)
Friends(Chris, Daniel)
Friends(Daniel, Chris)
Friends(Edward, Frank)
Friends(Frank, Edward)
Friends(Gary, Helen)
Friends(Helen, Gary)
Friends(Gary, Anna)
Friends(Anna, Gary)

Smokes(Anna)
Smokes(Edward)
Smokes(Frank)
Smokes(Gary)

Cancer(Anna)
Cancer(Edward)

!Smokes(Bob)
!Smokes(Chris)
!Smokes(Daniel)
!Smokes(Helen)

!Cancer(Bob)
!Cancer(Frank)
!Cancer(Chris)
!Cancer(Daniel)
!Cancer(Gary)
!Cancer(Helen)

!Friends(Anna, Chris)
!Friends(Anna, Daniel)
!Friends(Anna, Helen)
!Friends(Bob, Edward)
!Friends(Bob, Frank)
!Friends(Bob, Daniel)
!Friends(Bob, Gary)
!Friends(Bob, Helen)
!Friends(Edward, Bob)
!Friends(Edward, Chris)
!Friends(Edward, Daniel)
!Friends(Edward, Gary)
!Friends(Edward, Helen)
!Friends(Frank, Bob)
!Friends(Frank, Chris)
!Friends(Frank, Daniel)
!Friends(Frank, Gary)
!Friends(Frank, Helen)
!Friends(Chris, Anna)
!Friends(Chris, Edward)
!Friends(Chris, Frank)
!Friends(Chris, Gary)
!Friends(Chris, Helen)
!Friends(Daniel, Anna)
!Friends(Daniel, Bob)
!Friends(Daniel, Edward)
!Friends(Daniel, Frank)
!Friends(Daniel, Gary)
!Friends(Daniel, Helen)
!Friends(Gary, Bob)
!Friends(Gary, Edward)
!Friends(Gary, Frank)
!Friends(Gary, Chris)
!Friends(Gary, Daniel)
!Friends(Helen, Anna)
!Friends(Helen, Bob)
!Friends(Helen, Edward)
!Friends(Helen, Frank)
!Friends(Helen, Chris)
!Friends(Helen, Daniel)

I use the same smoking.mln as before, and now I run learnwts without the -queryEvidenceoption:

$ learnwts -d -i smoking.mln -o smoking-out.mln -t smoking-train.db -ne Smokes,Cancer

$ infer -ms -i smoking-out.mln -r smoking.result -e smoking-test.db -q Smokes,Cancer -ow Smokes,Cancer -cw Friends

And I get a very different result: smoking-out.mln:

//predicate declarations
Cancer(person)
Friends(person,person)
Smokes(person)

// 0.934545  Smokes(x) => Cancer(x)
0.934545  !Smokes(a1) v Cancer(a1)

// 0.886065  Friends(x,y) => (Smokes(x) <=> Smokes(y))
0.443032  !Friends(a1,a2) v Smokes(a1) v !Smokes(a2)
0.443032  !Friends(a1,a2) v Smokes(a2) v !Smokes(a1)

// 0       Friends(a1,a2)
0       Friends(a1,a2)

// 0.583657  Smokes(a1)
0.583657  Smokes(a1)

// -1.3644  Cancer(a1)
-1.3644  Cancer(a1)

smoking.result:

Smokes(John) 0.686981
Smokes(Katherine) 0.485001
Smokes(Lars) 0.475002
Smokes(Michael) 0.848965
Cancer(Ivan) 0.384012
Cancer(John) 0.318018
Cancer(Katherine) 0.257024
Cancer(Lars) 0.308019
Cancer(Michael) 0.353015
Cancer(Nick) 0.40001

So, why is this? I should get the exact same smoking-out.mln and smoking.result, isn't it?

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.