def calc_pairwise_cosine(model):
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 = []
for i in range(n):
for j in range(i + 1, n):
score.append(np.arccos(weights[i].dot(weights[j])))
return np.mean(score), np.std(score)
评论列表
文章目录