Capstone: Your Own Dataset, Start to Finish
Data Science & ML Projects (Beginner)
Chapter 8 · Capstone: Your Own Dataset, Start to Finish
The Pipeline, and What It's Demonstrated On
Palmer Penguins — real physical measurements (bill length, bill depth, flipper length, body mass) of three penguin species from Palmer Station, Antarctica, plus island and sex. It's used here specifically because, unlike Chapter 7's own squeaky-clean Iris dataset, it has real missing values and a real categorical column — giving this capstone a genuine reason to exercise every stage of the pipeline, not just the modeling step.
Stage 1 — Collect
import pandas as pd # swap this line for your own dataset: # - a downloaded CSV (as here) # - a scraped page (Chapter 1's own pattern) # - a live API, single or combined (Chapter 3's / Chapter 6's own pattern) raw = pd.read_csv("penguins.csv") print(raw.shape)
Stage 2 — Clean
def clean_penguins(df, report): before = len(df) df = df.dropna(subset=["species", "bill_length_mm"]) report.append(f"Dropped {before - len(df)} row(s) missing species or bill_length_mm.") n_sex_missing = df["sex"].isna().sum() df["sex"] = df["sex"].fillna("unknown") report.append(f"Filled {n_sex_missing} missing sex value(s) with 'unknown'.") return df report = [f"Started with {len(raw)} rows."] cleaned = clean_penguins(raw, report) report.append(f"Finished cleaning with {len(cleaned)} rows.")
Directly reusing Chapter 2's own shape: a function that cleans and appends plain-English lines to a shared report list, with the same kind of real per-column judgment call that chapter's own warn-box named — rows missing a core measurement are dropped, a missing category is labeled rather than guessed.
Stage 3 — Explore
report.append("--- Exploration ---") report.append(str(cleaned.groupby("species")["bill_length_mm"].describe()[["mean", "std"]])) report.append(f"Species counts: {cleaned['species'].value_counts().to_dict()}")
Chapter 5's own flowing, narrative style rather than a numbered checklist — a couple of well-chosen summaries, not an exhaustive re-run of every EDA step, since the real goal here is a working pipeline end to end, not a second full exploration chapter.
Stage 4 — Visualize
import seaborn as sns import matplotlib.pyplot as plt sns.scatterplot( data=cleaned, x="bill_length_mm", y="flipper_length_mm", hue="species", palette=["#15803D", "#EAB308", "#4ade80"], ) plt.title("Bill Length vs. Flipper Length by Species") plt.savefig("capstone_dashboard.png")
Stage 5 — Model
from sklearn.model_selection import train_test_split from sklearn.neighbors import KNeighborsClassifier features = ["bill_length_mm", "bill_depth_mm", "flipper_length_mm", "body_mass_g"] X = cleaned[features].dropna() y = cleaned.loc[X.index, "species"] X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) model = KNeighborsClassifier(n_neighbors=5) model.fit(X_train, y_train) accuracy = model.score(X_test, y_test) report.append(f"--- Model ---") report.append(f"KNN classifier accuracy on held-out test data: {accuracy:.2%}")
Chapter 7's own exact template — same algorithm, same honest framing (a light touch, not a substitute for ml1's own full depth) — applied here to a dataset with genuinely more real-world texture than Iris had.
Stage 6 — Report
from pathlib import Path Path("findings_report.txt").write_text("\n".join(report)) print("\n".join(report))
The same report-list pattern from Chapter 2, now spanning the entire pipeline rather than just the cleaning stage — one readable, saved artifact documenting exactly what happened to the data at every step, from raw file to trained model.
Chapter Attribution Table
| Stage | Drawn directly from |
|---|---|
| Collect | Chapter 1 (scraping), Chapter 3 (single live API), Chapter 6 (combining independent APIs) — swap freely depending on your own dataset's source |
| Clean | Chapter 2's own reusable, report-generating cleaning-function pattern |
| Explore | Chapter 5's own flowing, narrative EDA approach rather than a rigid checklist |
| Visualize | ds1-7/ds1-8's own chart-type choices, applied throughout Chapters 3-6 |
| Model | Chapter 7's own light-touch KNN classifier template |
| Report | Chapter 2's own report-list pattern, extended across the whole pipeline |
- No deep model tuning, cross-validation, or algorithm comparison — that's
ml1's own full-depth job, not this pipeline's. - No text, image, or deep-learning-shaped project —
nlp1/nn1/llm1-shaped work (like the sentiment-analyzer idea from this subject's own original roadmap brainstorm) belongs to the still-unflesheddsproj2(Intermediate), not this Beginner course. - No production deployment, scheduling, or serving — this pipeline runs once, by hand, producing local files.
- No guarantee your own chosen dataset will be as cooperative as Palmer Penguins — real data varies enormously, and adapting this template to genuine mess is expected, not a sign something went wrong.
One pipeline, swappable inputs
Every stage is written to be pointed at a different dataset with minimal changes.
The report as a real deliverable
A saved, readable summary of what happened — not just code that ran silently.
Every prior chapter, reused directly
Nothing new introduced here — this chapter's job is combination, not new material.
Honest scope, stated explicitly
What this pipeline can't do is named directly, not glossed over.
Try these on your own:
- Pick a genuinely different real dataset — one you find yourself, downloaded or scraped — and run it through this exact pipeline, adapting each stage as needed.
- Turn
findings_report.txtinto a short Markdown file with the saved chart embedded, for a more presentable finished artifact. - If your own dataset has a date column, add Chapter 4's own
.resample()trend analysis as an extra stage. - Once you've taken
ml1, swap Stage 5's KNN classifier for a properly tuned model and compare the accuracy difference honestly.
Course Complete
That's all 8 projects of Data Science & ML Projects (Beginner) — a scraper, a cleaning pipeline, a live weather dashboard, a pandas-powered finance analyzer, a full EDA, a multi-source API aggregator, a first classifier, and this capstone — combining ds1's own data-handling toolkit with one light, honest taste of ml1. The still-unfleshed dsproj2 (Intermediate) remains as the final piece of the Data Science & ML subject's own six-course roadmap, and is exactly where NLP-shaped projects like a real sentiment analyzer belong.
Chapter 8 Quick Reference — Course Summary
- The full pipeline: collect (1/3/6) → clean (2) → explore (5) → visualize (3-6) → model (7) → report (2, extended)
- Demonstrated on Palmer Penguins purely as a worked illustration — every stage is meant to be swapped for the reader's own real dataset
- The findings report is a genuine, saved deliverable, not just code that ran and printed to a terminal
- Honest scope: no deep model tuning, no NLP/deep-learning work (that's dsproj2's own job), no production deployment
- This completes the Data Science & ML Projects, Beginner course (8 chapters)