Reproducible and shared
Last updated
The last lesson of the course makes the capstone something anyone can check: rerun from nothing on a fresh computer, with a README that says how, licences on what you made, and a repository that holds it all. Then you share it.
By the end of this lesson you can
- Rerun the whole capstone on a fresh environment and get the same results
- Write a README that lets a stranger rerun it
- Choose licences for your code, report and data
One command per stage
A stranger shouldn't have to know which notebook to run first. Put the order in a script, run_all.py, which runs every stage from raw data to report and stops at the first failure:
"""Run the whole capstone, from raw data to report.""" import subprocess import sys STEPS = [ [sys.executable, "clean.py"], [sys.executable, "-m", "jupyter", "nbconvert", "--to", "notebook", "--execute", "--inplace", "04-explore.ipynb"], [sys.executable, "-m", "jupyter", "nbconvert", "--to", "notebook", "--execute", "--inplace", "05-answer.ipynb"], ["quarto", "render", "report.ipynb", "--execute"], ] for step in STEPS: print("running:", " ".join(step[1:] if step[0] == sys.executable else step)) subprocess.run(step, check=True) # stops at the first failure print("done: see report.html")
jupyter nbconvert --to notebook --execute --inplace runs a notebook from the top in a fresh kernel and saves it with its new outputs: "Restart and run all", from the command line (10.2).
Then write the README (10.4): what the project answers, in two sentences, with a link to the report; how to set it up; how to get the raw data (a download script like the reference's get_data.py, or the steps by hand); python run_all.py; and what each file is for.
The fresh rerun
Follow your own README, word for word, in a new folder:
git clone <your repository> capstone-test cd capstone-test py -m venv .venv .venv\Scripts\activate (.venv) $ python -m pip install -r requirements.txt (.venv) $ (copy the raw files into data/raw, as the README says) (.venv) $ python fingerprint.py compare with SOURCES.md (.venv) $ python run_all.py
Then compare. Every number in the new report should match the old one. If one doesn't, find out why: an unpinned package, a missing seed, a file read from outside the project, a cell that depended on another run first (10.4). Fix the cause, not the number, and rerun until two fresh runs agree.
The fingerprints matter here: if a raw file has been re-downloaded and the publisher revised it, the fingerprint won't match SOURCES.md, and you'll know why the numbers moved.
Licences for what you made
Others can only reuse your work if you say they may. Choose a licence for each kind of thing, and put each in the repository:
| what | a common choice | means |
|---|---|---|
Code (clean.py, notebooks, dashboard) | MIT | Anyone may reuse it, keeping your copyright notice |
| Report and charts | CC BY 4.0 | Anyone may share and adapt it, with credit |
| Clean dataset | The source's licence, if it requires it; CC BY 4.0 for PSA data | Credit the source and you (C.9) |
Write the licence in a LICENSE file for the code, and say in the README which licence covers the report and the data. Your licence can't give more than the source allows: data you may not republish (C.9) stays out, whatever licence you choose.
Share it
Push the repository (Simple Git covers remotes), with the report as HTML in it or linked from the README, and share the link with the people your question was for. If your capstone answers a question someone in your community asks (a barangay office, a school, a cooperative, a local newsroom), send it to them, with the summary in the message.
Before you send it, one last pass with 10.6 in mind: no personal data, no small counts that single anyone out, and nothing the source's terms don't allow.
Finished
Tick off the whole capstone:
All ten: that’s a complete, honest, reproducible analysis of real data.
Look back at what you can do now. You can take a vague question about the Philippines, find public data that bears on it, check you're allowed to use it, clean it with code that records every change, explore it before believing it, answer with the right comparisons and say how sure you are, show it in charts that don't mislead, write it up so a busy reader gets the answer in a minute, and hand the whole thing to a stranger who can rerun it and get the same numbers.
That's what data analysis is. Well done.
Sources
Every example on this page was run with Python 3.14, and its output and error messages are copied from it. These pages cover the same ground in more depth.
- nbconvert: Executing notebooks: running notebooks from the command line
- Creative Commons: About CC licenses: licences for reports and data
- Pro Git, 2nd ed., section 2.5: Working with remotes: pushing a repository to share it