Ejemplo n.º 1
0
def assoc(self):
    """
	The spectrally associated matrix, i.e. U e^(S/2) row-normalized.

	This matrix is like U, but the dot products of its rows represent
	spreading activation instead of direct similarity. The highest
	dot products in .assoc are nodes that can reach each other through
	many short paths.
	"""
    unnormalized = np.multiply(self.u, np.exp(self.sigma / 2))
    return eigenmath.normalize_rows(unnormalized, offset=1e-4)
Ejemplo n.º 2
0
def test_normalize_rows():
    arr = np.asarray([[3.0, 4.0], [0.3, 0.4]])
    assert np.allclose(normalize_rows(arr), [[0.6, 0.8], [0.6, 0.8]])
    normalized_with_offset = normalize_rows(arr, offset=0.001)
    assert (normalized_with_offset[0] > normalized_with_offset[1]).all()
Ejemplo n.º 3
0
def test_normalize_rows():
    arr = np.asarray([[3.0, 4.0], [0.3, 0.4]])
    assert np.allclose(normalize_rows(arr), [[0.6, 0.8], [0.6, 0.8]])
    normalized_with_offset = normalize_rows(arr, offset=0.001)
    assert (normalized_with_offset[0] > normalized_with_offset[1]).all()