Getting Started

As this site aims to serve as a practical guide to the technical details of these machine learning concepts, we have provided example code in each section that will allow you to take the publicly available data and models and reproduce the figures you see as you explore each section. Below, we will outline how to set your environment up so that you can code along with the material.

This code walk-through assumes R is already installed, and you have a basic familiarity with running R code.

The GitHub Repository

  1. Download the repo:

    https://github.com/nspies13/practical-machine-learning-in-the-clinical-laboratory/archive/refs/heads/main.zip

  2. Open the zip file and move the contents to your desired location on your computer.

Clone the repository by running this command from the desired location on your computer as your working directory.

git clone https://github.com/nspies13/practical-machine-learning-in-the-clinical-laboratory.git

Once downloaded, open the project environment by clicking on the file “supplementary_website.Rproj”.

Setting Up Our Environment

With the .Rproj file opened, our first task will be to install the necessary packages by running the code below.

### Install renv if you don't already have it
if (!requireNamespace("renv", quietly = TRUE)) {
  install.packages("renv")
}

### Use renv to install the necessary packages
renv::restore()

Next, we’ll load the most relevant libraries and set a random seed for reproducibility.

## Load Libraries
library(tidyverse)
library(tidymodels)

## Configure Environment
set.seed(12345)

Download and Load the Example Data and Models

## Download and Import BMP Data Directly from FigShare 
train <- arrow::read_feather("https://figshare.com/ndownloader/files/45407401")
validation <- arrow::read_feather("https://figshare.com/ndownloader/files/45407398")

## Download and Import Models Directly from FigShare
model_realtime <- read_rds("https://figshare.com/ndownloader/files/45631488") |> pluck("model") |> bundle::unbundle()
model_retrospective <- read_rds("https://figshare.com/ndownloader/files/45631491") |> pluck("model") |> bundle::unbundle()

With these commands run, you should be all set to code along with the remainder of the content in this site.