williamleif / socialsent

Code and data for inducing domain-specific sentiment lexicons.
Apache License 2.0
195 stars 76 forks source link

Symmetric transition matrix #16

Open slavi opened 6 years ago

slavi commented 6 years ago

The paper claims that the transition matrix T=D^0.5*E*D^0.5 is symmetric, and socialsent.graph_construct.transition_matrix takes a sym parameter that is supposed to make the transition matrix symmetric.

That is however not the case (mathematically, the above equation does not make a non-symmetric matrix symmetric). This can be trivially demonstrated by e.g.:

    import numpy as np
    from socialsent.graph_construction import transition_matrix

    v = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
    v_norm = np.divide(v.T, np.linalg.norm(v, axis=1)).T
    E = namedtuple('Embedding', ['m'])
    embeddings = E(m=v_norm)
    M = transition_matrix(embeddings, nn=1, sym=True, arccos=True)
    print M
[[ 0.          0.97276408  0.        ]
 [ 0.          0.          1.        ]
 [ 0.          1.          0.        ]]

What am I missing?