Skip to content
ENExplore Calculators

TF IDF Weight Calculator

Work out tf idf weight instantly with clear inputs, formula shown and shareable results.

About TF IDF Weight Calculator

TF-IDF multiplies how often a term appears in a document by how rare it is across the corpus. The rarity factor ln(N/df) is what suppresses stopwords: a word in every document has an IDF of zero and therefore no weight, while a term in one percent of documents gets a large multiplier and dominates the vector.

Formula

TF-IDF

tf = count / document length; idf = ln(N / df); weight = tf x idf

N
Documents in the corpus
df
Documents containing the term

Worked example

With the default values below, TF IDF Weight Calculator returns TF-IDF weight of 0.08846. Change any input above and every figure here is recalculated in your browser.

Inputs used

Occurrences of the term in the documentminimum 0
8
Words in the documentminimum 1
400
Documents in the corpusminimum 1
10,000
Documents containing the termminimum 1
120

Results

TF-IDF weight
0.08846
Normalised term frequency
0.02000
Inverse document frequency
4.42285
Share of documents containing the term
1.200%

Step by step

  1. 1Values used
  2. 2TF-IDF
  3. 3TF-IDF weight= 0.08846
  4. 4Normalised term frequency= 0.02000
  5. 5Inverse document frequency= 4.42285
  6. 6Share of documents containing the term= 1.200

Assumptions and limits

  • The result is derived only from the 4 inputs listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax or fees or charges into account.
  • Figures are rounded for display to 5 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

Frequently Asked Questions

Why is my TF-IDF zero?

Because the term appears in every document, making ln(N/df) = ln(1) = 0. Smoothed variants add 1 to the denominator and the result to avoid this.

How does BM25 improve on TF-IDF?

BM25 saturates term frequency so the twentieth occurrence adds little, and normalises by document length relative to the corpus average, which makes it far more robust on mixed-length documents.

TF IDF Weight Calculator – Calculate TF-IDF weight