Skip to content

Conditional mutual information in pyagrum. #25

Answered by phwuil
kenneth-lee-ch asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, you found a problem : it seems that (a part of) the state of the inference is kept from an InformationTheory instance to another. For now, a (not so expensive) workaround is to create the LazyPropagation object in the loop :

import pyAgrum as gum
import numpy as np

bn = gum.randomBN(n=10) # 
mi_matrix = np.zeros((bn.size(), bn.size()))

for i,ni in bn:
    for j,nj in bn:
        if i<=j:
            continue
        mi_matrix[i, j] =  gum.InformationTheory(gum.LazyPropagation(bn), 
                                                 ni,nj).mutualInformationXY()

print("Pairwise Mutual Information Matrix:")
print(mi_matrix)

(Note the loop in bn that iterates over all the pairs (node_id,…

Replies: 6 comments 13 replies

Comment options

You must be logged in to vote
1 reply
@phwuil
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
10 replies
@kenneth-lee-ch
Comment options

@phwuil
Comment options

@phwuil
Comment options

@kenneth-lee-ch
Comment options

@phwuil
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@kenneth-lee-ch
Comment options

@phwuil
Comment options

Answer selected by phwuil
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants