Transparency and Reproducibility

The reproducibility crisis in AI research and what you can do about it. Model cards, datasheets for datasets, open-source practices, and documentation standards.


In January 2020 a team from Google Health published a paper in Nature reporting that their AI system read screening mammograms better than radiologists. It got a lot of press. Later that year Benjamin Haibe-Kains and about two dozen other researchers published a reply in the same journal. Their complaint was not that the result was wrong. It was that nobody could tell, because the paper lacked the code, the trained model and enough detail about the methods for anyone to check. A study that can't be examined, they wrote, is closer to a product announcement than to science.

That exchange is a pretty good summary of where the field is. Medical AI papers make claims that affect patients, and many of them can't be independently verified. This article is about what makes a study reproducible and what you can do, fairly cheaply, to make yours one of the ones that is.

Three things people mean

The vocabulary is used inconsistently, so we'll define ours.

Reproducing a result means taking the same data and the same code and getting the same numbers. It sounds trivial and frequently isn't.

Replicating a result means repeating the study with new data, perhaps at a different site, and reaching the same conclusion. This is what external validation does (see 5.4 Multi-Site External Validation).

Transparency is reporting enough that a reader can judge the work: what data, what methods, what was tried, what the model can and can't do. It's what makes the other two possible, and it's worth something even when code and data can't be shared.

How bad is it?

Fairly bad. In 2018 Odd Erik Gundersen and Sigbjørn Kjensmo surveyed 400 papers from two leading AI conferences and found that about 6% shared the code for their experiments and 30% shared their test data. Matthew McDermott and colleagues looked specifically at machine learning for health in 2021 and found that it did worse than other areas of machine learning on sharing both, which isn't surprising given that the data is patient records.

Sharing is only part of it. In 2023 Sayash Kapoor and Arvind Narayanan collected cases where published machine learning results turned out to be inflated by data leakage, meaning that information from the test set had reached the model during training. They found the problem in 17 scientific fields, medicine among them, affecting some 300 papers. In most of those cases the authors weren't hiding anything. They had made an error that nobody, including themselves, could see without the code (see 3.2 Training, Validation, and Test Sets).

Reproducibility is mostly a defence against your own mistakes. An analysis that someone else can rerun is an analysis in which someone else can find the bug.

Why AI results are hard to reproduce

Some of the causes are specific to machine learning, and it helps to know them when talking to your engineers.

Randomness. Training starts from random initial weights, shuffles the data in random order and applies random augmentations. Train the same model twice and you get two slightly different models. On a small test set, the difference between runs can be as large as the improvement being claimed. Fixing the random seed helps, though some GPU operations are not fully deterministic even then. The better practice is to train several times with different seeds and report the spread.

Software versions. A result depends on the versions of the framework, the libraries underneath it, the GPU drivers and sometimes the hardware. Code that ran in 2023 may not run today, or may run and give different numbers.

Undocumented steps. The preprocessing, the exclusions, the way the threshold was chosen, the cases that were dropped because the file wouldn't open. These live in somebody's notebook or head. "Images were preprocessed using standard methods" is the sentence that most reliably makes a paper impossible to reproduce (see 2.5 Data Preprocessing and Augmentation).

Data that moves. Labels get corrected, cases get added, a de-identification script is rerun. If nobody recorded exactly which version of the dataset produced the result, the result can't be regenerated.

Unreported search. A team tries forty configurations and reports the best. If the forty were compared on the test set, the reported figure is optimistic, and the paper won't say so because nobody kept count (see 3.4 Hyperparameter Tuning and Model Selection).

What to keep for every experiment

The goal is that any number in your paper can be traced to the exact code, data and settings that produced it. That takes five things.

  1. The code, at a specific version. That means version control, with the commit identifier recorded for each run.
  2. The data, at a specific version. A frozen snapshot, or at least a list of case identifiers and a checksum of the labels file.
  3. The data split. The list of which patients were in training, validation and test. This is the item most often lost, and without it nothing can be rerun.
  4. The configuration. Every setting, including the ones left at default, and the random seeds.
  5. The environment. The library versions, ideally captured as a container image that can be rerun as a unit.

Then keep the outputs: the trained weights, the per-case predictions and the logs. The per-case predictions are more useful than they look. With them, anyone can recompute any metric, add a subgroup analysis or check a confidence interval without retraining anything.

Experiment tracking software records most of this automatically, and it's worth asking your engineers to use one from the first day and not the week before submission (see 3.7 Tools and Infrastructure). This is also not extra work if the model may become a product. A regulator will expect the same traceability from training data to released model as part of the design history file (see 6.10 Design History File and Quality Management System Essentials).

Documenting the data and the model

Two documentation formats from the machine learning community have become fairly standard, and both are short.

A datasheet for a dataset, proposed by Timnit Gebru and colleagues in 2018, is modeled on the datasheets that come with electronic components. It answers a fixed set of questions. Why was the dataset created? Who is in it and how were they selected? How was it collected, over what period, on what equipment? How was it labeled and by whom? What was removed? What should it not be used for? Writing one usually turns up a question or two the team can't answer, which is useful to know.

A model card, proposed by Margaret Mitchell and colleagues in 2019, does the same for a trained model. It gives the intended use and the uses that are out of scope, the training data, the evaluation data, performance overall and by subgroup, and known limitations. It's a page or two.

Regulators have moved in the same direction. In 2024 the FDA, Health Canada and the UK's MHRA published guiding principles on transparency for machine learning medical devices. They ask manufacturers to communicate, to the people who use the device and those affected by it, what it is for, how it was developed, how it performs, and what its limits are. A good model card covers most of that.

For publication there are the reporting guidelines: checklists of what a paper on an AI study must contain (see 9.1 Reporting Standards). We'd suggest reading the relevant one at the design stage. Several of its items can't be supplied afterwards if they weren't recorded at the time.

Sharing, and what to do when you can't

The ideal is to release code, trained model and data. In medicine the data is usually the obstacle, for good reasons (see 2.7 De-Identification, Privacy, and Regulatory Compliance for Research Data). There's a range of options short of full release.

Share the code. There is seldom a privacy reason not to, and it documents the preprocessing and the evaluation more precisely than any methods section. Even code that can't be run without the data can be read.

Share the trained model, if your institution allows. Others can then test it on their own data, which is replication. It's worth knowing that trained models can sometimes leak information about their training data, so this needs sign-off too.

Share the data under controlled access, where an applicant signs a data use agreement. Or share a de-identified subset. Or, at the least, test on a public dataset as well as your own, so that part of your result can be checked by anyone.

Share the per-case predictions and labels for the test set, without the images. This lets others verify the statistics.

And if none of it can be shared, say so plainly in the paper, give the reason, and describe the methods in enough detail that someone with their own data could rebuild the pipeline. 9.4 Sharing Code, Data, and Models goes into the mechanics.

Commercial interest is the other reason given for not sharing. It's a legitimate one, and it has a cost: a claim that can't be checked carries less weight. Authors can't have both the scientific credit of a peer-reviewed paper and the secrecy of a product.

A test you can run yourself

Before submitting, ask someone who was not involved in the analysis, another student or a colleague's engineer, to take the frozen data and code and regenerate the main results table. Give them only what you plan to make available or describe.

It takes a day or two, and it will probably find something: a hard-coded file path, a step done by hand, a number in the table that came from an older run. Those are far better found by a colleague than by a reviewer, or by a reader after publication.

Key takeaways

  • Reproducing means same data and code, same numbers. Replicating means new data, same conclusion. Transparency is what makes both possible.
  • Most AI papers don't share code or data, and many published results have been inflated by errors that only became visible when someone could inspect the pipeline.
  • Random seeds, software versions, undocumented preprocessing, changing datasets and unreported tuning all make results hard to regenerate.
  • For each experiment keep the code version, the data version, the split, the full configuration and the environment, plus the weights and per-case predictions.
  • Write a datasheet for the dataset and a model card for the model. Regulators' transparency principles ask for much the same information.
  • When data can't be shared, share code, the model, predictions or a public-dataset result, and state what is withheld and why.
  • Have an outsider rerun the main result before you submit.

This article is part of the AI in Clinical Research Knowledge Base.