Thuta Learning
ExercisesData & Databasesintermediate

Hands-On Practice Set 1

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Understand Hands-On Practice Set 1 without any of the intimidation
  • Be able to run scikit-learn code yourself
  • Apply this concept in a real project right away

Let's stop and think about this for a second

This round is about putting the Basic/Intermediate concepts you've already learned back into practice — telling apart Supervised vs Unsupervised, Regression vs Classification, hunting down errors in ML pipeline code, and correctly picking evaluation metrics. Each task shouldn't take more than 5 minutes.

Let's connect it to a real scenario

Task 1: Explain the difference between 'Supervised Learning', 'Unsupervised Learning', 'Regression', and 'Classification' in one sentence each. Task 2: Guess and write down what could go wrong if `model.fit(X_test, y_test)` were mistakenly written (X_test instead of X_train). Task 3: For a dataset with class imbalance (95% Class A, 5% Class B) that gets 95% Accuracy, explain why that should raise suspicion. Task 4: Decide which is Regression and which is Classification — house price prediction (continuous value) vs. email spam detection (category) — and explain why.

Let's look at it together

text
# Task 2 - training on test data (data leakage)
model.fit(X_test, y_test)  # WRONG! should be X_train, y_train

Result: The model has now "seen" the test data during
training. When you evaluate on X_test again, the score
will look artificially high — you're testing on data the
model already memorized, not on truly unseen data.
This completely defeats the purpose of the train/test split.

# Task 3 - suspicious 95% accuracy
If the dataset is 95% Class A, a model that ALWAYS
predicts "Class A" (ignoring the input entirely) would
still score 95% accuracy — check precision/recall/F1
for Class B before trusting this number.
You should see
You'll come away knowing the Supervised/Unsupervised difference, how to spot a data leakage bug, and awareness of class imbalance.

Try it in 5 minutes

Write your own sample ML pipeline code, deliberately mix up `X_test`/`X_train`, and run it — see for yourself how the accuracy result comes out different.

One thing to watch out for

You don't need a real dataset or a production model for this round — the focus is purely on practicing the concepts and debugging logic.

Easy traps

  • Assuming you can use 'the same evaluation approach for every ML algorithm' — R² (regression) and Accuracy/Precision/Recall (classification) are not the same thing
  • Skipping over the variable names (X_train vs X_test) during code review and missing a data leakage bug

Now try it yourself

Write your own sample ML pipeline code, deliberately mix up `X_test`/`X_train`, and run it — see for yourself how the accuracy result comes out different.

You'll know it worked when: You'll come away knowing the Supervised/Unsupervised difference, how to spot a data leakage bug, and awareness of class imbalance.

Hands-On Practice Set 1 | Thuta Learning