Course contents

AppendixAppendices

Exercise solutions: where to find them (Chapters 1 to 18)

On this page
  1. Notes for instructors

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.

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: diabetes has levels c("Yes","No"); no patient_id is 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_n lets trees grow very detailed and overfit; have learners compare settings with cross-validation instead of assuming one size wins.