Explore Library
Code QuizIntermediate

Inverted IDF Ratio

Identify why this inverse document frequency formula is backwards.

Codepython
import math

def idf(term, docs):
    n_containing = sum(1 for d in docs if term in d)
    return math.log(n_containing / len(docs))

print(idf('cat', [['cat'], ['dog'], ['cat', 'dog']]))

What is the bug in this IDF function?