TF IDF - why wight for same word is different is each document, even though they appeared same time in each document

code following :
s1 = “this is good movie”
s2 = “this was good movie”
s3 = “this is not good movie”

corpus = [s1,s2,s3]
tfidf = TfidfVectorizer()
vc = tfidf.fit_transform(corpus).toarray()
print(vc)

in vc = “good” was the first word but it didn’t have same weight for all 3 documents, why? as per the formula, they should be same , right?

Hey @sanandasaha3

Terms which appear the same number of times in different documents do not necessarily have the same TF-IDF score because we are missing one variable which can still be different among these docs.
TF(t) = (Number of times term t appears in a document) / (Total number of terms in the document).
The second term i.e. Total number of terms in the document is different for the last document and hence the different score.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.