Overfitting, Underfitting & Train-Test Split in CBSE AI

⚡ Direct Answer & Key Takeaway

Underfitting occurs when a model is too simple to learn data patterns, giving high error on both training and test sets. Overfitting occurs when a model memorizes training noise, giving very low training error but poor test accuracy. To detect overfitting before deployment in CBSE AI (Code 417 & 843), split data into separate Training (commonly 70–80%) and Testing (20–30%) subsets so unseen generalization is measured honestly.

1. Diagnosing Underfitting vs Overfitting from Error Scores

Think of preparing for a CBSE board exam using practice papers. A model that underfits is like someone who skimmed one summary page: it scores poorly on practice questions (high training error) and equally poorly in the final exam (high test error). Underfitting happens when the algorithm lacks capacity—such as fitting a straight line to curved housing prices—or stops training too early. Overfitting is the opposite failure: memorizing the exact question numbers and answers of 50 practice sheets. That model scores 99% on training data yet drops to 61% on fresh test data because it memorized random fluctuations instead of general rules. A healthy 'Good Fit' sits between these extremes, achieving low training error and closely matching low test error.

  • Underfitting (High Bias): High training error AND high test error.
  • Overfitting (High Variance): Near-zero training error, sharp jump in test error.
  • Good Fit: Low training error with small gap to test error.

2. Why Train-Test Split Prevents Data Leakage

In CBSE Class 10 Unit 7 and Class 12 Code 843 (Data Science & Evaluation), evaluating a model on the exact rows it trained on is strictly discouraged because memorized answers inflate Accuracy artificially. Splitting the dataset into a Training set (typically 80% or 70%) and a Testing set (20% or 30%) simulates real-world deployment on unseen examples. Before splitting, rows are shuffled so class distributions stay balanced—for instance, if a CSV is sorted with all 'Pass' rows first and 'Fail' rows last, an unshuffled 80/20 split would put zero 'Fail' cases in training. For smaller datasets in Class 12 Practicals (50 marks), cross-validation (k-fold) rotates the test fold across all slices so every row is tested fairly.

  • Standard ratios: 80% Train / 20% Test or 70% Train / 30% Test.
  • Always shuffle (or use stratified splitting) so class proportions match in both splits.
  • Never fit scalers or encoders on the full dataset before splitting; fit on Train only.

3. Fixing Fit Problems in Board Exams and Python Labs

CBSE Part B (40 marks) short-answer questions frequently give a table of train versus test accuracy and ask you to name the problem and suggest a remedy. To fix Underfitting, increase model complexity (e.g., use a deeper decision tree or polynomial features), add informative features, or train longer. To fix Overfitting, collect more diverse training samples, reduce model complexity (prune tree depth or lower polynomial degree), apply regularization, or drop noisy irrelevant columns. In Class 12 Code 843 practicals (50 marks), examiners also expect you to inspect Root Mean Squared Error (RMSE) or accuracy across both splits side-by-side—for example, RMSE = 1.2 on Train vs 14.8 on Test signals severe overfitting that pruning or more data will correct.

  • Cure Underfitting: richer features, deeper model, longer training.
  • Cure Overfitting: more training data, simpler/pruned model, feature selection.
  • Compare Train vs Test metrics side-by-side in every 50-mark Practical notebook.

4. Deterministic Train-Test Split and Fit Diagnostics in Python

import random

dataset = [(x, 2 * x + 1) for x in range(1, 21)]
random.Random(42).shuffle(dataset)

split_idx = int(0.8 * len(dataset))
train_set = dataset[:split_idx]
test_set = dataset[split_idx:]

def diagnose_fit(train_acc, test_acc):
    if train_acc < 0.70 and test_acc < 0.70:
        return "Underfitting"
    if train_acc - test_acc > 0.15:
        return "Overfitting"
    return "Good Fit"

print(f"Train={len(train_set)}, Test={len(test_set)}")
print("Model A:", diagnose_fit(0.98, 0.64))
print("Model B:", diagnose_fit(0.60, 0.58))
print("Model C:", diagnose_fit(0.91, 0.88))

Verified Console / Dry-Run Output:

Train=16, Test=4
Model A: Overfitting
Model B: Underfitting
Model C: Good Fit

5. Diagnosing Model Fit from CBSE Train vs Test Performance

Model BehaviorTrain ScoreTest ScoreDiagnosis & Action
Linear line on curved data62% Acc60% AccUnderfitting: add polynomial features or richer model
Unpruned deep decision tree99% Acc66% AccOverfitting: prune depth or add more training samples
Balanced regularized model91% Acc88% AccGood Fit: generalizes well to unseen test inputs
Evaluated on training set only100% AccNot testedData Leakage risk: perform proper 80/20 Train-Test split
🎯 1-on-1 Live Mentorship & Free Study Kit

Build Models That Truly Generalize

Practice Train-Test splits, cross-validation, and Part B fit diagnostics with 4Achievers Junior in 1-on-1 or 1:4 Micro-Pods.

💬 WhatsApp Now
🔒 Instant WhatsApp notes + free 60-min 1-on-1 trial session
Confirmed! Our Senior Mentor is sending your study kit & free 1-on-1 demo link on WhatsApp now.

6. Common Mistakes & Top Scorer Tips

  • Avoid Mistake: Testing a classifier on the same rows used for training and claiming 100% real-world accuracy.
  • Avoid Mistake: Confusing Underfitting (bad on both train and test) with Overfitting (great on train, bad on test).
  • Avoid Mistake: Splitting a sorted dataset sequentially without shuffling, leaving one class completely out of training.
  • Examiner / Mentor Tip: Quote exact Train vs Test numbers when justifying Overfitting or Underfitting in Part B answers.
  • Examiner / Mentor Tip: Explain random_state / seed in your Practical viva: it makes the Train-Test split reproducible.
  • Examiner / Mentor Tip: Connect Model Evaluation (Unit 7 in Code 417) to why unseen test data acts as a realistic board exam.

7. Interactive Concept Check Quiz

Question: A student's AI classifier achieves 99.2% accuracy on the training set but drops to 63.5% on the 20% test split. What is the model experiencing, and which fix helps?

8. Frequently Asked Questions

What is the standard Train-Test split ratio recommended in CBSE AI?
CBSE AI courses commonly use 80% Training and 20% Testing (or 70% / 30%) depending on total dataset size.
Can you ever use the test set while tuning hyperparameters?
No. Tuning directly on the test set leaks test information; instead, hold out a validation split or use k-fold cross-validation on the training data.
Why does memorizing training data hurt performance on new inputs?
Training data always contains measurement noise and coincidental patterns. Memorizing those quirks breaks predictions when fresh unseen data arrives.

Explore Related Lessons & Free Interactive Tools

Free 1-on-1 Session

Book a Free Demo Class