CBSE Class 10 · Artificial Intelligence, code 417 · Unit 6 calculations, 2026-27

Bag of words class 10 AI, worked through to the last TFIDF value.

Most notes on bag of words class 10 AI stop at a definition and a two-line example. This page takes one corpus of three short documents all the way: normalise it, build the dictionary, fill the document vector table, count document frequency, work out IDF and finish with every TFIDF value, using the formula in the CBSE handbook. In our live batch, students do the same on fresh text against the clock until the method is automatic.

Live online · one corpus, every table · CBSE handbook formula · checked in Python · four-mark questions timed in class · first class free

Start here

Courses behind these calculations

The 417 course whose Class 10 batch drills these tables, Python for students who want to check their TFIDF in code, and Data Science for the counting and table habits underneath.

Ans. The short version

Bag of words class 10 AI is the method in CBSE 417 Unit 6 that turns text into numbers: normalise the corpus, list every unique word as the dictionary, then write each document as a row of word counts, called the document vector table. TFIDF then weighs each count. Following the CBSE handbook, IDF(W) = total documents / documents containing W, and TFIDF(W) = TF(W) x log10(IDF(W)), so a word found in every document scores 0. Modern Age Coders practises these tables live in a Monday and Wednesday 9:00 PM IST batch, or personalised one to one.

Q1. What is it?

What is Bag of Words in Class 10 AI?

Bag of Words is an NLP model that represents each document by how many times every word of the corpus occurs in it, ignoring grammar and word order. The name fits: the words are tipped into a bag and only counted.

The algorithm in four steps

  1. Normalise the text

    Clean all the documents together: split, tokenise, drop stopwords and symbols, lower the case, reduce words to their base.

  2. Create the dictionary

    List each unique word of the normalised corpus once. This list is also called the vocabulary.

  3. Make a vector for one document

    Under every dictionary word, write how many times it appears in that document.

  4. Repeat for every document

    Stack the rows and you have the document vector table, ready for TFIDF.

What the model gives, and what it loses

  • Gives: a fixed-length row of numbers for every document, which a machine can compare and learn from.
  • Gives: a quick view of which words dominate each document.
  • Loses: order. "Dog bites man" and "man bites dog" get the same vector.
  • Loses: importance. A common word gets a big count without telling documents apart, which is the problem TFIDF fixes.

Bag of Words and TFIDF are part of the theory half of Unit 6 in the 2026-27 curriculum, so a calculation on a small corpus is fair game for a four-mark question. The other Unit 6 topics, the stages, chatbots and applications, are answered on NLP class 10 questions and answers.

Q2. Clean the corpus

Text normalisation steps on our three documents

We start from three raw sentences. The stopword list is stated up front, because an examiner marks you on the list you declare, and different lists give different dictionaries.

Raw corpusN = 3 documents
D1: Meera feeds the stray dogs, and the
    dogs wag their tails at Meera.
D2: The stray dogs follow Meera to school.
D3: Dogs sleep in the sun after school.

Stopwords used: the, and, their, at,
to, in, after

Each document is a single sentence, so sentence segmentation gives three sentences.

StepD1D2D3
Tokens (words and marks)1588
After stopwords and punctuation goMeera feeds stray dogs dogs wag tails Meerastray dogs follow Meera schoolDogs sleep sun school
Lower case, then lemmatisemeera feed stray dog dog wag tail meerastray dog follow meera schooldog sleep sun school
Words left854

The dictionary

Reading the cleaned lists left to right and keeping each new word once gives ten words:

meera, feed, stray, dog, wag, tail, follow, school, sleep, sun

Note that repeats inside D1 (dog twice, meera twice) still give one entry each. The dictionary counts kinds of word, not occurrences.

Where students slip

  • Counting D1 as 13 tokens: the comma and the full stop are tokens too, so it is 15.
  • Keeping "Dogs" and "dog" as two entries because the case or the plural was not fixed.
  • Changing the stopword list halfway. Declare it once and apply it to every document.

Q3. Count the words

The document vector table, and term frequency

A document vector table has one row per document and one column per dictionary word; each cell is the number of times that word occurs in that document. Those cells are the term frequencies, TF, that TFIDF needs.

Document vector tablerows = documents, cells = TF
     meera feed stray dog wag tail follow school sleep sun
D1     2    1     1    2   1    1     0      0     0    0
D2     1    0     1    1   0    0     1      1     0    0
D3     0    0     0    1   0    0     0      1     1    1

Read across a row to get that document's vector. D2's vector is [1, 0, 1, 1, 0, 0, 1, 1, 0, 0].

Check 1: row totals

Each row should add up to the words left after cleaning: 8 for D1, 5 for D2, 4 for D3. If it does not, a word was missed or double counted.

Check 2: no empty column

Every dictionary word came from some document, so every column has at least one non-zero cell.

Presence or count?

Some textbook examples only mark 1 for present and 0 for absent. In a TFIDF question you need the true counts, so D1's dog is 2, not 1.

Q4. Weigh the words

TFIDF class 10: a term frequency inverse document frequency example

TFIDF scores a word high when it is frequent in one document but rare across the corpus. We use the CBSE handbook convention: IDF(W) = N / DF(W), written as a fraction, and TFIDF(W) = TF(W) x log10(IDF(W)), where N is the number of documents and DF(W) is how many documents contain W.

WordDFIDF = 3 / DFlog10(IDF)TFIDF D1TFIDF D2TFIDF D3
meera23/20.1760.3520.1760
feed13/10.4770.47700
stray23/20.1760.1760.1760
dog33/30000
wag13/10.4770.47700
tail13/10.4770.47700
follow13/10.47700.4770
school23/20.17600.1760.176
sleep13/10.477000.477
sun13/10.477000.477

One cell, written as the examiner wants it

TFIDF(meera) in D1 = TF x log10(N / DF) = 2 x log10(3 / 2) = 2 x 0.176 = 0.352.

TFIDF(dog) in D1 = 2 x log10(3 / 3) = 2 x log10(1) = 2 x 0 = 0.

Show TF, the fraction, the log and the product for at least one word; then the rest can go straight into the table. Log values are rounded to three decimal places throughout.

Reading the result

  • dog scores 0 everywhere, even with TF 2 in D1, because it is in all three documents. It behaves like a stopword for this corpus.
  • feed, wag and tail are D1's most telling words at 0.477 each: they appear nowhere else.
  • sleep and sun identify D3; follow identifies D2.
  • meera in D1 beats stray (0.352 against 0.176) only because it occurs twice there.
Check it in Pythonmath.log10, no libraries
import math

docs = [["meera", "feed", "stray", "dog", "dog", "wag", "tail", "meera"],
        ["stray", "dog", "follow", "meera", "school"],
        ["dog", "sleep", "sun", "school"]]

vocab = []
for d in docs:
    for w in d:
        if w not in vocab:
            vocab.append(w)

N = len(docs)
for w in vocab:
    df = sum(1 for d in docs if w in d)
    scores = [round(d.count(w) * math.log10(N / df), 3) for d in docs]
    print(w, df, scores)

The lists are the cleaned documents from the table above. d.count(w) is TF; N / df is the handbook's IDF.

Outputword, DF, TFIDF in D1 to D3
meera 2 [0.352, 0.176, 0.0]
feed 1 [0.477, 0.0, 0.0]
stray 2 [0.176, 0.176, 0.0]
dog 3 [0.0, 0.0, 0.0]
wag 1 [0.477, 0.0, 0.0]
tail 1 [0.477, 0.0, 0.0]
follow 1 [0.0, 0.477, 0.0]
school 2 [0.0, 0.176, 0.176]
sleep 1 [0.0, 0.0, 0.477]
sun 1 [0.0, 0.0, 0.477]

Matches the hand-worked table cell for cell. Programs like this belong in the practical file too; see Python for CBSE Class 10 AI.

Q5. Practise the sums

TFIDF class 10 numericals, and the formula traps

Short calculations in the shape objective and short-answer questions take. Use log to base 10, as the handbook does, and round to three places.

  1. A corpus has 8 documents. "monsoon" occurs 3 times in one document and appears in 2 documents in all. Find its TFIDF in that document.
    Answer 3 x log10(8 / 2) = 3 x log10(4) = 3 x 0.602 = 1.806.
  2. In the same corpus, "is" appears in all 8 documents. What is its TFIDF in any document?
    Answer 0, because log10(8 / 8) = log10(1) = 0, whatever its TF.
  3. "glacier" appears once, in one document out of 8. Its TFIDF there is
    Answer 1 x log10(8 / 1) = 0.903, the largest value any single occurrence can reach in this corpus.
  4. "river" appears twice in a document and in 5 of the 8 documents. Find its TFIDF.
    Answer 2 x log10(8 / 5) = 2 x log10(1.6) = 2 x 0.204 = 0.408.
  5. Which has the higher TFIDF: a word with TF 1 found in 1 of 8 documents, or a word with TF 3 found in 2 of 8?
    Answer The second: 1.806 against 0.903. Rarity helps, but frequency in the document multiplies it.
  6. Name two applications of TFIDF.
    Answer Any two of: document classification, topic modelling, information retrieval (search), and stopword filtering.

Why sites give different numbers

ConventionWord in 1 of 3 docs, TF 1Use in the exam?
CBSE handbook: TF x log10(N / DF)0.477Yes
Same idea written as IDF = log10(N / DF)0.477Same numbers, different labels
Natural log: TF x ln(N / DF)1.099No
Smoothed, as in scikit-learn: ln((1 + N) / (1 + DF)) + 11.693No

The handbook calls the fraction N / DF the IDF and applies the log in the TFIDF step. Many websites put the log inside IDF instead. With base 10 the final TFIDF is identical, so either layout earns the marks as long as you are consistent. A Python library run with default settings will not match the handbook, so never copy a library's output into a written answer.

More one-mark items on this topic sit beside every other unit on Class 10 AI MCQ with answers, and every formula of the course is on one page at the CBSE Class 10 AI formula sheet.

Q6. How is it practised?

How the live class makes a TFIDF question routine

A TFIDF question is long but not hard. Marks are lost to one missed token, one wrong document frequency or a calculator set to the wrong log. Practice under a teacher's eye removes those slips.

Worked once, together

On Monday the teacher builds a corpus with the class, and students call out each cell of the vector table before it is filled in, so the method is shared and every row is checked aloud.

Then alone, timed

On Wednesday each student gets a fresh three- or four-document corpus and a four-mark time limit. Answers are marked on screen against a scheme: dictionary, vectors, IDF, TFIDF, each worth its share.

Calculator and code

Students learn which key gives log to base 10 on their own calculator, and those who want it write the short Python checker above for their practical file.

TFIDF questions also turn up inside full papers on the sample paper and mock tests page, and the model answers for other long questions are on CBSE Class 10 AI important questions.

Batch or personalised: you choose

Practise Bag of Words and TFIDF in the batch, or one to one

In the batch, TFIDF comes in its place in Unit 6 and returns in every mock. One to one can start straight at the table your child gets wrong, whether that is tokens, document frequency or the log. Monthly billing, no admission fee, stop whenever a month ends.

Option 1 · Fixed batch timings

Group batch, Monday and Wednesday 9 PM

₹1,499

per month, two live classes a week

  • Monday and Wednesday, 9:00 PM IST, live on video
  • Fifteen to twenty Class 10 AI students, one teacher
  • Corpora worked together, then solved alone under time
  • Four-mark TFIDF answers marked step by step on screen
  • TFIDF inside full mock papers from December
Book a free demo in this batch

Option 2 · Choose your own timing

Personalised one to one

₹4,999

per month, one private class a week, at a time set with you

  • Your days and hour, in your own time zone
  • Fresh corpora until every table comes out right first time
  • The exact step that slips is found and fixed
  • Optional Python checker written together
  • Same CBSE 417 syllabus and teachers as the batch
Ask for a personalised plan

A student who understands the idea but keeps making arithmetic or counting slips usually needs only a few one to one sessions of timed corpora. A student meeting NLP for the first time is better in the batch, where the whole unit is built up in order. Fees show in your own currency.

Studying outside India?

Bag of Words and TFIDF practice for CBSE students abroad

The same handbook formula is examined in CBSE schools in the UAE, Saudi Arabia, Qatar and Kenya. Here is when the batch meets in your local time this winter.

Where you liveMon and Wed 9:00 PM ISTBest format
India (IST)
every Indian city
9:00 PMBatch fits
UAE and Oman
Dubai, Abu Dhabi, Sharjah, Muscat
7:30 PMBatch fits
Saudi Arabia, Qatar, Kuwait, Bahrain
Riyadh, Jeddah, Dammam, Doha, Kuwait City, Manama
6:30 PMBatch fits
Nepal
Kathmandu
9:15 PMBatch fits
Ethiopia and East Africa
Addis Ababa and East Africa Time
6:30 PMBatch fits
Singapore and Malaysia
Singapore, Kuala Lumpur
11:30 PMChoose 1-on-1

If the 9:00 PM IST class is too late for you, one to one runs at a local hour you pick. See CBSE Class 10 AI online classes in the Gulf and abroad for more.

What families say

Rated 4.9 across 547 Google reviews

Real reviews from real families. We neither write nor commission them.

★★★★★

"The one step solution for my son. Modern Age Coders make learning coding so simple that kids love it. The teachers explain complex concepts clearly with practical exercises and interactive content."

Ria Mukherjee

Parent

★★★★★

"Modern Age Coders has been a game-changer for me. I struggled to grasp IT concepts and coding before joining, but their classes transformed everything. I can now confidently write complex programs with ease."

Samriddha Mondal

Student

★★★★★

"One of the most wonderful education centres out there. Education is not limited to school syllabus but focuses on skill development."

Vansh Agarwal

Student

★★★★★

"My child Dhairya is really enjoying the Modern Age Coders classes. This is his first online class and he eagerly looks forward to it. I can already see his improvement, and the teachers are very cooperative."

Sonam Oswal

Parent of Dhairya

★★★★★

"Modern Age Coders have wonderful teachers who teach in a clear, easy and practical way. The teacher boosts students' confidence and inspires them to learn without hesitation."

Sonu Goyal

Parent

★★★★★

"I highly recommend this computer coding class! The teachers are incredibly knowledgeable and passionate about coding."

Ritu Kedia

Parent

The rest of the Class 10 series

More pages for Class 10 board students

Every page in the CBSE Class 10 AI (417) series, grouped by what you need: classes, each unit, question practice, notes and revision, and the exam itself.

ICSE Class 10 Computer Applications (Java): The Tue and Wed ICSE Java batch ICSE Computer Applications syllabus ICSE Java programs practice ICSE CA important questions

Questions about Bag of Words and TFIDF

Bag of Words and TFIDF in Class 10 AI: common questions

What is bag of words in class 10 AI?

It is the NLP model that turns each document into a row of word counts. You normalise the corpus, list every unique word as the dictionary, then count how often each dictionary word appears in each document. Order and grammar are ignored; only counts matter. It is part of Unit 6 of CBSE 417.

What is the TFIDF formula in class 10 AI?

The CBSE handbook uses TFIDF(W) = TF(W) x log(IDF(W)), with IDF(W) = total number of documents divided by the number of documents containing W, and log to base 10. TF is the count of the word in that document, read from the document vector table.

What is a document vector table?

A table with one row per document and one column per dictionary word. Each cell holds how many times that word appears in that document. A single row is that document's vector, and the cells are the term frequencies used in TFIDF.

Why is TFIDF zero for some words?

If a word appears in every document, IDF = N / N = 1 and log10(1) = 0, so its TFIDF is 0 however often it occurs. Such a word cannot tell documents apart, which is why very common words behave like stopwords.

Which log is used for TFIDF in CBSE class 10?

Log to base 10. The handbook says so directly. On a calculator use the log key, not ln. Using the natural log gives larger numbers, for example 1.099 instead of 0.477 for a word in one of three documents. Check your calculator once before the exam: log10 of 100 should show 2.

Can you give a term frequency inverse document frequency example?

In a corpus of 8 documents, a word appearing 3 times in one document and in 2 documents overall has TFIDF = 3 x log10(8 / 2) = 3 x 0.602 = 1.806. A word in all 8 documents scores 0. The full three-document example on this page shows every table.

What are the text normalisation steps before Bag of Words?

Split the corpus into sentences, break them into tokens, remove stopwords and punctuation, put everything in lower case, then stem or lemmatise. State your stopword list first, because it decides what reaches the dictionary. Then show the cleaned text of every document, since the examiner checks your vector table against it, and a slip at this stage carries through every later table.

Do I write TF as a count or as a fraction of the document length?

For CBSE 417, as a count: the handbook reads TF straight from the document vector table. Some websites divide by the document length; that is a different convention and will not match the scheme. In our worked corpus, dog has TF 2 in the first document, not 2 out of 8, and that count is what you multiply by the log.

Is a TFIDF calculation asked in the board exam?

TFIDF is listed under text processing in the theory part of Unit 6 for 2026-27, and a small-corpus calculation suits a four-mark question. The 2026-27 sample paper for 417 is not out yet, so we cannot say exactly how it will be asked this year.

Is this practised in your classes?

Yes. Corpora are worked together on Monday and solved alone under time on Wednesday, with each step marked on screen, and TFIDF appears in the full mocks. It is covered by the monthly fee shown on this page, for the batch or one to one. The first class is a free demo.

Start

Work a corpus with a teacher, free

In the free first class your child normalises a short three-document corpus, builds the vector table and computes two TFIDF values with the teacher watching each step. Afterwards the mentor tells you where the method holds and where it slips, and whether the batch or one to one would be the better fit.

The rest of the unit, from stages to chatbots, is on NLP class 10 questions and answers.

WhatsApp us · +91 91233 66161 · connect@modernagecoders.com

Every class is live video. The form requests a callback and reserves nothing.

We call within a few hours. No card, no enrolment fee.

Want it sooner? Book a priority demo

A full live class of about 45 to 60 minutes at a slot you pick, with a written skill report and learning roadmap on WhatsApp afterwards. The fee is adjusted against your first month if you enrol.

Book a priority demo

Keep exploring Modern Age Coders

By class and age

Learn more

Free resources

From the blog

Start here