Day 01 — Machine Learning Basics¶
You spent Week 1 learning how to load, clean, and describe data. Week 2 is about making data do work. This session is where the shift happens: from "what does the data look like?" to "what can the data predict?"
Before writing a single line of sklearn code, you need to understand three things that most tutorials skip. Why ML is not always the right tool. Why your accuracy score can lie to your face. And why a bad split can invalidate months of work. Get these right and the rest of Week 2 clicks into place.
Session Overview
Difficulty: Beginner Reading time: ~2 hours | Exercises: ~1.5 hours Prerequisites: Python functions and loops · Pandas DataFrames (filtering, groupby) · Basic statistics (mean, variance, distributions) · Plotting with Matplotlib
What You Will Cover¶
| # | Topic | File |
|---|---|---|
| 1 | What Is Machine Learning? | 01-what-is-machine-learning |
| 2 | Supervised vs Unsupervised Learning | 02-supervised-unsupervised |
| 3 | Train/Test Split and Data Leakage | 03-train-test-split-and-leakage |
| 4 | Scikit-learn Workflow | 04-scikit-learn-workflow |
| 5 | Exercises | 05-exercises |
Learning Objectives¶
By the end of this session you will be able to:
- Explain what machine learning is and, critically, when not to use it
- Distinguish supervised, unsupervised, and reinforcement learning, and map any new problem to the right category
- Identify features and target variables in a real dataset
- Split data into train, validation, and test sets correctly — and explain why the split is a fundamental requirement, not a convention
- Recognise data leakage in its common forms and explain why it produces misleadingly good results
- Build a complete sklearn pipeline from raw data to evaluation score
- Interpret cross-validation output without over-reading it
Prerequisites¶
You should be comfortable with:
- Python: functions, list comprehensions, basic OOP
- NumPy: arrays, broadcasting, vectorised operations
- Pandas: DataFrames, groupby, merge, handling nulls
- EDA workflow: distribution analysis, correlation, outlier detection
- Basic statistics: mean, variance, distributions, correlation vs causation
If any of those feel shaky, revisit the relevant Week 1 notes before continuing.
Estimated Time¶
| Section | Reading | Exercises |
|---|---|---|
| What Is ML | 20 min | — |
| Supervised vs Unsupervised | 25 min | — |
| Train/Test & Leakage | 30 min | — |
| Sklearn Workflow | 35 min | — |
| Exercises | — | 60–90 min |
| Total | ~110 min | 60–90 min |
Environment Setup¶
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split, cross_val_score
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score, classification_report
# Confirm versions
import sklearn
print(sklearn.__version__) # Output: 1.4.x or later
Tip
Pin your sklearn version in requirements.txt. Model behaviour and default hyperparameters have changed across versions — a version mismatch is a silent bug.