Course / Weeks / Week 4
Part 1: Foundations · Week 4 · Tue, Jan 26
Chapter 4: Athlete Data in Python You wore a chest strap and a watch for the same interval session. The two files have gaps, a few impossible beats, and clocks that do not agree. What was your heart rate, second by second, and how do you know?
Ask Collect (this week) Check (this week) Interpret (this week) Coach Reassess Bring to class A phone with a free sensor-logging app; a heart-rate strap or watch if you have one; the results files you saved in weeks 1 and 3; a laptop with a web browser. Data you collect: A phone sensor log.
Apps: Watch
No one has to exercise hard, buy a device, or share health data: every collection has a case-file path.
Lecture slides Classes Homework H08 · due Class 8, Thu, Jan 28 Core exercises on tables, cleaning and resampling. Record a walk with a phone sensor-logging app (Exercise 4.14); load, clean, resample and plot it.
H09 · due Class 9, Tue, Feb 2 From the instructor's watch data: audit the data (missing heart rate, pauses, units, duplicates), then build a four-panel overview where each chart makes one point.
Tutorials From a raw file to something an athlete can act on. The case study is this week's worked example in class; the quick tutorials prepare you for it and for the homework. The data workflow · Your athlete record
Case study CS-4 · 60 min Take 693 activity summaries in a watch's own field names and units, audit every unit with an identity, write the cleaning rules first, keep a change log, and produce a quarterly running summary a coach can trust.
Case study CS-5 · 75 min Profile, clean and window eight phone accelerometer logs (Part 1), then classify walk, jog and run for a person the model has never seen, against the majority-class baseline, with balancing applied to the training rows only (Part 2).
Quick tutorials · 10–20 min each Build step B-4: A CSV file on a canvas Exercise board 34 exercises in 10 strands; 8 are CORE, the set homework draws on. Tick them off as you go; ticks stay in this browser.
CORE only Concept check Hand calculation Python analysis App lab Field collection Body science Science of the sport Build Communicate Check the AI
4.1 CORE Concept check, Foundation, 2 min A watch file has the time stamp 2027-03-02 07:15:00 and no zone. Which statement is right? Options: It is UTC, because files store UTC unless told otherwise It cannot be… 4.2 CORE Concept check, Core, 2 min You smooth a live heart-rate display with a trailing 9-point moving average of one value a second. On a steady rise, how late is the display? Options: 0 s, because… 4.3 Concept check, Foundation, 2 min Two heart-rate devices give a correlation of 0.99 over a session. What does that show? Options: That they rise and fall together; it says nothing about whether one reads… 4.4 Concept check, Core, 2 min A 120 fps slow-motion jump clip, stored with a 30 fps header, is processed with the capture rate left on “auto”. Which results in its Markdown file stay trustworthy?… 4.5 CORE Hand calculation, Foundation, 10 min A GPS watch gives ten speeds, one a second, in m/s: \(3.2, 3.4, 3.3, 3.5, 3.6, 3.4, 3.7, 3.8, 3.6, 3.9\). parts Compute the centered five-point moving average at samples… 4.6 Hand calculation, Core, 10 min A pose model places the hip with random noise of \(=3 mm\) in each frame. parts Compute the noise in a speed from two neighboring frames at 60 fps. 0.25 m/s. Repeat at… 4.7 Hand calculation, Core, 8 min A chest strap writes 05:58:41Z at the moment you press a lap button. A watch worn in a zone two hours ahead of UTC records the same press at local time 07:58:30. parts… 4.8 CORE Python analysis, Foundation, 20 min The course module https://apmonitor.com/dde/index.php/Main/SmartphoneSensors publishes a real phone accelerometer file,… 4.9 Python analysis, Core, 20 min Change Listing 4.17 so that it does not subtract the 7 s offset, and run it. parts Report the bias, the SD and the limits of agreement. By what factor did the correction… 4.10 Python analysis, Extension, 20 min The spike rule of Listing 4.8 uses a threshold of 5 m/s² from the five-point median. Run it with thresholds of 5, 2 and 1 m/s\(^2\) (keep the duplicate removal) and… 4.11 Python analysis, Extension, 30 min Give an AI assistant the seven .md files in data/results (not the .json receipts) and ask for a five-line summary of the athlete's progress for a coach. Then check its… 4.12 CORE App lab, Core, 20 min Analyze yourself with the jump app's process-a-folder page (https://apopt.com/jump/automation.html), following the five-step pattern of the book. steps Film three… 4.13 App lab, Extension, 25 min Process one slow-motion jump clip twice with the jump app's folder page: once with the capture rate on “auto” and once with the rate the camera recorded at (rename a… 4.14 CORE Field collection, Foundation, 30 min Record a walk with your phone's motion sensors and find your cadence. steps Install a free sensor-logging app that exports CSV. Set the accelerometer to 50–100 Hz and… 4.15 Body science, Foundation, 5 min In the synthetic session, the strap's heart rate takes tens of seconds to settle after each change of pace. In plain words, why does heart rate not jump at once when the… 4.16 Body science, Core, 5 min A wrist heart-rate sensor shines light into the skin and measures how much returns as blood volume pulses with each beat. During a run it sometimes reports a value close… 4.17 Science of the sport, Foundation, 5 min You want to check a watch's clock against a chest strap by cross-correlation. Which session would you choose: a steady 40-minute easy run, or a session of 6 \(×\)… 4.18 Science of the sport, Extension, 8 min A coach wants to see whether a squad's countermovement jump improved over a four-week block. From what you know about jumping and about measurement, list three things,… 4.19 CORE Build, Core, 60 min Build step B-4. Add to your week-1 Vite project a page that loads a CSV file chosen by the user and draws one column on a canvas, using Listing 4.24 as a model. parts… 4.20 CORE Communicate, Core, 20 min A coach sends you a default spreadsheet chart of the squad's jump heights: a 3-D column chart, one color per athlete, the axis starting at 25 cm, legend… 4.21 Check the AI, Core, 8 min An assistant wrote this to put the watch on UTC before aligning it with the strap: watch.index = pd.to_datetime(watch["timestamp"], utc=True). The cross-correlation over… 4.22 Python analysis, Foundation, 15 min Run Listing 4.23. Then fix the function so that the test passes, without changing the test. Show the passing output and say in one sentence why your version leaves the… 4.23 Python analysis, Foundation, 15 min Extend Listing 4.2 (Section 4.1.1). parts Add a fourth known case: a marathon, 42195 m, in 3:30:00. Compute the pace by hand first, then write the assert. 298.6 s a… 4.24 Python analysis, Foundation, 15 min Write a function speed_kmh(distance_m, time_s) that returns speed in kilometers an hour, and three known cases you compute by hand before you write any code: 10 km in 50… 4.25 Hand calculation, Foundation, 8 min Four 200 m repetitions take t = [40, 38, 36, 40] seconds. parts What are t[1:3] and t[-1]? \([38, 36]\); 40. Compute the speed of each repetition in m/s, as 200 /… 4.26 Python analysis, Foundation, 15 min Load data/walk_accel.csv and compute the magnitude \(x^2+y^2+z^2\) of every row twice: with a loop over the rows, and with one line of array arithmetic. parts Report the… 4.27 Python analysis, Core, 20 min Write a data dictionary (Section 4.2.5) for this chapter's two heart-rate files, the strap's and the watch's (strap_hr.csv and watch_hr.csv in data/): for each field,… 4.28 Python analysis, Core, 20 min Apply provenance and a change log (Section 4.3.1) to the synthetic watch activity table in the file data/watch_activity.csv. Using the dictionary of Table 4.2, write… 4.29 App lab, Foundation, 15 min Process one clip of yourself with the jump app's process-a-folder page, https://apopt.com/jump/automation.html: side view, phone on a stand at hip height, one… 4.30 Python analysis, Core, 20 min Use data/sessions.csv and data/session_hr.csv (Section 4.4.1). parts Before running anything, predict the rows of an inner join of the raw tables, and of an outer join.… 4.31 Check the AI, Core, 8 min An assistant writes df = hr.merge(log, on="session_id") for the files of Section 4.4.1 and reports: “Joined successfully: 300 rows, no errors, every heart-rate row now… 4.32 Communicate, Core, 20 min Draw a histogram and a box plot of the watch's heart rates in data/watch_hr.csv (Section 4.7.1). parts Report the five numbers of the box plot. 99, 112, 132, 162, 182… 4.33 Python analysis, Core, 40 min, case-file data Case file: Audit your case-file athlete's watch archive (see apopt.com/data/athletes) for data quality. Read each activity's FIT file with fitdecode and make a… 4.34 Communicate, Core, 20 min, case-file data Case file: Write a half-page data-quality note about your case-file athlete's watch archive (see apopt.com/data/athletes) for the coach, from your audit in the previous… Data for this week watch
19 runs recorded on a COROS PACE Pro between 2026-04-10 and 2026-05-18: one row per run, lap splits, weekly totals, and a per-second record file for every run. GPS coordinates removed.
22 files, 4.5 MB · CC BY 4.0 · main file
heart
4 chest-strap sessions (ECG at 130 Hz with beat-by-beat RR) from June 2026: 2 full nights and 2 daytime sessions, with 3-minute excerpts and nightly HRV.
14 files, 48.0 MB · CC BY 4.0 · main file
watch
693 activity summaries from a COROS Training Hub archive of an adult male athlete in his mid-40s, 2024-06-28 to 2026-11-28: the watch's own session fields and units, a cleaned table in SI units, and weekly totals. GPS coordinates removed.
3 files, 211.7 KB · CC BY 4.0 · main file
book
The 21 example files that Chapter 4 of Data-Driven Athletics reads, under the same names the listings use.
21 files, 365.0 KB · CC BY 4.0 · main file
tutorial
Take 693 activity summaries in a watch's own field names and units, audit every unit with an identity, write the cleaning rules first, keep a change log, and produce a quarterly running summary a coach can trust.
6 files, 331.2 KB · CC BY 4.0 · main file
tutorial
Profile, clean and window eight phone accelerometer logs (Part 1), then classify walk, jog and run for a person the model has never seen, against the majority-class baseline, with balancing applied to the training rows only (Part 2).
14 files, 4.0 MB · CC BY 4.0 · main file
tutorial
Open a phone accelerometer log, compute its real sample rate from the time stamps, turn three axes into one magnitude, and plot the whole session and a zoom to see the steps and the faults.
2 files, 146.7 KB · CC BY 4.0 · main file
tutorial
Write a data dictionary for one of the instructor's per-second watch files, with units, allowed ranges and missing-value codes, before looking at the values, then count which rows break which rule.
3 files, 286.2 KB · CC BY 4.0 · main file
tutorial
Find empty cells, zero codes and gaps in time in one of the instructor's watch files, mark each with a reason in a copy that keeps every row, and see where the missing values cluster.
4 files, 669.7 KB · CC BY 4.0 · main file
course
Running biomechanics tables and phone-sensor examples from the Data-Driven Engineering course.
At the source · As published on apmonitor.com
Go further ← Week 3 Week 5 →