Authors: Marvin N. Wright, Lukas Burk, Pegah Golchian, Jan Kapar, Niklas Koenen, Sophie Hanna Langbein
Organizations: Leibniz Institute for Prevention Research and Epidemiology - BIPS, Bremen, Germany · University of Bremen, Germany · University of Copenhagen, Denmark
In the age of digital epidemiology, epidemiologists are faced by an increasing amount of data of growing complexity and dimensionality. Machine learning is a set of powerful tools that can help to analyze such enormous amounts of data. This chapter lays the methodological foundations for successfully applying machine learning in epidemiology. It covers the principles of supervised and unsupervised learning and discusses the most important machine learning methods. Strategies for model evaluation and hyperparameter optimization are developed and interpretable machine learning is introduced. All these theoretical parts are accompanied by code examples in R, where an example dataset on heart disease is used throughout the chapter.
Figures & tables
Figure 1: (a) Decision tree of the heart disease dataset using only the features ST_depression and serum_cholesterol . (b) The corresponding partition plot. The points are the instances/patients, and the shaded areas denote the model predictions.
Figure 2: A decision tree fitted on the heart disease dataset, visualized with the rpart.plot package. It predicts whether heart disease is present or absent in a patient, based on the features in the dataset, e.g., the results of a thallium stress test ( thal ). Each node contains the following information: 1) absent/present prediction, 2) proportion of patients with present heart disease, 3) size of the node as percentage of total sample size. The splitting criteria are denoted below the nodes. If the criteria apply, we follow the left path, otherwise the right path.
Figure 3: A visual representation of the cross-validation results of the cost-complexity pruning. The x -axis shows the complexity parameter cp . At the top, the number of leaf nodes corresponding to each complexity parameter is denoted. The y -axis represents a prediction error measure, based on cross-validation. The lowest error is reached at cp of 0.031. Figure created with the rpart package and slightly modified.
Figure 4: Model architecture of a sequential neural network with seven dense layers, generating predictions y^ from the input x . On the right, the model’s fourth layer is magnified, mapping the previous layer’s output x(4) to the next layer’s input x(5) through an affine transformation followed by a non-linear function, denoted as σ4 .
Figure 5: (a) The graphs of typical activation functions: hyperbolic tangent (green), rectified linear unit (ReLU) (orange), and logistic function (blue) used for probability outcomes. (b) Illustration of the gradient descent technique for learning the optimum θ^ by iteratively updating the current parameter θt for −η∇JD(θt) units based on the negated tangent’s slope at θt on the loss function and the learning rate η .
Figure 6: A confusion matrix showing the categorization of true and predicted class labels into true positives (TP), false positives (FP), false negatives (FN) and true negatives (TN). Common statistics derived from these values are the positive predictive value (PPV) and the negative predictive value (NPV), the accuracy (ACC) and its complement, the classification error (CE), as well as the true positive rate (TPR) and true negative rate (TNR).
Figure 7: ROC curve (a), precision-recall curve (b), and threshold curve (c) of a random forest classifier applied to the heart disease task as generated by mlr3 . Depending on the task, each visualization can provide valuable insight into the model at hand and provide necessary context to the model evaluation process.
Figure 8: The bias-variance trade-off characterizes the common phenomenon of the prediction error decreasing with higher model complexity up to the point at which it begins to increase again. This is based on the fact that low model complexity typically implies a high bias, whereas high complexity tends to imply higher variance.
Figure 9: 3-fold cross-validation splits the data into three disjoint sets. In each iteration, two thirds of the data serve as training set while the remaining fold serves as the test set for performance estimation. The results of the folds are averaged for a final performance estimate. Reprinted with permission from Bischl et al. (2024, Chap.3) .
Figure 10: Illustration of (a) grid search and (b) random search for tuning two hyperparameters. The hyperparameters lambda and max_depth are tuned within the search space lambda ∈(0,1) and max_depth ∈(0,20) . The dots with black outline are the respective ( max_depth , lambda ) combinations for which the xgboost model is evaluated in every iteration of the (a) grid search or (b) random search algorithm. In (a), combinations are selected on an equally spaced grid within the borders of the search space. In (b), the combinations are selected randomly within the borders of the search space. A high cross-validation classification accuracy (classif.acc) is represented by yellow color coding, darker colors indicate points with lower accuracy.
Figure 11: Illustration of the process of nested resampling. The larger blocks signify the use of 3-fold CV for evaluating the models in the outer resampling process, while the smaller blocks depict 4-fold CV for the inner resampling used in hyperparameter optimization. The training sets are represented by light blue blocks, whereas the test sets are shown by dark blue blocks. The thin blue arrows point to each step of the outer resampling process, in which a different portion of the data is used as a test set. Reprinted with permission from Bischl et al. (2024, Chap.4) .
Figure 12: Overview of the most popular post-hoc interpretable machine learning methods.
Figure 13: Illustration of the local model-agnostic IML methods ICE and Shapley values on the heart disease dataset: In (a), the left plot shows the ICE lines for the feature resting_blood_pressure and all test instances, while the right one displays the centered ICE plots at a blood pressure of 94. Additionally, the red highlighted line represents the first patient in the test data. In (b), the Shapley values of all features for the first patient are depicted.
Figure 14: Illustration of the global model-agnostic IML methods PFI, PDP and ALE plots. All three methods are calculated on a test dataset based on a random forest classifier trained on the heart disease dataset. Plot (a) highlights the ordered relative PFI computed using the classification error (CE). The PDPs in (b) show how age (left plot) and thal (right plot) affect the average model predictions while holding all other features constant. In (c) ALE plots describe how changes in age (left plot) and thal (right plot) affect the average model predictions while taking into account the effects of other features.
Figure 15: Basic approach of feature attribution methods.
Figure 16: Visual comparison of different methods for generative modeling. Action-counteraction pairs are colored in green and blue, respectively, latent space representations in red.
normal, ST-T wave abnormality 3 3 3 T wave inversions and/or ST elevation or depression of >0.05 mV , showing probable or definite left ventricular hypertrophy by Estes’ criteria
Table 1: Description and values of the features in the heart disease dataset. Divided into categorical (above) and numerical (below) features.
Reliable epidemiological reasoning requires synthesizing study evidence to infer disease burden, transmission dynamics, and intervention effects at the population level. Existing medical question answering benchmarks primarily emphasize clinical knowledge or patient-level reasoning, yet few systematically evaluate evidence-grounded epidemiological inference. We present EpiQAL, to our knowledge the first diagnostic benchmark for epidemiological question answering over research literature, comprising three subsets built from open-access articles across diverse diseases. The three subsets progressively test factual recall, multi-step inference, and conclusion reconstruction under incomplete information, and are constructed through a quality-controlled pipeline combining taxonomy guidance, multi-model verification, and difficulty screening. Experiments on fifteen models spanning open-source and proprietary systems reveal that current LLMs show limited performance on epidemiological reasoning, with multi-step inference posing the greatest challenge. Model rankings shift across subsets, and scale alone does not predict success. Chain-of-Thought prompting benefits multi-step inference but yields mixed results elsewhere. EpiQAL provides fine-grained diagnostic signals for evidence-grounding, inferential reasoning, and conclusion reconstruction.
Mingyang Wei, Dehai Min, Zewen Liu +8
1Emory University · University of Illinois Chicago · 3Microsoft
Machine learning (ML) studies using clinical data often rely on preprocessing and filtering pipelines before model development. The filtering decisions made in these pipelines can alter the dataset's statistical structure and may artificially reduce or increase the complexity of the prediction task. We argue that filtering choices should be treated as part of the scientific method rather than as a routine preprocessing step. We further discuss the need for explainable and transparent preprocessing pipelines that allow researchers to understand why specific filtering choices are made and how these choices affect the resulting data distribution and model performance. All of the source code for this work is available on GitHub.
Noah Subedar, Colin Campbell, Wenjing Zhang +3
School of Computer Science, University of Guelph, Ontario, Canada · St. Joseph’s Healthcare Hamilton, Hamilton, Ontario, Canada · The Research Institute of St. Joe’s Hamilton, Hamilton, Ontario, Canada +1
To prepare for future outbreaks, researchers need to know what studies have been done and what data they use. Mapping a large literature by hand is slow, while large language models alone can misstate or conflate sources. We present EpiLens, a lightweight, open-source retrieval-augmented generation package that applies a fixed retrieval template and output schema to every paper in a corpus and links outputs to source passages. We build a corpus of 2,297 papers from the sources of a multi-pathogen parameter study and evaluate EpiLens's paper-classification workflow against 214 manually labelled papers. Without task-specific training data, the classifier matches or exceeds the tested supervised and zero-shot baselines across four tasks. The study's early extraction sheets cite published sources for 327 estimates. We link each estimate to a cited document or to corpus studies included by a review. Then, we use the classifier's labels to compare the papers associated with different parameters and pathogens. EpiLens labels more papers linked to reproduction numbers than fatality risks as model-based (54% versus 22%, compared with 62% versus 24% in the manual labels). The gap is consistent with the frequent use of transmission models to estimate reproduction numbers and persists within each of five pathogens compared. Beyond the contrast between parameters, the model-based share of papers linked to incubation-period estimates differs by pathogen: 55% for SARS-CoV-2 versus 6% for mpox.