Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smooth_idf is incorrectly calculated #264

Open
EmilHvitfeldt opened this issue Mar 7, 2024 · 0 comments
Open

smooth_idf is incorrectly calculated #264

EmilHvitfeldt opened this issue Mar 7, 2024 · 0 comments
Labels
breaking change ☠️ API change likely to affect existing code

Comments

@EmilHvitfeldt
Copy link
Member

Right now we are doing log( 1 + (N / n_j)), but wikipedia has log(N / (1 + n_j)) + 1 and scikit-learn does

If smooth_idf=True (the default), the constant “1” is added to the numerator and denominator of the idf as if an extra document was seen containing every term in the collection exactly once, which prevents zero divisions: idf(t) = log [ (1 + n) / (1 + df(t)) ] + 1.

ref:
https://en.wikipedia.org/wiki/Tf%E2%80%93idf
https://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.TfidfTransformer.html#sklearn.feature_extraction.text.TfidfTransformer

@EmilHvitfeldt EmilHvitfeldt added the breaking change ☠️ API change likely to affect existing code label Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change ☠️ API change likely to affect existing code
Projects
None yet
Development

No branches or pull requests

1 participant