Learn · 02 of 02
Data & AI
How the model reads a recording, and how well it works.
01 · Reading a phonocardiogram
The sound of a heart, drawn.
A phonocardiogram (PCG) is a recording of the sounds a heart makes. Every heartbeat has two main sounds: the first heart sound (
These are two real recordings from two children, each cut to a single beat and drawn on the same time scale. The model does not look at one beat like this: it reads a whole 5 s window, several heartbeats long, so it sees the pattern repeat and nobody has to find S1 and S2 for it first.
FIG. 1 · One heartbeat, with and without a murmur
0–800 ms from the start of S1
Scroll sideways to see the whole drawing
Two real recordings, one heartbeat each: 49568_MV.wav (mitral site, labelled no murmur) above 9979_TV.wav (tricuspid site, labelled murmur, grade III/VI). The labels are the dataset’s, not a model output. Time is in milliseconds from the start of S1, and each trace is scaled to its own largest value, so compare shapes, not loudness. The part boundaries are the expert-reviewed S1/S2 segmentation of the dataset and the hatch is its murmur label. The sound is filtered to 20–500 Hz, the band the final system keeps.
The beats are at 5.42–6.22 s of 49568_MV and 3.66–4.28 s of 9979_TV. 8 samples at the loudest S1 peak of 9979_TV touch full scale. In murmur recordings the dataset’s S1/S2 borders can be less sharp, so some of the murmur can fall inside the S1 and S2 brackets. CirCor DigiScope Phonocardiogram Dataset, PhysioNet 2022, ODC-By 1.0.
02 · What the AI sees
Follow one window through the model.
Dataset label: Murmur — holosystolic, grade III/VI. Test split, held out: never used for training. Dataset label, not a model output.
FIG. 2 · 9979_TV.wav · window —. Time in seconds from the start of the file; amplitude in file units (full scale ±1). The vertical scale fits this window.
Step 1 of 5
The raw window
The classifier never looks at a whole recording at once. It cuts the recording into 5 s windows and starts a new window every 2.5 s, so each window holds several heartbeats. This plot is the window you chose, as the file stores it.
- Window
- —
- Samples
- —
Recordings from the CirCor DigiScope Phonocardiogram Dataset v1.0.3 (PhysioNet, ODC-By 1.0); the full citation is in the next chapter.
03 · How it was trained
Learning from labelled recordings.
438
training patient IDs
1,432
training recordings
11,278
training windows
0.32
decision threshold
The data
The CirCor DigiScope Phonocardiogram Dataset, version 1.0.3, from PhysioNet under the Open Data Commons Attribution License 1.0. It holds heart sounds from 942 paediatric patients, recorded at up to four chest locations (aortic, pulmonary, tricuspid and mitral) at 4 kHz. A recording is labelled "murmur present" if a murmur was audible at that location and "murmur absent" if the patient has no murmur. Recordings of patients labelled Unknown are left out, and so are recordings of a patient with a murmur at a location where it was not audible.
- Oliveira J, Renna F, Costa P, et al. The CirCor DigiScope Phonocardiogram Dataset (version 1.0.3). PhysioNet; 2022. doi:10.13026/tshs-mw03
- Oliveira JH, Renna F, Costa P, et al. The CirCor DigiScope Dataset: From Murmur Detection to Murmur Classification. IEEE Journal of Biomedical and Health Informatics. 2021. doi:10.1109/JBHI.2021.3137048
- Pollard T, Moody BE, Lehman L, et al. PhysioNet as a global platform for biomedical research. Nature Health. 2026. doi:10.1038/s44360-026-00096-z
The recipe
- Split by child, 50/50 (seed 3641). Half of the children train the model and the other half are held out. No child has recordings on both sides.
- Make windows. Every training recording is cut into 5 s windows, a new one every 2.5 s, and each window becomes 26 numbers. A window gets the label of its recording.
- Compare candidates: 12 random forests (200 or 400 trees, three depth limits, two leaf sizes), scored with 5-fold cross-validation grouped by child.
- Pick the model: the forest with the best mean AUC in cross-validation, 400 trees in all.
- Fix the threshold on the out-of-fold training predictions with Youden's rule. It is set once and never changed for the offline baseline or the live result.
- Fit the winner on all training windows and save it.
FIG. 7 · The candidates
5-fold cross-validation, training half
| Model | AUC, mean ± SD over folds | Balanced accuracy at 0.5 | Sensitivity at 0.5 | Specificity at 0.5 |
|---|---|---|---|---|
| forest n=200 depth=none leaf=1 | 0.749 ± 0.079 | 0.60 | 0.21 | 0.99 |
| forest n=200 depth=none leaf=5 | 0.748 ± 0.082 | 0.65 | 0.33 | 0.97 |
| forest n=200 depth=8 leaf=1 | 0.733 ± 0.091 | 0.68 | 0.57 | 0.79 |
| forest n=200 depth=8 leaf=5 | 0.733 ± 0.092 | 0.67 | 0.57 | 0.78 |
| forest n=200 depth=16 leaf=1 | 0.752 ± 0.079 | 0.63 | 0.29 | 0.98 |
| forest n=200 depth=16 leaf=5 | 0.748 ± 0.083 | 0.66 | 0.36 | 0.95 |
| forest n=400 depth=none leaf=1 | 0.750 ± 0.081 | 0.60 | 0.21 | 0.99 |
| forest n=400 depth=none leaf=5 | 0.747 ± 0.083 | 0.65 | 0.34 | 0.97 |
| forest n=400 depth=8 leaf=1 | 0.733 ± 0.090 | 0.68 | 0.57 | 0.80 |
| forest n=400 depth=8 leaf=5 | 0.732 ± 0.092 | 0.67 | 0.56 | 0.78 |
| forest n=400 depth=16 leaf=1chosen | 0.754 ± 0.079 | 0.64 | 0.30 | 0.97 |
| forest n=400 depth=16 leaf=5 | 0.748 ± 0.082 | 0.66 | 0.36 | 0.95 |
- Window
- 5 s every 2.5 s
- Band kept before any feature
- 20–500 Hz
- MFCCs
- 13 coefficients, 26 mel bands
- Frame and step
- 32 ms and 16 ms
- Numbers per window
- 26
- Forest
- 400 trees, depth 16, at least 1 window per leaf, 649,328 nodes
- Windows by class
- 9,402 absent, 1,876 murmur
- Decision threshold
- 0.32 (shown as 0.32)
- Seeds
- split 3641, cross-validation 0, forest 0
- Trained
- 2026-11-18, model file 1ba195cf721f
04 · How well it works
The numbers: offline baseline and through the hardware.
Headline numbers
Offline baseline · software, from training
The model's score on the held-out files.
- ROC AUC1 is perfect · 0.5 is chance
- 0.724160 recordings
- SensitivityMurmurs flagged
- 0.7195% CI 0.61–0.80 · 57 of 80
- SpecificityNo-murmur recordings cleared
- 0.6895% CI 0.57–0.77 · 54 of 80
- AccuracyShare of recordings classified right
- 0.6995% CI 0.62–0.76 · 111 of 160
| Predicted murmur | Predicted absent | |
|---|---|---|
| Murmur, 80 | 57found | 23missed |
| Absent, 80 | 26false alarm | 54cleared |
Through the hardware · live
The same files, played and classified live.
Not measured
Needs the speaker, coupler, silicone, microphone, front end and ADC.
Every evaluation run
| Run and set | Accuracy | Sensitivity | Specificity | ROC AUC | Balanced accuracy | Always-absent baseline |
|---|---|---|---|---|---|---|
| Offline baseline, bench set160 recordings, 80 murmur and 80 absent | 0.6995% CI 0.62–0.76 · 111 of 160 | 0.7195% CI 0.61–0.80 · 57 of 80 | 0.6895% CI 0.57–0.77 · 54 of 80 | 0.724 | 0.69 | 0.50 |
| Offline baseline, test split1458 recordings, 252 murmur and 1206 absent | 0.7195% CI 0.68–0.73 · 1031 of 1458 | 0.7295% CI 0.66–0.77 · 181 of 252 | 0.7095% CI 0.68–0.73 · 850 of 1206 | 0.767 | 0.71 | 0.83 |
| Simulated bandpass, bench set Simulated160 recordings, 80 murmur and 80 absent | 0.6495% CI 0.57–0.71 · 103 of 160 | 0.7295% CI 0.62–0.81 · 58 of 80 | 0.5695% CI 0.45–0.67 · 45 of 80 | 0.715 | 0.64 | 0.50 |
| Through the hardware, bench setplayed and classified live | Not measured | |||||
Under each rate are its 95%
Sensitivity by murmur grade
| Grade | Offline baseline, bench set | Offline baseline, test split | Simulated bandpass, bench set |
|---|---|---|---|
| Grade I/VI | 0.6195% CI 0.47–0.73 · 31 of 51 | 0.5895% CI 0.48–0.67 · 63 of 109 | 0.6395% CI 0.49–0.75 · 32 of 51 |
| Grades II/VI and III/VI | 0.8995% CI 0.73–0.96 · 25 of 28 | 0.8395% CI 0.76–0.88 · 117 of 141 | 0.8995% CI 0.73–0.96 · 25 of 28 |
| Other grades | 1.0095% CI 0.21–1.00 · 1 of 1 | 0.5095% CI 0.09–0.91 · 1 of 2 | 1.0095% CI 0.21–1.00 · 1 of 1 |
Murmurs are graded by loudness. Quiet grade I/VI murmurs are the hardest to detect. "Other grades" pools the few files with other grades, which are too few to say anything.
Confusion matrices
A confusion matrix counts every file by what it really is (rows) and what the model said (columns). The bench set's matrix is in the headline numbers above.
Offline baseline, test split
| Predicted murmur | Predicted absent | |
|---|---|---|
| Murmur, 252 | 181found | 71missed |
| Absent, 1206 | 356false alarm | 850cleared |
Simulated bandpass, bench set Simulated
| Predicted murmur | Predicted absent | |
|---|---|---|
| Murmur, 80 | 58found | 22missed |
| Absent, 80 | 35false alarm | 45cleared |
Simulated bandpass against the offline baseline
SimulatedEach bench file was also scored in software after a model of a 20–500 Hz bandpass filter (simulated), with the same model and threshold as the offline baseline. The change is simulated minus the offline baseline. This models the filter only. It is not a measurement through hardware, and it is not the live result.
| Metric | Offline baseline | Simulated | Change | 95% interval of the change |
|---|---|---|---|---|
| Sensitivity | 0.71 | 0.72 | +0.01 | -0.03 to 0.06 |
| Specificity | 0.68 | 0.56 | -0.11 | -0.19 to -0.05 |
| Accuracy | 0.69 | 0.64 | -0.05 | -0.09 to -0.01 |
| Balanced accuracy | 0.69 | 0.64 | -0.05 | -0.09 to -0.01 |
| ROC AUC | 0.724 | 0.715 | -0.009 | -0.033 to 0.015 |
The intervals are descriptive, from a paired bootstrap that resamples files together. The
| Files that are | Files | Changed | To present | To absent | p, exact McNemar | p, Holm-adjusted |
|---|---|---|---|---|---|---|
| Murmur files | 80 | 3 | 2 | 1 | 1.000 | 1.000 |
| Absent files | 80 | 9 | 9 | 0 | 0.004 | 0.008 |
Honest caveats
- Quiet murmurs are hard. In the offline baseline on the bench set, sensitivity is 0.61 for grade I/VI murmurs (31 of 51) against 0.89 for grades II/VI and III/VI (25 of 28). 85339_MV.wav is a recording the model misses: the share of trees voting murmur, averaged over its windows, is 0.19, below the threshold 0.32, so the answer is "Murmur absent". 9979_TV.wav is found only narrowly: its score is 0.323 against a threshold of 0.316, so a small change in the model could flip it.
- Test-split intervals are optimistic. The test split has several recordings per child, but the interval maths treats every file as independent, so its intervals come out too narrow. The bench set has one recording per child and does not have this problem.
- Accuracy alone flatters the test split. A model that always says "absent" already scores 0.83 there. The bench set is balanced, so its baseline is 0.50. Read sensitivity and balanced accuracy too.
- Absolute accuracy may be a little optimistic. The design was refined while earlier experimental splits of the same labelled patients were in use, so it was not chosen blind to the final test half. This matters much less for the comparison between the offline baseline and the live result, which use the same files, the same model and the same threshold.
- Live shows one window at a time. A live result is one 5 s window, so its error rates are the window-level ones, not the recording-level ones above. In the offline baseline on the bench set, window-level sensitivity is 0.67 and specificity is 0.62 over 1219 windows.
- Simulated is not hardware. The simulated bandpass models a filter only, not the loudspeaker, the silicone layer, the microphone or the noise of real electronics. The live run through the hardware will measure those, and it is not measured yet.
Decision threshold 0.3156 in the model, shown as 0.32
05 · Where to look in the code
Where to look in the code.
- pcg/features.py
- The one feature path: windows, band-limit, RMS, MFCCs and their mean and standard deviation per window.
- pcg/explain.py
- Recomputes each stage of one window, for the step-through above.
- pcg/labels.py
- The label rule and the split by child.
- pcg/train.py
- Cross-validation, the model choice and the threshold.
- pcg/model.py
- The saved forest, each tree's vote, and the recording-level rule: the mean of the window vote shares.
- pcg/evaluate.py
- Scoring a run, offline or through the hardware, and comparing two runs.
- hmi/export_web.py
- Writes the data files this page is built from.
- web/src/components/learn/
- The components and the arithmetic behind this page, with tests.