Course contents
AppendixAppendices
Exercise solutions: where to find them (Chapters 1 to 18)
On this page
Every chapter has a Try it section before its checkpoint. The solution to each question sits directly under it, in a collapsed “Show solution” box. Try the question first, then open the box to check your work. More than one correct line of code can solve a question, so compare the idea and the output, not the exact wording. Examples use only the supplied fake data.
This page is an index. It lists each chapter’s Try it section and how many questions it holds. The solutions for Chapters 19 to 31 are indexed on the methods solutions page.
| Chapter | Try it section | Questions |
|---|---|---|
| 1 | Orientation: What Are We Learning? | 3 |
| 2 | Set Up R and RStudio | 7 |
| 3 | Your First R Instructions | 8 |
| 4 | Vectors, Missing Values, and Conditions | 10 |
| 5 | Data Frames and CSV Files | 11 |
| 6 | Clean, Filter, and Summarize | 12 |
| 7 | Visualize and Explore Data | 11 |
| 8 | Functions, Decisions, and Debugging | 7 (plus a 10-question Part I self-check, see the milestone section) |
| 9 | Define the Research Question and Label | 5 |
| 10 | Statistics and Baselines for ML | 5 |
| 11 | Split the Data Before Modeling | 5 |
| 12 | Prepare Inputs Without Leakage | 7 |
| 13 | Regression: Predict a Number | 5 |
| 14 | Classification: Predict a Category | 5 |
| 15 | Evaluate a Classifier | 5 |
| 16 | Cross-Validation, Tuning, and Thresholds | 5 |
| 17 | Decision Trees and Random Forests | 5 |
| 18 | Capstone: A Complete ML Project | 5 |
Notes for instructors
- Chapters 14 to 17, pipeline checkpoints. The complete runnable pipeline is
scripts/02_capstone_pipeline.R. When checking a learner’s version of Chapters 14 to 17, look for these points:diabeteshas levelsc("Yes","No"); nopatient_idis among the predictors; all preprocessing is fitted inside the folds; cross-validation results, not the test set, choose the model and the threshold; held-out test metrics appear only after those choices are locked. - Chapter 17. A very small
min_nlets trees grow very detailed and overfit; have learners compare settings with cross-validation instead of assuming one size wins.