5 hidden checks

Write the evaluation tools you'll use in the module project. Labels and predictions are 0/1 integer arrays; 1 is positive.

  • confusion(y, pred): return the tuple (tp, fp, fn, tn) as integers.
  • precision_recall_f1(y, pred): return (precision, recall, f1). Define any 0/0 as 0.0.
  • kfold_indices(n, k, seed): shuffle np.arange(n) with np.random.default_rng(seed).permutation(n), split it into k nearly equal folds with np.array_split, and return a list of k pairs (train_idx, val_idx).
checks
  • confusion counts the four cellsnot run
  • precision, recall and F1not run
  • no division-by-zero when nothing is predicted positivenot run
  • kfold_indices covers every index exactly once as validationnot run
  • kfold_indices uses the seeded shufflenot run
python sleeps until you press run

Press Run & check. Your code runs first, then the hidden checks on the left.