#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
📚 FREE · CLASSIC & SKLEARN IDF

TF-IDF Calculator: Find the Words That Make Each Document Different

Paste a few documents and see which words matter most in each.

  • 🔤 Top terms per document
  • 🔍 Focus on one term
  • ⚙️ Two IDF formulas

How to use the TF-IDF Calculator

  1. 1. Paste documentsEnter one document per line: sentences, titles or reviews.
  2. 2. Choose formulasPick the TF and IDF versions, and optionally a term to focus on.
  3. 3. Read the scoresSee TF, IDF and TF-IDF and the top words per document.

Formulas and worked example

  • TF (term frequency) = count of the word in a document ÷ words in that document.
  • IDF (inverse document frequency) = ln(N ÷ df), where N is the number of documents and df is how many contain the word.
  • TF-IDF = TF × IDF.

With three documents, "data science is fun", "data analysis with python" and "python is fun", the word science appears once in a four-word document (TF = 0.25) and in only one of three documents (IDF = ln 3 = 1.0986). Its TF-IDF in document 1 is 0.2747, the highest in that document, while data, is and fun score 0.1014 because they appear elsewhere too.

Classic vs scikit-learn

scikit-learn's TfidfVectorizer uses a smoothed IDF, ln((1 + N) ÷ (1 + df)) + 1, so no word ever gets exactly zero, and it normalises each document vector to length 1. Pick the smooth option here to match its IDF; the final row normalisation is not applied in this table, so absolute values will still differ.

  • Search engines used TF-IDF to rank pages long before neural search.
  • Keyword extraction: top TF-IDF words make good tags.
  • Text classification: TF-IDF plus logistic regression is a strong, fast baseline.

Words are lowercased and punctuation removed; remove stopwords and stem first with the text preprocessing tool for cleaner results. Compare documents with the cosine similarity calculator.

Frequently asked questions

Why is a common word scored 0?

With the classic formula, a word in every document has IDF ln(1) = 0, so it carries no weight. Use the smooth option to keep a small weight.

How many documents can I use?

Up to 50 here, which is plenty for learning and checking homework.

Is the TF-IDF Calculator free?

Yes, the TF-IDF Calculator is free. The first time you see your first result, you are asked for your name and WhatsApp number once. After that, this and every other Uncodemy tool opens straight away without the form.

More free tools

See all free tools