Exercise: New trials or new people?#

Participant identity is predictive when the same people appear on both sides of a split. That convenience does not answer whether a system works for a new participant.

See the shared submission guidance and rubric. Run from book/exercises; the setup below supplies data, not completed answers.

# Shared simulator and small utility functions; no live service is called.
source("../R/course.R")
d <- simulate_trials(seed=116,n_subjects=40,n_items=20)
row_fold <- group_folds(d$trial_id,k=5,seed=116)
participant_fold <- group_folds(d$subject,k=5,seed=116)
# Prediction rule: use training participant mean if known; otherwise training grand mean.
predict_person_mean <- function(train, assessment) {
  means <- tapply(train$rt,train$subject,mean)
  p <- unname(means[as.character(assessment$subject)])
  p[is.na(p)] <- mean(train$rt)
  p
}

1. Audit the partitions before fitting#

For both fold assignments, count participant overlap between analysis and assessment sets in each fold. Verify every row is assessed exactly once. Explain which deployment question each assignment approximates; shared participants are not inherently wrong if known-person prediction is the explicit target.

# Produce a fold-level overlap and size table.

Your explanation and evidence:

2. Compare evaluation targets#

Generate out-of-fold predictions for the supplied person-mean rule under both schemes. Also evaluate lm(rt ~ frequency + length) using each fold’s analysis rows. Report pooled out-of-fold MSE and per-fold MSE for both procedures. Explain why the rankings or gaps can change without either calculation containing a software bug.

# Fill prediction vectors at assessment indices, then compare losses.

Your explanation and evidence:

3. Design an honest tuning pipeline#

Write pseudocode for tuning a regularized model for new participants: outer assessment, inner tuning, training-only scaling, refit, and final evaluation. Identify where prompt or embedding-model choice would belong if it were tuned. Explain why five fold losses are not five independent experiments and avoid presenting their SD/sqrt(5) as a universal confidence interval.

# Optional repeat with a second prespecified fold seed; keep both results.

Your explanation and evidence:

What to submit#

A partition audit, an out-of-fold comparison table, and a correctly nested pipeline diagram or pseudocode. The central deliverable is a match between split design and deployment claim.