★★★★★
"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
CBSE Class 10 · Artificial Intelligence, code 417 · Unit 6 calculations, 2026-27
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
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.

The batch / 417 Class 10
Unit 6 taught in full, with Bag of Words and TFIDF worked on new corpora until students can do a four-mark question without notes.
Open the course →
Check it / Python
Lists, loops and the math module: enough Python to write the ten-line TFIDF checker on this page yourself.
Open the course →
Tables / Data Science
Counting, frequency tables and reading numbers in context, the skills a TFIDF table quietly depends on.
Open the course →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?
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.
Clean all the documents together: split, tokenise, drop stopwords and symbols, lower the case, reduce words to their base.
List each unique word of the normalised corpus once. This list is also called the vocabulary.
Under every dictionary word, write how many times it appears in that document.
Stack the rows and you have the document vector table, ready for TFIDF.
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
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.
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.
| Step | D1 | D2 | D3 |
|---|---|---|---|
| Tokens (words and marks) | 15 | 8 | 8 |
| After stopwords and punctuation go | Meera feeds stray dogs dogs wag tails Meera | stray dogs follow Meera school | Dogs sleep sun school |
| Lower case, then lemmatise | meera feed stray dog dog wag tail meera | stray dog follow meera school | dog sleep sun school |
| Words left | 8 | 5 | 4 |
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.
Q3. Count the words
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.
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].
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.
Every dictionary word came from some document, so every column has at least one non-zero cell.
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 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.
| Word | DF | IDF = 3 / DF | log10(IDF) | TFIDF D1 | TFIDF D2 | TFIDF D3 |
|---|---|---|---|---|---|---|
| meera | 2 | 3/2 | 0.176 | 0.352 | 0.176 | 0 |
| feed | 1 | 3/1 | 0.477 | 0.477 | 0 | 0 |
| stray | 2 | 3/2 | 0.176 | 0.176 | 0.176 | 0 |
| dog | 3 | 3/3 | 0 | 0 | 0 | 0 |
| wag | 1 | 3/1 | 0.477 | 0.477 | 0 | 0 |
| tail | 1 | 3/1 | 0.477 | 0.477 | 0 | 0 |
| follow | 1 | 3/1 | 0.477 | 0 | 0.477 | 0 |
| school | 2 | 3/2 | 0.176 | 0 | 0.176 | 0.176 |
| sleep | 1 | 3/1 | 0.477 | 0 | 0 | 0.477 |
| sun | 1 | 3/1 | 0.477 | 0 | 0 | 0.477 |
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.
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.
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
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.
| Convention | Word in 1 of 3 docs, TF 1 | Use in the exam? |
|---|---|---|
| CBSE handbook: TF x log10(N / DF) | 0.477 | Yes |
| Same idea written as IDF = log10(N / DF) | 0.477 | Same numbers, different labels |
| Natural log: TF x ln(N / DF) | 1.099 | No |
| Smoothed, as in scikit-learn: ln((1 + N) / (1 + DF)) + 1 | 1.693 | No |
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?
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.
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.
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.
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
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
₹1,499
per month, two live classes a week
Option 2 · Choose your own timing
₹4,999
per month, one private class a weektwo private classes a week, at a time set with you
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?
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 live | Mon and Wed 9:00 PM IST | Best format |
|---|---|---|
| India (IST) every Indian city | 9:00 PM | Batch fits |
| UAE and Oman Dubai, Abu Dhabi, Sharjah, Muscat | 7:30 PM | Batch fits |
| Saudi Arabia, Qatar, Kuwait, Bahrain Riyadh, Jeddah, Dammam, Doha, Kuwait City, Manama | 6:30 PM | Batch fits |
| Nepal Kathmandu | 9:15 PM | Batch fits |
| Ethiopia and East Africa Addis Ababa and East Africa Time | 6:30 PM | Batch fits |
| Singapore and Malaysia Singapore, Kuala Lumpur | 11:30 PM | Choose 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
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
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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