Class 7 · CBSE AI · Strand B — Python for AI
Your first machine learning model with scikit-learn — Class 7
Create → fit → predict: how scikit-learn trains your first ML model in a few lines. For Class 7.
Class 7 · CBSE AI · Strand B — Python for AI
Create → fit → predict: how scikit-learn trains your first ML model in a few lines. For Class 7.
UPSC exam preparation
A student who only practises last year's actual exam papers and then is tested on the same papers will score 100%. But that proves nothing about whether they can handle a new paper. The train/test split is like keeping one practice paper sealed until the actual test day.
Teaching a child to recognise mangoes
You show a child 80 mangoes of different sizes and colours and they learn what a mango looks like. Then you test them on 20 new mangoes they have never seen. That test result is the real measure of whether they learned the concept or just memorised your specific examples.
Every Dhee Learning session for this concept follows three stages. We share the questions Dhee actually asks, so you can hear what a session sounds like.
Stage 1 — Surface
You have trained a model to predict whether a student will pass. You test it on the same data you trained it on and it gets 98% accuracy. Your friend says 'amazing!' Why should you be suspicious?
Rote answer
"Because it might be overfitting"
Understood
"The model has seen all those examples before — it may have just memorised the answers rather than learned a pattern. The only fair test is data it has never seen, which is why we hold back a test set before training begins."
Stage 2 — Reasoning
In scikit-learn, you call model.fit(X_train, y_train) and then model.predict(X_test). What exactly is happening at each step — what is the model 'doing' mathematically in simple terms?
Follow-up Dhee may use: If you add more features to X_train, will the model always get better? Why or why not?
Stage 3 — Application
Using a simple dataset (e.g. iris or a student grades CSV), write a complete scikit-learn pipeline: load data, split it 80/20, train a Decision Tree, and print predictions for the test set. What is one thing that surprised you about the output?
Misconception Dhee watches for: Treating the model as a black box that magically produces answers, without any mental model of what 'fitting' means
Dhee turns this concept into a 15-minute spoken session — asking, listening, and probing — so your child builds the idea themselves.
Create → fit → predict: how scikit-learn trains your first ML model in a few lines. For Class 7.
More complex models are always better — in reality, a simple model that generalises well beats a complex model that only memorises training data
Dhee opens with a question — for example: "You have trained a model to predict whether a student will pass. You test it on the same data you trained it on and it gets 98% accuracy. Your friend says 'amazing!' Why should you be suspicious?" — listens to your child's answer, then probes the reasoning behind it. The session ends when the child can apply the idea to a brand-new situation, not just recall it.