Objective. Students produce a fully reproducible analytical notebook in Jupyter and an R Markdown report that a classmate can re-run from scratch on a fresh environment and obtain identical output.
This lesson, its worked examples and its practice questions has not yet been verified by an industry-certified professional or by a certification or approval body. It is a study draft and may contain errors. Do not use it as instructions for work on a job site or on live equipment. Always follow your instructor, your supervising professional, and current official references and regulations.
VoTechWorks program approval and accreditation are still in progress. Credentials are issued only by the certifying bodies named in each program, after their own exams.
Reproducibility is the ability of another analyst — or your future self — to re-run your analysis on a fresh machine and obtain exactly the same output. In data science, a result that cannot be reproduced is a result that cannot be trusted. Industry certifications, including the IBM Data Science Professional Certificate, treat reproducibility as a core professional competency, not an optional nicety. Employers expect that deliverables handed off between team members, or submitted for audit, will run cleanly without undocumented manual steps.
Environment drift happens when your code depends on a specific version of a library that is not recorded anywhere. A teammate installs a newer version of pandas or ggplot2, runs your notebook, and gets different results or an outright error. The fix is to capture every dependency and its version before you share your work.
Hidden execution state happens when a Jupyter notebook has been run out of order — cell 10 before cell 3 — leaving variables in memory that a fresh run would never create. A notebook that produces correct output in its current session but fails on a clean restart is not reproducible. Always restart the kernel and run all cells top-to-bottom before declaring a notebook complete.
A `requirements.txt` file is a plain-text list of every Python package your project needs, pinned to an exact version. You generate it inside your active virtual environment with:
```
pip freeze > requirements.txt
```
A collaborator who clones your repository recreates the same environment with:
```
python -m venv env
source env/bin/activate # Windows: env\Scripts\activate
pip install -r requirements.txt
```
Keep the file in the root of your repository alongside your notebooks. Without it, environment setup becomes guesswork.
A well-structured notebook reads like a technical report. Apply these practices:
1. One imports cell at the top. All `import` statements go in the first code cell so every dependency is visible immediately.
2. Relative paths only. Never hard-code a path like `C:/Users/maria/Desktop/data.csv`. Use relative paths such as `../data/sales.csv` so the notebook works on any machine where the repository structure is intact.
3. Markdown between every major section. Add a Markdown cell above each logical block explaining what the code does and why. This turns a script into a narrative.
4. Functions instead of repeated code. If you copy and paste a block of code more than once, wrap it in a function. Place all helper functions in an early cell or, for larger projects, in a separate `.py` module that the notebook imports.
5. Restart and run all before sharing. Use Kernel → Restart & Run All and confirm every cell completes without error.
R Markdown combines prose, code, and output in a single `.Rmd` file that is knitted into HTML, PDF, or Word. Because knitting always executes code in a clean R session from top to bottom, an R Markdown report is naturally more resistant to hidden-state problems than an interactive session.
Key practices:
Git and GitHub are not just for software developers. Committing your notebook and all supporting files — data (if small), `requirements.txt`, and the `.Rmd` file — creates a timestamped record of every change. If a partner cannot reproduce your results, you can both check out the same commit and eliminate version differences as a cause. Use `.gitignore` to exclude large data files, virtual environment folders, and rendered HTML that should be re-generated locally.
Data science labs do not involve physical hazards requiring PPE, but professional data handling standards apply. Never commit real personal or proprietary data to a public repository. Use anonymized sample datasets for all lab exercises. If a dataset contains identifiers, remove or mask them before sharing. Treat credentials (API keys, database passwords) as secrets: store them in environment variables or a `.env` file that is listed in `.gitignore`, never hard-coded in a notebook cell.
Answer each question, then check it. Nothing is recorded; this is your own practice.
A free tech program — complimentary, as our commitment to get America working. Help us build VoTechWorks. Tell us what works, what doesn’t, and what you want to learn.