def calc_pairwise_dev(model):
# the average squared deviation from 0 (90 degree)
n = model.num_topics
weights = model.state.get_lambda()
weights = np.apply_along_axis(lambda x: x / x.sum(), 1, weights) # get dist.
weights = unitmatrix(weights) # normalize
score = 0.
for i in range(n):
for j in range(i + 1, n):
score += (weights[i].dot(weights[j]))**2
return np.sqrt(2. * score / n / (n - 1))
评论列表
文章目录