Skip to content

Fix inverted information diversity score (cosine distance vs. similarity) - #371

Merged
xehu merged 1 commit into
devfrom
ID_score_fix
Jul 15, 2026
Merged

Fix inverted information diversity score (cosine distance vs. similarity)#371
xehu merged 1 commit into
devfrom
ID_score_fix

Conversation

@sundy1994

Copy link
Copy Markdown
Collaborator

Overview

Corrects the information diversity calculation in calculate_ID_score(), which was computing the opposite of topical diversity.

Description

The score implements Eq. (1) of Riedl & Woolley (2017): ID = Σ(1 − cos(dⱼ, M))² / N, where cos is cosine similarity. The code used (1 - cosine(doc, mean))**2, but scipy.spatial.distance.cosine() already returns the cosine distance (1 − similarity) — so the 1 - canceled it back to similarity. The result was the mean squared similarity to the mean topic vector, which moves opposite to diversity (high score = less diverse), contradicting the docs.

Changes

  1. Drop the spurious "1 -".
  2. Update docstring to describe squared cosine distance and note the scipy sign convention.
  3. Update the dead source link → https://ssrn.com/abstract=2384068.
  4. Remove 7 unused imports.

@sundy1994
sundy1994 requested a review from xehu June 30, 2026 13:06

@xehu xehu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple fix. Looks good to me!

@xehu
xehu merged commit 054da82 into dev Jul 15, 2026
1 check passed
@xehu
xehu deleted the ID_score_fix branch July 15, 2026 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants