🚀 Stage 1 of 13
←
→
← Previous — Stage 0
Why this project? The 5-layer motive
Meet the dataset — 4 questions you always ask
head(), shape, info(), describe(). The 4 questions you ask of ANY dataset before touching ML.
🧠 The intuition
Before you train anything, you must answer 4 questions about the data. These 4 questions are non-negotiable — skipping them is the #1 cause of broken ML projects.
1. head() -> what does a row LOOK like? (columns, value shapes)
2. shape -> how many rows x columns? (is there enough data?)
3. info() -> what type is each column? are there nulls?
4. describe() -> what's the range/mean/std of each numeric column?
If you can answer all 4 in one sentence each, you understand the dataset. If you can't, you're not ready to model it.
✏️ Tiny task — write this yourself
Run these 4 commands on the students.csv below and write down ONE sentence you learn from each.
import pandas as pd
df = pd.read_csv('students.csv')
df.head()
df.shape
df.info()
df.describe()
✅ Check — what you should see
You should learn something like:
head() -> each row is 1 student, columns are study_hours, attendance, ...
shape -> 1000 rows x 8 columns (enough for ML)
info() -> all numeric, no nulls (lucky us)
describe() -> final_score ranges 0-100, mean 67, std 14
🧮 Code files for this stage
📄
data/students.csv
csv
student_id,study_hours,previous_score,attendance,assignments_completed,sleep_hours,extracurricular_hours,parental_support,final_score 1,4.5,72,85,8,7,2,3,68 2,6.0,81,92,10,7,1,4,79 3,2.0,55,60,4,6,4,2,51 4,7.5,88,95,10,8,0,5,91 5,3.0,65,72,6,5,3,3,62 6,5.5,78,88,9,7,2,4,76 7,1.5,45,55,3,5,5,1,42 8,8.0,92,98,10,8,1,5,95 9,4.0,68,80,7,6,2,3,66 10,6.5,85,90,10,7,0,4,83 ... (1000 rows total)
📄
explore.py
python
import pandas as pd
df = pd.read_csv('data/students.csv')
# Question 1: what does a row look like?
print(df.head())
# Question 2: how big is the dataset?
print(df.shape) # (1000, 8)
# Question 3: types + nulls?
print(df.info())
# Question 4: spread of numeric columns?
print(df.describe())
How it works
head() shows the first 5 rows so you can see what a 'record' actually looks like — is it a student? a transaction? an image? shape tells you if you have enough data (100 rows = too few, 1M rows = too slow for this project). info() reveals nulls and type mismatches — study_hours as a string instead of a float is a classic bug. describe() gives you the statistical sanity check — if final_score's max is 250, something is wrong with the data.
🚧 Routes — what's wired up at this stage
Still no routes. This stage is pure pandas — runs in a Jupyter cell, a Python REPL, or our /notebook. No web server needed yet.
🧮 Is a response model necessary here?
NO — use response_class=HTMLResponse
Pandas doesn't need a Pydantic response model — it's a data-analysis library, not a web framework. The response model question only becomes real when FastAPI enters at Stage 8.
⚠️ Common mistakes to avoid
- Skipping info() and being surprised by nulls at training time.
- Not noticing a column is a string when it should be a number — pandas will keep it as object dtype and sklearn will crash later.
- Looking at describe() but not asking 'does this make sense?' — if sleep_hours has a max of 24, fine; if it has a max of 50, the data is broken.
Next — Stage 2
3 plots that tell you if ML is even possible