daims-validation 0.1.0a1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- daims_validation-0.1.0a1/CITATION.cff +27 -0
- daims_validation-0.1.0a1/LICENSE +21 -0
- daims_validation-0.1.0a1/MANIFEST.in +2 -0
- daims_validation-0.1.0a1/PKG-INFO +145 -0
- daims_validation-0.1.0a1/README.md +122 -0
- daims_validation-0.1.0a1/daims.py +662 -0
- daims_validation-0.1.0a1/daims_validation.egg-info/PKG-INFO +145 -0
- daims_validation-0.1.0a1/daims_validation.egg-info/SOURCES.txt +17 -0
- daims_validation-0.1.0a1/daims_validation.egg-info/dependency_links.txt +1 -0
- daims_validation-0.1.0a1/daims_validation.egg-info/requires.txt +2 -0
- daims_validation-0.1.0a1/daims_validation.egg-info/top_level.txt +1 -0
- daims_validation-0.1.0a1/examples/synthetic-clinic/reviewed-data.csv +13 -0
- daims_validation-0.1.0a1/examples/synthetic-clinic/reviewed-dictionary.csv +5 -0
- daims_validation-0.1.0a1/examples/synthetic-clinic/source-records.csv +3 -0
- daims_validation-0.1.0a1/examples/synthetic-clinic/starter-data.csv +13 -0
- daims_validation-0.1.0a1/examples/synthetic-clinic/starter-dictionary.csv +5 -0
- daims_validation-0.1.0a1/pyproject.toml +35 -0
- daims_validation-0.1.0a1/setup.cfg +4 -0
- daims_validation-0.1.0a1/tests/test_validation.py +42 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use DAIMS, please cite the methods paper."
|
|
3
|
+
type: software
|
|
4
|
+
title: "DAIMS: Datasheets for AI and Medical Datasets"
|
|
5
|
+
authors:
|
|
6
|
+
- family-names: "Zargari Marandi"
|
|
7
|
+
given-names: Ramtin
|
|
8
|
+
- family-names: Frahm
|
|
9
|
+
given-names: Anne Svane
|
|
10
|
+
- family-names: Milojevic
|
|
11
|
+
given-names: Maja
|
|
12
|
+
repository-code: "https://github.com/PERSIMUNE/DAIMS"
|
|
13
|
+
license: MIT
|
|
14
|
+
preferred-citation:
|
|
15
|
+
type: article
|
|
16
|
+
title: "Datasheets for AI and medical datasets (DAIMS): a data validation and documentation framework before machine learning analysis in medical research"
|
|
17
|
+
authors:
|
|
18
|
+
- family-names: "Zargari Marandi"
|
|
19
|
+
given-names: Ramtin
|
|
20
|
+
- family-names: Frahm
|
|
21
|
+
given-names: Anne Svane
|
|
22
|
+
- family-names: Milojevic
|
|
23
|
+
given-names: Maja
|
|
24
|
+
journal: arXiv
|
|
25
|
+
year: 2025
|
|
26
|
+
doi: "10.48550/arXiv.2501.14094"
|
|
27
|
+
url: "https://arxiv.org/abs/2501.14094"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 DAIMS contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: daims-validation
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: Validate and document datasets for biomedical and clinical machine learning
|
|
5
|
+
Author: Ramtin Zargari Marandi, Anne Svane Frahm, Maja Milojevic
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/PERSIMUNE/DAIMS
|
|
8
|
+
Project-URL: Documentation, https://github.com/PERSIMUNE/DAIMS#readme
|
|
9
|
+
Project-URL: Issues, https://github.com/PERSIMUNE/DAIMS/issues
|
|
10
|
+
Project-URL: Research paper, https://arxiv.org/abs/2501.14094
|
|
11
|
+
Keywords: dataset validation,data quality,data dictionary,metadata,biomedical research,clinical machine learning
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: pandas>=2.1
|
|
21
|
+
Requires-Dist: numpy>=1.24
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# DAIMS: Datasheets for AI and Medical Datasets
|
|
25
|
+
|
|
26
|
+
<p align="center">
|
|
27
|
+
<img src="https://github.com/PERSIMUNE/DAIMS/blob/main/DAIMSlogo.svg" alt="DAIMS Logo" width="300">
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
 [](https://github.com/PERSIMUNE/DAIMS/releases/tag/v1.0.0) [](https://scholar.google.com/scholar?cites=8674731473406692984&hl=en) [](https://daims-app.streamlit.app/) [](https://huggingface.co/spaces/ramtinzm/DAIMS) [](https://www.kaggle.com/code/remyz5/daims-dataset-checks)
|
|
31
|
+
|
|
32
|
+
**DAIMS (Datasheets for AI and Medical Datasets)** helps researchers check and document datasets before machine learning analysis. It combines a 24-point checklist, automated data checks, a dataset documentation form, a data dictionary template, and a flowchart for choosing analysis methods.
|
|
33
|
+
|
|
34
|
+
Use the [online app](https://daims-app.streamlit.app/) to run the automated checks, and the templates in this repository to document your dataset. DAIMS builds on the *Datasheets for Datasets* framework with guidance tailored to medical data and AI research.
|
|
35
|
+
|
|
36
|
+
## Key Features
|
|
37
|
+
|
|
38
|
+
1. **Comprehensive Checklist**
|
|
39
|
+
A 24-point checklist that covers common data standardization requirements. A subset of these checks is automated by the DAIMS software tool to validate dataset readiness.
|
|
40
|
+
|
|
41
|
+
2. **Data Documentation Form**
|
|
42
|
+
An extended documentation form designed to capture essential metadata, pose relevant research questions, and ensure datasets are well-prepared for ML analysis.
|
|
43
|
+
|
|
44
|
+
3. **Data Dictionary Table**
|
|
45
|
+
A tabular format to document variable descriptions, data types, units, and any relevant details about the dataset.
|
|
46
|
+
|
|
47
|
+
4. **Flowchart for ML Analyses**
|
|
48
|
+
A guided flowchart that maps research questions to suggested ML methods, providing researchers with a clear pathway to address their objectives.
|
|
49
|
+
|
|
50
|
+
5. **Software Tool**
|
|
51
|
+
A publicly available tool to assist in dataset preparation by automating key aspects of the checklist validation process.
|
|
52
|
+
|
|
53
|
+
6. **Online App**
|
|
54
|
+
DAIMS is available as an easy-to-use online app hosted at [https://daims-app.streamlit.app/](https://daims-app.streamlit.app/), enabling efficient dataset evaluation and preparation.
|
|
55
|
+
|
|
56
|
+
## Benefits of DAIMS
|
|
57
|
+
|
|
58
|
+
- **Standardization**: Promotes consistent practices for preparing datasets in medical research.
|
|
59
|
+
- **Guidance**: Offers actionable insights through the flowchart and checklist, helping researchers align datasets with their ML objectives.
|
|
60
|
+
- **Automation**: Saves time by automating key validation processes.
|
|
61
|
+
- **Documentation**: Enhances transparency and reproducibility through detailed data documentation.
|
|
62
|
+
|
|
63
|
+
## Choose how to start
|
|
64
|
+
|
|
65
|
+
| What you want to do | Where to start |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| Check and document a sample dataset | [Try the worked example](https://github.com/PERSIMUNE/DAIMS/tree/main/examples/synthetic-clinic/) |
|
|
68
|
+
| Run the sample checks and compare the results | [DAIMS notebook on Kaggle](https://www.kaggle.com/code/remyz5/daims-dataset-checks) |
|
|
69
|
+
| Check your own dataset | [Open the DAIMS app](https://daims-app.streamlit.app/) |
|
|
70
|
+
| Document your dataset | [DAIMS datasheet template](https://github.com/PERSIMUNE/DAIMS/blob/main/DAIMS_DatasetName_DDMMYYYY.md) |
|
|
71
|
+
| Download the versioned templates | [DAIMS v1.0.0 templates ZIP](https://github.com/PERSIMUNE/DAIMS/releases/download/v1.0.0/DAIMS-templates.zip) |
|
|
72
|
+
| Review the full checklist and analysis flowchart | [DAIMS methods paper](https://arxiv.org/abs/2501.14094) |
|
|
73
|
+
|
|
74
|
+
## Run the checks in Python
|
|
75
|
+
|
|
76
|
+
Install the Python preview from PyPI:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
python -m pip install --pre daims-validation
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
From a [repository checkout](https://github.com/PERSIMUNE/DAIMS), try the same synthetic inputs used in the app walkthrough:
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
import pandas as pd
|
|
86
|
+
from daims import validate_dataset
|
|
87
|
+
|
|
88
|
+
folder = "examples/synthetic-clinic"
|
|
89
|
+
data = pd.read_csv(f"{folder}/starter-data.csv", dtype=str, keep_default_na=False)
|
|
90
|
+
dictionary = pd.read_csv(f"{folder}/starter-dictionary.csv")
|
|
91
|
+
report = validate_dataset(data, dictionary)
|
|
92
|
+
|
|
93
|
+
print(report.checklist.loc[[8, 10, 12], ["Mark if true", "Notification"]])
|
|
94
|
+
report.checklist.to_csv("daims-checklist.csv")
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The report contains all 24 checklist items and any informational notes. The nine manual items start as `Unknown` and can be reviewed in the Streamlit app. Use `dtype=str` when reading the dataset to preserve formatting that the checks can inspect.
|
|
98
|
+
|
|
99
|
+
## DAIMS in research
|
|
100
|
+
|
|
101
|
+
**[Cited by 11 works on Google Scholar](https://scholar.google.com/scholar?cites=8674731473406692984&hl=en)** · As of 3 November 2026.
|
|
102
|
+
|
|
103
|
+
DAIMS is cited across medical research, dataset documentation, pharmaceutical data quality, scientific software, and responsible AI. All 11 citing works are listed below, grouped by research area.
|
|
104
|
+
|
|
105
|
+
| Research area | Citing publication |
|
|
106
|
+
| --- | --- |
|
|
107
|
+
| Cancer research | [Machine learning and deep learning in glioblastoma: systematic review and meta-analysis](https://doi.org/10.1007/s12672-025-03303-7) |
|
|
108
|
+
| Cancer research | [Testicular cancer relapse prediction](https://doi.org/10.1111/andr.70195) |
|
|
109
|
+
| Gynecologic diagnostics | [Optical coherence tomography and AI in gynecologic diagnostics](https://www.authorea.com/doi/full/10.22541/au.176790712.29291970) |
|
|
110
|
+
| Clinical data preparation | [From medical records to AI-ready datasets: a practical guide](https://www.mdpi.com/2077-0383/15/16/6297) |
|
|
111
|
+
| Healthcare AI | [Responsible foundation models for healthcare](https://doi.org/10.1201/9781003737810-7) |
|
|
112
|
+
| Pharmaceutical data quality | [Evaluating data fitness for AI: the PAIR framework](https://sarcouncil.com/2025/07/evaluating-data-fitness-for-ai-in-pharmaceutical-applications-the-pair-framework) |
|
|
113
|
+
| Dataset documentation | [From reflection to repair: a scoping review of dataset documentation tools](https://doi.org/10.1145/3772318.3791344) |
|
|
114
|
+
| Scientific software and physics | [Scientific software development in the AI era: reproducibility, MLOps, and soft matter physics](https://doi.org/10.3389/fphy.2025.1711356) |
|
|
115
|
+
| Responsible AI and risk management | [Open problems in frontier AI risk management](https://arxiv.org/abs/2604.25982) |
|
|
116
|
+
| Responsible AI and risk management | [Engineering trustworthy AI: the VERITAS framework](https://ieeexplore.ieee.org/abstract/document/11662190/) |
|
|
117
|
+
| Document processing and automation | [Automated data extraction from documents using AI](https://run.unl.pt/server/api/core/bitstreams/d44147b1-0557-4deb-bba3-065cee392bed/content) |
|
|
118
|
+
|
|
119
|
+
The [testicular cancer study](https://doi.org/10.1111/andr.70195) applied the DAIMS checklist to guide data curation and preprocessing.
|
|
120
|
+
|
|
121
|
+
Used DAIMS in your research? [Share your work](https://github.com/PERSIMUNE/DAIMS/issues/new) to be featured here.
|
|
122
|
+
|
|
123
|
+
## Citation
|
|
124
|
+
|
|
125
|
+
If you use DAIMS in your research, please cite our work:
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
@article{marandi2025daims,
|
|
129
|
+
title={Datasheets for AI and medical datasets (DAIMS): a data validation and documentation framework before machine learning analysis in medical research},
|
|
130
|
+
author={Ramtin Zargari Marandi and Anne Svane Frahm and Maja Milojevic},
|
|
131
|
+
journal={arXiv preprint arXiv:2501.14094},
|
|
132
|
+
year={2025},
|
|
133
|
+
url={https://arxiv.org/abs/2501.14094}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
You can find the preprint of our work on [arXiv](https://arxiv.org/abs/2501.14094).
|
|
138
|
+
|
|
139
|
+
## Contributing
|
|
140
|
+
|
|
141
|
+
We welcome contributions to improve DAIMS! Feel free to open issues, submit pull requests, or provide feedback on the GitHub repository.
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
This project is licensed under the [MIT License](https://github.com/PERSIMUNE/DAIMS/blob/main/LICENSE).
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# DAIMS: Datasheets for AI and Medical Datasets
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://github.com/PERSIMUNE/DAIMS/blob/main/DAIMSlogo.svg" alt="DAIMS Logo" width="300">
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
 [](https://github.com/PERSIMUNE/DAIMS/releases/tag/v1.0.0) [](https://scholar.google.com/scholar?cites=8674731473406692984&hl=en) [](https://daims-app.streamlit.app/) [](https://huggingface.co/spaces/ramtinzm/DAIMS) [](https://www.kaggle.com/code/remyz5/daims-dataset-checks)
|
|
8
|
+
|
|
9
|
+
**DAIMS (Datasheets for AI and Medical Datasets)** helps researchers check and document datasets before machine learning analysis. It combines a 24-point checklist, automated data checks, a dataset documentation form, a data dictionary template, and a flowchart for choosing analysis methods.
|
|
10
|
+
|
|
11
|
+
Use the [online app](https://daims-app.streamlit.app/) to run the automated checks, and the templates in this repository to document your dataset. DAIMS builds on the *Datasheets for Datasets* framework with guidance tailored to medical data and AI research.
|
|
12
|
+
|
|
13
|
+
## Key Features
|
|
14
|
+
|
|
15
|
+
1. **Comprehensive Checklist**
|
|
16
|
+
A 24-point checklist that covers common data standardization requirements. A subset of these checks is automated by the DAIMS software tool to validate dataset readiness.
|
|
17
|
+
|
|
18
|
+
2. **Data Documentation Form**
|
|
19
|
+
An extended documentation form designed to capture essential metadata, pose relevant research questions, and ensure datasets are well-prepared for ML analysis.
|
|
20
|
+
|
|
21
|
+
3. **Data Dictionary Table**
|
|
22
|
+
A tabular format to document variable descriptions, data types, units, and any relevant details about the dataset.
|
|
23
|
+
|
|
24
|
+
4. **Flowchart for ML Analyses**
|
|
25
|
+
A guided flowchart that maps research questions to suggested ML methods, providing researchers with a clear pathway to address their objectives.
|
|
26
|
+
|
|
27
|
+
5. **Software Tool**
|
|
28
|
+
A publicly available tool to assist in dataset preparation by automating key aspects of the checklist validation process.
|
|
29
|
+
|
|
30
|
+
6. **Online App**
|
|
31
|
+
DAIMS is available as an easy-to-use online app hosted at [https://daims-app.streamlit.app/](https://daims-app.streamlit.app/), enabling efficient dataset evaluation and preparation.
|
|
32
|
+
|
|
33
|
+
## Benefits of DAIMS
|
|
34
|
+
|
|
35
|
+
- **Standardization**: Promotes consistent practices for preparing datasets in medical research.
|
|
36
|
+
- **Guidance**: Offers actionable insights through the flowchart and checklist, helping researchers align datasets with their ML objectives.
|
|
37
|
+
- **Automation**: Saves time by automating key validation processes.
|
|
38
|
+
- **Documentation**: Enhances transparency and reproducibility through detailed data documentation.
|
|
39
|
+
|
|
40
|
+
## Choose how to start
|
|
41
|
+
|
|
42
|
+
| What you want to do | Where to start |
|
|
43
|
+
| --- | --- |
|
|
44
|
+
| Check and document a sample dataset | [Try the worked example](https://github.com/PERSIMUNE/DAIMS/tree/main/examples/synthetic-clinic/) |
|
|
45
|
+
| Run the sample checks and compare the results | [DAIMS notebook on Kaggle](https://www.kaggle.com/code/remyz5/daims-dataset-checks) |
|
|
46
|
+
| Check your own dataset | [Open the DAIMS app](https://daims-app.streamlit.app/) |
|
|
47
|
+
| Document your dataset | [DAIMS datasheet template](https://github.com/PERSIMUNE/DAIMS/blob/main/DAIMS_DatasetName_DDMMYYYY.md) |
|
|
48
|
+
| Download the versioned templates | [DAIMS v1.0.0 templates ZIP](https://github.com/PERSIMUNE/DAIMS/releases/download/v1.0.0/DAIMS-templates.zip) |
|
|
49
|
+
| Review the full checklist and analysis flowchart | [DAIMS methods paper](https://arxiv.org/abs/2501.14094) |
|
|
50
|
+
|
|
51
|
+
## Run the checks in Python
|
|
52
|
+
|
|
53
|
+
Install the Python preview from PyPI:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
python -m pip install --pre daims-validation
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
From a [repository checkout](https://github.com/PERSIMUNE/DAIMS), try the same synthetic inputs used in the app walkthrough:
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
import pandas as pd
|
|
63
|
+
from daims import validate_dataset
|
|
64
|
+
|
|
65
|
+
folder = "examples/synthetic-clinic"
|
|
66
|
+
data = pd.read_csv(f"{folder}/starter-data.csv", dtype=str, keep_default_na=False)
|
|
67
|
+
dictionary = pd.read_csv(f"{folder}/starter-dictionary.csv")
|
|
68
|
+
report = validate_dataset(data, dictionary)
|
|
69
|
+
|
|
70
|
+
print(report.checklist.loc[[8, 10, 12], ["Mark if true", "Notification"]])
|
|
71
|
+
report.checklist.to_csv("daims-checklist.csv")
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The report contains all 24 checklist items and any informational notes. The nine manual items start as `Unknown` and can be reviewed in the Streamlit app. Use `dtype=str` when reading the dataset to preserve formatting that the checks can inspect.
|
|
75
|
+
|
|
76
|
+
## DAIMS in research
|
|
77
|
+
|
|
78
|
+
**[Cited by 11 works on Google Scholar](https://scholar.google.com/scholar?cites=8674731473406692984&hl=en)** · As of 3 November 2026.
|
|
79
|
+
|
|
80
|
+
DAIMS is cited across medical research, dataset documentation, pharmaceutical data quality, scientific software, and responsible AI. All 11 citing works are listed below, grouped by research area.
|
|
81
|
+
|
|
82
|
+
| Research area | Citing publication |
|
|
83
|
+
| --- | --- |
|
|
84
|
+
| Cancer research | [Machine learning and deep learning in glioblastoma: systematic review and meta-analysis](https://doi.org/10.1007/s12672-025-03303-7) |
|
|
85
|
+
| Cancer research | [Testicular cancer relapse prediction](https://doi.org/10.1111/andr.70195) |
|
|
86
|
+
| Gynecologic diagnostics | [Optical coherence tomography and AI in gynecologic diagnostics](https://www.authorea.com/doi/full/10.22541/au.176790712.29291970) |
|
|
87
|
+
| Clinical data preparation | [From medical records to AI-ready datasets: a practical guide](https://www.mdpi.com/2077-0383/15/16/6297) |
|
|
88
|
+
| Healthcare AI | [Responsible foundation models for healthcare](https://doi.org/10.1201/9781003737810-7) |
|
|
89
|
+
| Pharmaceutical data quality | [Evaluating data fitness for AI: the PAIR framework](https://sarcouncil.com/2025/07/evaluating-data-fitness-for-ai-in-pharmaceutical-applications-the-pair-framework) |
|
|
90
|
+
| Dataset documentation | [From reflection to repair: a scoping review of dataset documentation tools](https://doi.org/10.1145/3772318.3791344) |
|
|
91
|
+
| Scientific software and physics | [Scientific software development in the AI era: reproducibility, MLOps, and soft matter physics](https://doi.org/10.3389/fphy.2025.1711356) |
|
|
92
|
+
| Responsible AI and risk management | [Open problems in frontier AI risk management](https://arxiv.org/abs/2604.25982) |
|
|
93
|
+
| Responsible AI and risk management | [Engineering trustworthy AI: the VERITAS framework](https://ieeexplore.ieee.org/abstract/document/11662190/) |
|
|
94
|
+
| Document processing and automation | [Automated data extraction from documents using AI](https://run.unl.pt/server/api/core/bitstreams/d44147b1-0557-4deb-bba3-065cee392bed/content) |
|
|
95
|
+
|
|
96
|
+
The [testicular cancer study](https://doi.org/10.1111/andr.70195) applied the DAIMS checklist to guide data curation and preprocessing.
|
|
97
|
+
|
|
98
|
+
Used DAIMS in your research? [Share your work](https://github.com/PERSIMUNE/DAIMS/issues/new) to be featured here.
|
|
99
|
+
|
|
100
|
+
## Citation
|
|
101
|
+
|
|
102
|
+
If you use DAIMS in your research, please cite our work:
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
@article{marandi2025daims,
|
|
106
|
+
title={Datasheets for AI and medical datasets (DAIMS): a data validation and documentation framework before machine learning analysis in medical research},
|
|
107
|
+
author={Ramtin Zargari Marandi and Anne Svane Frahm and Maja Milojevic},
|
|
108
|
+
journal={arXiv preprint arXiv:2501.14094},
|
|
109
|
+
year={2025},
|
|
110
|
+
url={https://arxiv.org/abs/2501.14094}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
You can find the preprint of our work on [arXiv](https://arxiv.org/abs/2501.14094).
|
|
115
|
+
|
|
116
|
+
## Contributing
|
|
117
|
+
|
|
118
|
+
We welcome contributions to improve DAIMS! Feel free to open issues, submit pull requests, or provide feedback on the GitHub repository.
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
This project is licensed under the [MIT License](https://github.com/PERSIMUNE/DAIMS/blob/main/LICENSE).
|
|
@@ -0,0 +1,662 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Written by Anne Svane Frahm, annesfrahm@gmail.com, CHIP Persimune, 2025.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
import string
|
|
8
|
+
|
|
9
|
+
import numpy as np
|
|
10
|
+
import pandas as pd
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
NA_VALUES = ['#N/A', '#N/A N/A', '#NA', '-1.#IND', '-1.#QNAN', '-NaN', '-nan', '1.#IND', '1.#QNAN', '<NA>', 'N/A', 'NA', 'NULL', 'NaN', 'None', 'n/a', 'nan', 'null', 'na', '-']
|
|
14
|
+
_NORMALIZED_NA_VALUES = frozenset(value.lower() for value in NA_VALUES)
|
|
15
|
+
_MANUAL_CHECKS = {
|
|
16
|
+
16: 'Date and time are formatted as described in the data dictionary (for example 05-11-2022 12:23 DD-MM-YYYY CET)',
|
|
17
|
+
17: 'Numerical entries have “.” as decimal separator (i.e. 1.2 not 1,2)',
|
|
18
|
+
18: 'Non-English entries are translated to English. Non-Latin scripts are transformed to Latin scripts',
|
|
19
|
+
19: 'The terms used in the dataset follow international standards',
|
|
20
|
+
20: 'All entries for each variable follow the same standard (e.g. older entries may have different standards or definitions)',
|
|
21
|
+
21: 'Erroneous data are corrected or removed (e.g., a BMI value of 2000)',
|
|
22
|
+
22: 'Informative missingness is properly encoded (e.g. “not tested” when it was deemed unnecessary to test',
|
|
23
|
+
23: 'Variable irrelevant for study are removed (i.e. non-generalizable variables that could not relate to the outcome, e.g., billing ID or personal contact information)',
|
|
24
|
+
24: 'No sensitive data including name, address, or identity number of the participants (patients) are included ',
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass
|
|
29
|
+
class ValidationReport:
|
|
30
|
+
"""DAIMS checklist and informational notes keyed by check number."""
|
|
31
|
+
|
|
32
|
+
checklist: pd.DataFrame
|
|
33
|
+
notes: dict[int, str]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _normalize_data_value(value):
|
|
37
|
+
if pd.isna(value):
|
|
38
|
+
return np.nan
|
|
39
|
+
if isinstance(value, str):
|
|
40
|
+
text = value.strip().lower()
|
|
41
|
+
return np.nan if text in _NORMALIZED_NA_VALUES else text
|
|
42
|
+
return str(value)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def validate_dataset(data: pd.DataFrame, dictionary: pd.DataFrame) -> ValidationReport:
|
|
46
|
+
"""Run the DAIMS checklist on a dataset and its data dictionary.
|
|
47
|
+
|
|
48
|
+
Keep original text formatting on import with dtype=str when possible.
|
|
49
|
+
Inputs are copied. Manual checks are returned with the status Unknown.
|
|
50
|
+
Raises ValueError for duplicate columns or an invalid data dictionary.
|
|
51
|
+
"""
|
|
52
|
+
if not len(data.columns):
|
|
53
|
+
raise ValueError("The dataset must contain at least one column.")
|
|
54
|
+
|
|
55
|
+
data = data.map(_normalize_data_value)
|
|
56
|
+
data = data.rename(columns=lambda value: str(value).strip().lower())
|
|
57
|
+
dd = dictionary.rename(columns=lambda value: str(value).strip().lower())
|
|
58
|
+
dd = dd.map(lambda value: value.strip().lower() if isinstance(value, str) else value)
|
|
59
|
+
|
|
60
|
+
if data.columns.has_duplicates or dd.columns.has_duplicates:
|
|
61
|
+
raise ValueError("Column names must be unique after normalization.")
|
|
62
|
+
|
|
63
|
+
required = ("variable name", "role", "variable type")
|
|
64
|
+
missing = [column for column in required if column not in dd.columns]
|
|
65
|
+
if missing:
|
|
66
|
+
raise ValueError(f"Missing data dictionary columns: {', '.join(missing)}.")
|
|
67
|
+
|
|
68
|
+
if dd["variable name"].isna().any() or dd["variable name"].eq("").any():
|
|
69
|
+
raise ValueError("Every data dictionary row must have a variable name.")
|
|
70
|
+
if dd["variable name"].duplicated().any():
|
|
71
|
+
raise ValueError("Variable names must be unique in the data dictionary.")
|
|
72
|
+
|
|
73
|
+
allowed = {
|
|
74
|
+
"role": ("outcome", "feature", "identifier", "other"),
|
|
75
|
+
"variable type": ("continuous", "categorical", "date and time"),
|
|
76
|
+
}
|
|
77
|
+
for column, options in allowed.items():
|
|
78
|
+
bad_values = dd.loc[~dd[column].isin(options), column]
|
|
79
|
+
if not bad_values.empty:
|
|
80
|
+
raise ValueError(f"Invalid {column}: {bad_values.iloc[0]!r}. Use {', '.join(options)}.")
|
|
81
|
+
|
|
82
|
+
sheet_out = pd.DataFrame(columns=["Mark if true", "Automatically checked", "Item", "Notification"])
|
|
83
|
+
sheet_out.index.name = "#"
|
|
84
|
+
notes = {}
|
|
85
|
+
|
|
86
|
+
#remove variables with role "other"
|
|
87
|
+
others = dd[dd.role == "other"]["variable name"]
|
|
88
|
+
data_full = data.copy()
|
|
89
|
+
for i in others:
|
|
90
|
+
if i in data.columns:
|
|
91
|
+
data = data.drop(i, axis = 1)
|
|
92
|
+
|
|
93
|
+
#get list of categorical variables
|
|
94
|
+
cat_rows = dd[dd["variable type"] == "categorical"]
|
|
95
|
+
cat_cols = cat_rows["variable name"]
|
|
96
|
+
|
|
97
|
+
#find column lable as ID
|
|
98
|
+
id_row = dd[dd.role == "identifier"]
|
|
99
|
+
id_col = id_row["variable name"]
|
|
100
|
+
|
|
101
|
+
#remove ID(s) from list
|
|
102
|
+
if len(id_col) > 0 :
|
|
103
|
+
#cat_cols = cat_cols.drop(id_col, errors='ignore')
|
|
104
|
+
cat_cols = cat_cols[~cat_cols.isin(id_col)]
|
|
105
|
+
|
|
106
|
+
#remove columns not in data (and features with Role "other") from list
|
|
107
|
+
cat_cols = cat_cols[cat_cols.isin(data.columns)]
|
|
108
|
+
|
|
109
|
+
#find continuous variables
|
|
110
|
+
cont_n = dd["variable name"][dd["variable type"]== "continuous"]
|
|
111
|
+
cont_n = cont_n[cont_n.isin(data.columns)]
|
|
112
|
+
conts = data[cont_n]
|
|
113
|
+
|
|
114
|
+
#check if range column is in dd
|
|
115
|
+
if "categories or range" in dd.columns:
|
|
116
|
+
flag_range = 1
|
|
117
|
+
else:
|
|
118
|
+
flag_range = 0
|
|
119
|
+
|
|
120
|
+
#convert variables marked as continous to float
|
|
121
|
+
data_float = conts.apply(pd.to_numeric, errors ="coerce")
|
|
122
|
+
data_float_comb = data_float.copy()
|
|
123
|
+
|
|
124
|
+
cat_data = data[cat_cols]
|
|
125
|
+
for i in cat_cols:
|
|
126
|
+
data_float_comb[i] = pd.factorize(data[i])[0]
|
|
127
|
+
data_float_comb[i] = data_float_comb[i].replace(-1, np.nan)
|
|
128
|
+
|
|
129
|
+
#region 1 Wide format: Each row is an instance, and each column is a variable (in addition to patient ID and target/outcome variable)
|
|
130
|
+
sheet_row = np.full(4, "", dtype= 'object')
|
|
131
|
+
sheet_row[2] = "Wide format: Each row is an instance, and each column is a variable (in addition to patient ID and target/outcome variable)"
|
|
132
|
+
#check if all data columns is datadict rows
|
|
133
|
+
var_not_in_dd = data.columns[~data.columns.isin(dd["variable name"])]
|
|
134
|
+
#rows in data not in dd - check failed
|
|
135
|
+
if len(var_not_in_dd) > 0 :
|
|
136
|
+
error = f"There are columns not described in the Data Dictionary. For instance: {var_not_in_dd[0]}"
|
|
137
|
+
sheet_row[3] = error
|
|
138
|
+
sheet_row[0] = "Fail"
|
|
139
|
+
#check passed
|
|
140
|
+
else:
|
|
141
|
+
sheet_row[0] = "Pass"
|
|
142
|
+
#add row to output sheet
|
|
143
|
+
sheet_row[1] = "Yes"
|
|
144
|
+
sheet_out.loc[1] = sheet_row
|
|
145
|
+
#endregion
|
|
146
|
+
|
|
147
|
+
#region 2 Each patient has a unique identifier (ID)
|
|
148
|
+
#set up line for output sheet
|
|
149
|
+
sheet_row = np.full(4, "", dtype= 'object')
|
|
150
|
+
sheet_row[2] = "Each patient has a unique identifier (ID)"
|
|
151
|
+
|
|
152
|
+
#no ID - check failed
|
|
153
|
+
if len(id_row) == 0:
|
|
154
|
+
error = "No column has Role as Identifier in Data Dictionary."
|
|
155
|
+
sheet_row[3] = error
|
|
156
|
+
sheet_row[0] = "Fail"
|
|
157
|
+
#ID found
|
|
158
|
+
else:
|
|
159
|
+
#(first)ID is in data
|
|
160
|
+
if id_col.iloc[0] in data.columns:
|
|
161
|
+
ids = data[id_col.iloc[0]]
|
|
162
|
+
#all values are unique - check passed
|
|
163
|
+
if ids.is_unique:
|
|
164
|
+
sheet_row[0] = "Pass"
|
|
165
|
+
error = ""
|
|
166
|
+
#duplicate IDs present -check failed
|
|
167
|
+
else:
|
|
168
|
+
id_dubs = ids[ids.duplicated()]
|
|
169
|
+
sheet_row[0] = "Fail"
|
|
170
|
+
error = f"Some IDs are duplicated. For instance: {str(id_dubs.values[0])}"
|
|
171
|
+
#(first) ID not present - check failed
|
|
172
|
+
else:
|
|
173
|
+
sheet_row[0] = "Fail"
|
|
174
|
+
error = f"The column with Role as Identifier {id_col.iloc[0]} is not in Data."
|
|
175
|
+
|
|
176
|
+
sheet_row[3] = error
|
|
177
|
+
sheet_row[1] = "Yes"
|
|
178
|
+
sheet_out.loc[2] = sheet_row
|
|
179
|
+
#endregion
|
|
180
|
+
|
|
181
|
+
#region 3 No Unicode character
|
|
182
|
+
#set up line for output sheet
|
|
183
|
+
sheet_row = np.full(4, "", dtype= 'object')
|
|
184
|
+
sheet_row[2] = "No Unicode character"
|
|
185
|
+
#costum defined char list?
|
|
186
|
+
#char_allowed = string.ascii_lowercase + string.digits
|
|
187
|
+
#function for checking for non-standard character
|
|
188
|
+
def check_cha(x):
|
|
189
|
+
y = False
|
|
190
|
+
for i in str(x):
|
|
191
|
+
if i not in string.printable:
|
|
192
|
+
y = True
|
|
193
|
+
return y
|
|
194
|
+
|
|
195
|
+
#check columns
|
|
196
|
+
col_wrong = data.columns[data.columns.map(lambda x : check_cha(x))]
|
|
197
|
+
#check elements in data
|
|
198
|
+
data_wrong = data[data.map(lambda x : check_cha(x))]
|
|
199
|
+
data_wrong.dropna(axis = 0, how="all", inplace= True)
|
|
200
|
+
data_wrong.dropna(axis = 1, how="all", inplace= True)
|
|
201
|
+
#wrong char in col - failed
|
|
202
|
+
if len(col_wrong) > 0:
|
|
203
|
+
sheet_row[0] = "Fail"
|
|
204
|
+
error = f"There are columns with non-standard characters in data. For instance: {col_wrong[0]}."
|
|
205
|
+
#wrong char in values - failed
|
|
206
|
+
elif len(data_wrong) > 0:
|
|
207
|
+
sheet_row[0] = "Fail"
|
|
208
|
+
wrong_example = data_wrong.notna().idxmax()
|
|
209
|
+
error = f"There are values with non-standard characters in data. For instance: {data_wrong[wrong_example.index[0]].loc[wrong_example.iloc[0]]}."
|
|
210
|
+
#all in allowed chars - passed
|
|
211
|
+
else:
|
|
212
|
+
sheet_row[0] = "Pass"
|
|
213
|
+
error = ""
|
|
214
|
+
|
|
215
|
+
#add row to output sheet
|
|
216
|
+
sheet_row[3] = error
|
|
217
|
+
sheet_row[1] = "Yes"
|
|
218
|
+
sheet_out.loc[3] = sheet_row
|
|
219
|
+
|
|
220
|
+
#endregion
|
|
221
|
+
|
|
222
|
+
#region 4 No duplicate rows and columns
|
|
223
|
+
#set up line for output sheet
|
|
224
|
+
sheet_row = np.full(4, "", dtype= 'object')
|
|
225
|
+
sheet_row[2] = "No duplicate rows and columns"
|
|
226
|
+
|
|
227
|
+
#check if columns are duplicated
|
|
228
|
+
#dub_col = data.columns[data.columns.duplicated()]
|
|
229
|
+
dub_row = data[data.duplicated()]
|
|
230
|
+
#duplicated rows - check failed
|
|
231
|
+
if len(dub_row) > 0 :
|
|
232
|
+
sheet_row[0] = "Fail"
|
|
233
|
+
error = f"There are duplicated rows in data. For instance: {dub_row.iloc[0]}."
|
|
234
|
+
#no duplicates found
|
|
235
|
+
else:
|
|
236
|
+
sheet_row[0] = "Pass"
|
|
237
|
+
error = ""
|
|
238
|
+
|
|
239
|
+
#add row to output sheet
|
|
240
|
+
sheet_row[3] = error
|
|
241
|
+
sheet_row[1] = "Yes"
|
|
242
|
+
sheet_out.loc[4] = sheet_row
|
|
243
|
+
|
|
244
|
+
#endregion
|
|
245
|
+
|
|
246
|
+
#region 5 Test if first column is patient ID
|
|
247
|
+
#set up line for output sheet
|
|
248
|
+
sheet_row = np.full(4, "", dtype= 'object')
|
|
249
|
+
sheet_row[2] = "First column is patient ID"
|
|
250
|
+
#more than one ID - check failed
|
|
251
|
+
if len(id_row) > 1:
|
|
252
|
+
sheet_row[0] = "Fail"
|
|
253
|
+
error = "Multiple columns have Role as Identifiers"
|
|
254
|
+
#no ID - check failed
|
|
255
|
+
elif len(id_row) == 0:
|
|
256
|
+
sheet_row[0] = "Fail"
|
|
257
|
+
error = "No column has Role as Identifier in Data Dictionary"
|
|
258
|
+
#exactly one ID
|
|
259
|
+
elif len(id_row) == 1:
|
|
260
|
+
#ID first column in Data - check passed
|
|
261
|
+
if data_full.columns[0] == id_col.iloc[0]:
|
|
262
|
+
error = ""
|
|
263
|
+
sheet_row[0] = "Pass"
|
|
264
|
+
#ID not first column - check failed
|
|
265
|
+
else:
|
|
266
|
+
sheet_row[0] = "Fail"
|
|
267
|
+
error = f"Column with Role as Identifier is: {id_col.iloc[0]}. First column is: {data_full.columns[0]}."
|
|
268
|
+
#add row to output sheet
|
|
269
|
+
sheet_row[3] = error
|
|
270
|
+
sheet_row[1] = "Yes"
|
|
271
|
+
sheet_out.loc[5] = sheet_row
|
|
272
|
+
#endregion
|
|
273
|
+
|
|
274
|
+
#region 6 Last column is the outcome variable or the main outcome in the case of multiple outcomes
|
|
275
|
+
#set up line for output sheet
|
|
276
|
+
sheet_row = np.full(4, "", dtype= 'object')
|
|
277
|
+
sheet_row[2] = "Last column is the outcome variable or the main outcome in the case of multiple outcomes"
|
|
278
|
+
#more than one ID - check failed
|
|
279
|
+
outcome_row = dd[dd.role == "outcome"]
|
|
280
|
+
outcome_col = outcome_row["variable name"].values
|
|
281
|
+
#no outcome - check failed
|
|
282
|
+
if len(id_row) == 0:
|
|
283
|
+
sheet_row[0] = "Fail"
|
|
284
|
+
error = "No column has Role as outcome in Data Dictionary"
|
|
285
|
+
#check if outcome is last
|
|
286
|
+
else:
|
|
287
|
+
#(one of) outcome last column in Data - check passed
|
|
288
|
+
if data_full.columns[-1] in outcome_col:
|
|
289
|
+
error = ""
|
|
290
|
+
sheet_row[0] = "Pass"
|
|
291
|
+
#outcome not last column - check failed
|
|
292
|
+
else:
|
|
293
|
+
sheet_row[0] = "Fail"
|
|
294
|
+
error = f"Column(s) with Role as Outcome is: {outcome_col}. Last column is: {data_full.columns[-1]}."
|
|
295
|
+
#add row to output sheet
|
|
296
|
+
sheet_row[3] = error
|
|
297
|
+
sheet_row[1] = "Yes"
|
|
298
|
+
sheet_out.loc[6] = sheet_row
|
|
299
|
+
#endregion
|
|
300
|
+
|
|
301
|
+
#region 7 (8) (13) No further separator (e.g., “,” for numbers with four digits or longer such as 1,050,099) and no extra characters “()”,”[]”, “<>”, “//”, “||” and ”{}”. The only acceptable separator is the decimal point.
|
|
302
|
+
sheet_row = np.full(4, "", dtype= 'object')
|
|
303
|
+
sheet_row[2] = "No further separator (e.g., “,” for numbers with four digits or longer such as 1,050,099) and no extra characters “()”,”[]”, “<>”, “//”, “||” and ”{}”. The only acceptable separator is the decimal point"
|
|
304
|
+
|
|
305
|
+
#list of allowed characters
|
|
306
|
+
allowed_cha = list(map(str, np.arange(10)))+list([".", "-"])
|
|
307
|
+
#set up check functions
|
|
308
|
+
def cont_checkcha(x):
|
|
309
|
+
# returns true if all cha allowed
|
|
310
|
+
return(all(c in allowed_cha for c in x))
|
|
311
|
+
|
|
312
|
+
def countdot(x):
|
|
313
|
+
# returns True if more than one .
|
|
314
|
+
y = x.split(".")
|
|
315
|
+
if len(y) > 2:
|
|
316
|
+
return True
|
|
317
|
+
else:
|
|
318
|
+
return False
|
|
319
|
+
|
|
320
|
+
def check_minus(x):
|
|
321
|
+
#returns True if misplaced minus
|
|
322
|
+
if "-" in x:
|
|
323
|
+
x = x[1:]
|
|
324
|
+
if len(x) > 0:
|
|
325
|
+
if "-" in x:
|
|
326
|
+
return True
|
|
327
|
+
else:
|
|
328
|
+
return False
|
|
329
|
+
else:
|
|
330
|
+
return True
|
|
331
|
+
else:
|
|
332
|
+
return False
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
flag_cont = 0
|
|
336
|
+
|
|
337
|
+
for col in conts.columns:
|
|
338
|
+
#remove NaN
|
|
339
|
+
conts_col_not_nan = conts[col][~conts[col].isna()]
|
|
340
|
+
#get bad values
|
|
341
|
+
x = conts_col_not_nan[~conts_col_not_nan.apply(cont_checkcha)]
|
|
342
|
+
z = conts_col_not_nan[conts_col_not_nan.apply(check_minus)]
|
|
343
|
+
y = conts_col_not_nan[conts_col_not_nan.apply(countdot)]
|
|
344
|
+
|
|
345
|
+
if (len(x) > 0) and flag_cont == 0:
|
|
346
|
+
flag_cont = 1
|
|
347
|
+
bad_col = col
|
|
348
|
+
bad_val = x.iloc[0]
|
|
349
|
+
error = f"There are non permitted characters in a continuous variable. For instance: {bad_val} In column: {bad_col}"
|
|
350
|
+
elif (len(y) > 0) and flag_cont == 0:
|
|
351
|
+
flag_cont = 1
|
|
352
|
+
bad_col = col
|
|
353
|
+
bad_val = y.iloc[0]
|
|
354
|
+
error = f"There are multiple \".\"s in a continuous variable. For instance: {bad_val} In column: {bad_col}."
|
|
355
|
+
elif (len(z) > 0) and flag_cont == 0:
|
|
356
|
+
flag_cont = 1
|
|
357
|
+
bad_col = col
|
|
358
|
+
bad_val = z.iloc[0]
|
|
359
|
+
error = f"There are misplaced \"-\"s in a continuous variable. For instance: {bad_val} In column: {bad_col}."
|
|
360
|
+
|
|
361
|
+
if flag_cont == 1:
|
|
362
|
+
sheet_row[0] = "Fail"
|
|
363
|
+
else:
|
|
364
|
+
sheet_row[0] = "Pass"
|
|
365
|
+
error = ""
|
|
366
|
+
if len(conts.columns) == 0:
|
|
367
|
+
notes[7] = "No columns marked as \"continuous\" found"
|
|
368
|
+
|
|
369
|
+
#add row to output sheet
|
|
370
|
+
sheet_row[1] = "Yes"
|
|
371
|
+
sheet_row[3] = error
|
|
372
|
+
sheet_out.loc[7] = sheet_row
|
|
373
|
+
#endregion
|
|
374
|
+
|
|
375
|
+
#region 8 (7) All missing entries are indicated by the same entry (such as NA for not available) ### TEXT IS WRONG AND SHOULD BE UPDATED
|
|
376
|
+
#set up line for output sheet
|
|
377
|
+
sheet_row = np.full(4, "", dtype= 'object')
|
|
378
|
+
sheet_row[2] = "All missing entries are indicated by the same entry (e.g., either \"missing\" or an empty field for not available) "
|
|
379
|
+
#NaN present in data - check failed
|
|
380
|
+
if data.isnull().values.any():
|
|
381
|
+
sheet_row[0] = "Fail"
|
|
382
|
+
idx, idy = np.where(pd.isnull(data))
|
|
383
|
+
error = f"There are NaN values in data. For instance column: {data.columns[idy[0]]} row: {data.index[idx[0]]} in data."
|
|
384
|
+
#"na" present in data - check failed
|
|
385
|
+
elif (data == "na" ).any().any():
|
|
386
|
+
sheet_row[0] = "Fail"
|
|
387
|
+
idx, idy = np.where(data == "na")
|
|
388
|
+
error = f"There are \"na\" values in data. For instance column: {data.columns[idy[0]]} row: {data.index[idx[0]]} in data."
|
|
389
|
+
#"-" present in data - check failed
|
|
390
|
+
elif (data == "-" ).any().any():
|
|
391
|
+
sheet_row[0] = "Fail"
|
|
392
|
+
idx, idy = np.where(data == "-")
|
|
393
|
+
error = f"There are \"-\" values in data. For instance column: {data.columns[idy[0]]} row: {data.index[idx[0]]} in data."
|
|
394
|
+
#both empty fields and "missing" present in data - check failed
|
|
395
|
+
elif (data == "" ).any().any() and (data == "missing").any().any():
|
|
396
|
+
sheet_row[0] = "Fail"
|
|
397
|
+
idx, idy = np.where(data == "")
|
|
398
|
+
jdx, jdy = np.where(data == "missing")
|
|
399
|
+
error = f"There are \"missing\" and empty values in data. For instance column: {data.columns[idy[0]]} row: {data.index[idx[0]]}, and column: {data.columns[jdy[0]]} row: {data.index[jdx[0]]} in data."
|
|
400
|
+
#no errors found - check passed
|
|
401
|
+
else :
|
|
402
|
+
error = ""
|
|
403
|
+
sheet_row[0] = "Pass"
|
|
404
|
+
#add row to output sheet
|
|
405
|
+
sheet_row[3] = error
|
|
406
|
+
sheet_row[1] = "Yes"
|
|
407
|
+
sheet_out.loc[8] = sheet_row
|
|
408
|
+
#endregion
|
|
409
|
+
|
|
410
|
+
#region 9 (10) (20) No instance has all-missing variables
|
|
411
|
+
|
|
412
|
+
#set up line for output sheet
|
|
413
|
+
sheet_row = np.full(4, "", dtype= 'object')
|
|
414
|
+
sheet_row[2] = "No instance has all-missing variables"
|
|
415
|
+
|
|
416
|
+
all_miss = data.columns[data.isna().all(0)]
|
|
417
|
+
|
|
418
|
+
if len(all_miss) == 0:
|
|
419
|
+
sheet_row[0] = "Pass"
|
|
420
|
+
error = ""
|
|
421
|
+
else:
|
|
422
|
+
error = f"Some columns has all missing values. For instance column: {all_miss[0]}."
|
|
423
|
+
sheet_row[0] = "Fail"
|
|
424
|
+
|
|
425
|
+
#add row to output sheet
|
|
426
|
+
sheet_row[1] = "Yes"
|
|
427
|
+
sheet_row[3] = error
|
|
428
|
+
sheet_out.loc[9] = sheet_row
|
|
429
|
+
#endregion
|
|
430
|
+
|
|
431
|
+
#region 10 (15) (10) A data dictionary (codebook) is provided that defines all variables, their types (categorical, ordinal, and interval) and units (e.g. kg)
|
|
432
|
+
#set up line for output sheet
|
|
433
|
+
sheet_row = np.full(4, "", dtype= 'object')
|
|
434
|
+
sheet_row[2] = "A data dictionary (codebook) is provided that defines all variables, their types (continuous, categorical or date and time) and units (e.g., kg)"
|
|
435
|
+
|
|
436
|
+
#columns in data not in dd - check failed
|
|
437
|
+
if len(var_not_in_dd) > 0 :
|
|
438
|
+
error = f"There are columns not described in the Data Dictionary. For instance: {var_not_in_dd[0]}"
|
|
439
|
+
sheet_row[0] = "Fail"
|
|
440
|
+
#variable type not defined for all data columns - check failed
|
|
441
|
+
elif "units" not in dd.columns:
|
|
442
|
+
error = "No column named \"units\" in Data Dictionary."
|
|
443
|
+
sheet_row[0] = "Fail"
|
|
444
|
+
#There are missing values in units column - check failed
|
|
445
|
+
elif dd.units.isna().values.any():
|
|
446
|
+
example = dd["variable name"][dd.units.isna()].values[0]
|
|
447
|
+
error = f"There are missing values in the \"units\" column in the Data Dictionary. For instance for: {example}."
|
|
448
|
+
sheet_row[0] = "Fail"
|
|
449
|
+
else:
|
|
450
|
+
sheet_row[0] = "Pass"
|
|
451
|
+
error = ""
|
|
452
|
+
|
|
453
|
+
#add row to output sheet
|
|
454
|
+
sheet_row[1] = "Yes"
|
|
455
|
+
sheet_row[3] = error
|
|
456
|
+
sheet_out.loc[10] = sheet_row
|
|
457
|
+
#endregion
|
|
458
|
+
|
|
459
|
+
#region 11 (12) (22) The actual data values for continuous variables are within the range listed in data dictionary (Check consistency between data dictionary and actual data values)
|
|
460
|
+
|
|
461
|
+
#set up line for output sheet
|
|
462
|
+
sheet_row = np.full(4, "", dtype= 'object')
|
|
463
|
+
sheet_row[2] = "The actual data values for continuous variables are within the range listed in data dictionary"
|
|
464
|
+
|
|
465
|
+
cont_flag = 0
|
|
466
|
+
cont_comment = 0
|
|
467
|
+
|
|
468
|
+
if flag_range == 1:
|
|
469
|
+
for i in data_float.columns:
|
|
470
|
+
if cont_flag == 0:
|
|
471
|
+
range_values = str(dd.loc[dd["variable name"] == i, "categories or range"].iloc[0]).split(";")
|
|
472
|
+
|
|
473
|
+
if len(range_values) != 2:
|
|
474
|
+
cont_flag = 2
|
|
475
|
+
else:
|
|
476
|
+
try:
|
|
477
|
+
r_1, r_2 = map(float, range_values)
|
|
478
|
+
except (TypeError, ValueError):
|
|
479
|
+
cont_flag = 2
|
|
480
|
+
|
|
481
|
+
if cont_flag == 2:
|
|
482
|
+
error = f"Range is not listed correctly in Data Dictionary with two numerical values separeted by a \";\". For instance for variable: {i}."
|
|
483
|
+
elif data_float[i].dropna().between(r_1,r_2).all() == False:
|
|
484
|
+
cont_flag = 1
|
|
485
|
+
bad_cont = i
|
|
486
|
+
bad_cont_val = data_float[i].dropna()[~data_float[i].dropna().between(r_1,r_2)].iloc[0]
|
|
487
|
+
elif len(data_float[i].dropna()) == 0:
|
|
488
|
+
cont_comment = 1
|
|
489
|
+
bad_cont = i
|
|
490
|
+
|
|
491
|
+
if flag_range == 0:
|
|
492
|
+
sheet_row[0] = "Fail"
|
|
493
|
+
error = f"There are no column called \"Categories or range\" in the Data Dictionary"
|
|
494
|
+
|
|
495
|
+
elif cont_flag == 0:
|
|
496
|
+
sheet_row[0] = "Pass"
|
|
497
|
+
error = ""
|
|
498
|
+
if len(cont_n) == 0:
|
|
499
|
+
notes[11] = "No variables marked as \"continuous\" found"
|
|
500
|
+
elif cont_comment == 1:
|
|
501
|
+
notes[11] = f"Variable {bad_cont} has no numerical values."
|
|
502
|
+
|
|
503
|
+
else:
|
|
504
|
+
sheet_row[0] = "Fail"
|
|
505
|
+
error = "There are values outside of the range defined in the Data Dictionary"
|
|
506
|
+
|
|
507
|
+
sheet_row[1] = "Yes"
|
|
508
|
+
sheet_row[3] = error
|
|
509
|
+
sheet_out.loc[11] = sheet_row
|
|
510
|
+
|
|
511
|
+
#endregion
|
|
512
|
+
|
|
513
|
+
#region 12 (9) (17) Categorical variables have all their categories listed in the data dictionary (All the entries for each variable follow the same format (units for numerical variables and categories for categorical variables)
|
|
514
|
+
#set up line for output sheet)
|
|
515
|
+
sheet_row = np.full(4, "", dtype= 'object')
|
|
516
|
+
sheet_row[2] = "Categorical variables have all their categories listed in the data dictionary"
|
|
517
|
+
|
|
518
|
+
cat_flag = 0
|
|
519
|
+
|
|
520
|
+
if flag_range == 1:
|
|
521
|
+
for i in cat_cols:
|
|
522
|
+
#get potential catogirical values from dd
|
|
523
|
+
cat_values = str(dd.loc[dd["variable name"] == i, "categories or range"].iloc[0]).split(";")
|
|
524
|
+
#remove white space
|
|
525
|
+
cat_values = [cat_val.strip() for cat_val in cat_values]
|
|
526
|
+
|
|
527
|
+
#check all values are in potential values
|
|
528
|
+
if cat_flag == 0 and not set(data[i].unique()).issubset(cat_values):
|
|
529
|
+
cat_flag = 1
|
|
530
|
+
bad_cat = i
|
|
531
|
+
bad_cat_val = list(set(data[i].unique()) - set(cat_values))[0]
|
|
532
|
+
|
|
533
|
+
#no range column - check failed
|
|
534
|
+
if flag_range == 0:
|
|
535
|
+
sheet_row[0] = "Fail"
|
|
536
|
+
error = f"There are no column called \"Categories or range\" in the Data Dictionary"
|
|
537
|
+
#no values not listed found - check passed
|
|
538
|
+
elif cat_flag == 0:
|
|
539
|
+
sheet_row[0] = "Pass"
|
|
540
|
+
error = ""
|
|
541
|
+
if len(cat_cols) == 0:
|
|
542
|
+
notes[12] = "No non-ID columns marked as \"categorical\" found"
|
|
543
|
+
#categories not listed found - check failed
|
|
544
|
+
else:
|
|
545
|
+
sheet_row[0] = "Fail"
|
|
546
|
+
error = f"There are rare categories in the data not listed in the Data Dictionary. For instance: [{bad_cat_val}] in column: {bad_cat}."
|
|
547
|
+
|
|
548
|
+
#add row to output sheet
|
|
549
|
+
sheet_row[3] = error
|
|
550
|
+
sheet_row[1] = "Yes"
|
|
551
|
+
sheet_out.loc[12] = sheet_row
|
|
552
|
+
#endregion
|
|
553
|
+
|
|
554
|
+
#region 13 (14) (9) Rare categories in categorical variables are grouped
|
|
555
|
+
#set up line for output sheet
|
|
556
|
+
sheet_row = np.full(4, "", dtype= 'object')
|
|
557
|
+
sheet_row[2] = "Rare categories in categorical variables are grouped"
|
|
558
|
+
|
|
559
|
+
flag_c = 1
|
|
560
|
+
for i in cat_cols:
|
|
561
|
+
freq = data[i].value_counts(normalize=True, ascending=True)
|
|
562
|
+
freq_rare = freq[freq < 0.05]
|
|
563
|
+
if len(freq_rare > 0):
|
|
564
|
+
flag_c = 0
|
|
565
|
+
rare_col = i
|
|
566
|
+
rare_1 = freq_rare.index[0]
|
|
567
|
+
#rare_2 = freq_rare.index[1]
|
|
568
|
+
#No rare categories found - check passed
|
|
569
|
+
if flag_c == 1:
|
|
570
|
+
sheet_row[0] = "Pass"
|
|
571
|
+
error = ""
|
|
572
|
+
if len(cat_cols) == 0:
|
|
573
|
+
notes[13] = "No non-ID columns marked as \"categorical\" found"
|
|
574
|
+
else:
|
|
575
|
+
sheet_row[0] = "Fail"
|
|
576
|
+
error = f"There are rare categories in data. For instance: [{rare_1}] in column: {rare_col}."
|
|
577
|
+
|
|
578
|
+
sheet_row[3] = error
|
|
579
|
+
sheet_row[1] = "Yes"
|
|
580
|
+
sheet_out.loc[13] = sheet_row
|
|
581
|
+
#endregion
|
|
582
|
+
|
|
583
|
+
#region 14 (11) (21) Perfectly collinear variables are removed
|
|
584
|
+
|
|
585
|
+
#set up line for output sheet
|
|
586
|
+
sheet_row = np.full(4, "", dtype= 'object')
|
|
587
|
+
sheet_row[2] = "Perfectly collinear variables are removed"
|
|
588
|
+
|
|
589
|
+
corr_matrix = data_float_comb.corr()
|
|
590
|
+
off_diagonal = ~np.eye(len(corr_matrix), dtype=bool)
|
|
591
|
+
perf_corr = corr_matrix.where((corr_matrix > 0.999) & off_diagonal)
|
|
592
|
+
|
|
593
|
+
perf_corr = perf_corr.dropna(how = 'all', axis = 0)
|
|
594
|
+
perf_corr = perf_corr.dropna(how = 'all', axis = 1)
|
|
595
|
+
|
|
596
|
+
#check passed
|
|
597
|
+
if len(perf_corr) == 0:
|
|
598
|
+
sheet_row[0] = "Pass"
|
|
599
|
+
error = ""
|
|
600
|
+
#check failed
|
|
601
|
+
else:
|
|
602
|
+
error = f"Some columns are perfectly collinear. For instance variables: {perf_corr.columns[0]} and {perf_corr.notna().idxmax()[perf_corr.columns[0]]}]"
|
|
603
|
+
sheet_row[0] = "Fail"
|
|
604
|
+
|
|
605
|
+
#add row to output sheet
|
|
606
|
+
sheet_row[1] = "Yes"
|
|
607
|
+
sheet_row[3] = error
|
|
608
|
+
sheet_out.loc[14] = sheet_row
|
|
609
|
+
#endregion
|
|
610
|
+
|
|
611
|
+
#region 15 (13) (24) Irrelevant observations that could skew the results or cause bias (e.g., outliers or extreme values that do not reflect normal conditions) are removed
|
|
612
|
+
|
|
613
|
+
#set up line for output sheet
|
|
614
|
+
sheet_row = np.full(4, "", dtype= 'object')
|
|
615
|
+
sheet_row[2] = "Irrelevant observations that could skew the results or cause bias (e.g., outliers or extreme values that do not reflect normal conditions) are removed"
|
|
616
|
+
|
|
617
|
+
out_flag = 0
|
|
618
|
+
cont_comment = 0
|
|
619
|
+
|
|
620
|
+
for i in data_float.columns:
|
|
621
|
+
if out_flag == 0:
|
|
622
|
+
#check if not all NaN
|
|
623
|
+
if len(data_float[i].dropna()) > 0:
|
|
624
|
+
#get interquantile range
|
|
625
|
+
q1 = data_float[i].quantile(.25)
|
|
626
|
+
q3 = data_float[i].quantile(.75)
|
|
627
|
+
iqr = q3 - q1
|
|
628
|
+
|
|
629
|
+
#find outliers
|
|
630
|
+
outliers = data_float[i].dropna()[~data_float[i].dropna().between((q1-3*iqr),(q3+3*iqr))]
|
|
631
|
+
|
|
632
|
+
if len(outliers) > 0:
|
|
633
|
+
out_flag = 1
|
|
634
|
+
cont_out = i
|
|
635
|
+
cont_out_val = outliers.iloc[0]
|
|
636
|
+
#if all NaN
|
|
637
|
+
elif cont_comment == 0:
|
|
638
|
+
cont_out = i
|
|
639
|
+
cont_comment = 1
|
|
640
|
+
|
|
641
|
+
#no outliers found - check passed
|
|
642
|
+
if out_flag == 0:
|
|
643
|
+
sheet_row[0] = "Pass"
|
|
644
|
+
error = ""
|
|
645
|
+
if len(cont_n) == 0:
|
|
646
|
+
notes[15] = "No variables marked as \"continuous\" found"
|
|
647
|
+
elif cont_comment == 1:
|
|
648
|
+
notes[15] = f"Variable {cont_out} has no numerical values."
|
|
649
|
+
|
|
650
|
+
else:
|
|
651
|
+
sheet_row[0] = "Fail"
|
|
652
|
+
error = f"There are outliers in the data. For instance variable: {cont_out} has value: {cont_out_val}."
|
|
653
|
+
|
|
654
|
+
sheet_row[1] = "Yes"
|
|
655
|
+
sheet_row[3] = error
|
|
656
|
+
sheet_out.loc[15] = sheet_row
|
|
657
|
+
#endregion
|
|
658
|
+
|
|
659
|
+
for number, description in _MANUAL_CHECKS.items():
|
|
660
|
+
sheet_out.loc[number] = ["Unknown", "No", description, ""]
|
|
661
|
+
|
|
662
|
+
return ValidationReport(sheet_out, notes)
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: daims-validation
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: Validate and document datasets for biomedical and clinical machine learning
|
|
5
|
+
Author: Ramtin Zargari Marandi, Anne Svane Frahm, Maja Milojevic
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/PERSIMUNE/DAIMS
|
|
8
|
+
Project-URL: Documentation, https://github.com/PERSIMUNE/DAIMS#readme
|
|
9
|
+
Project-URL: Issues, https://github.com/PERSIMUNE/DAIMS/issues
|
|
10
|
+
Project-URL: Research paper, https://arxiv.org/abs/2501.14094
|
|
11
|
+
Keywords: dataset validation,data quality,data dictionary,metadata,biomedical research,clinical machine learning
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: pandas>=2.1
|
|
21
|
+
Requires-Dist: numpy>=1.24
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# DAIMS: Datasheets for AI and Medical Datasets
|
|
25
|
+
|
|
26
|
+
<p align="center">
|
|
27
|
+
<img src="https://github.com/PERSIMUNE/DAIMS/blob/main/DAIMSlogo.svg" alt="DAIMS Logo" width="300">
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
 [](https://github.com/PERSIMUNE/DAIMS/releases/tag/v1.0.0) [](https://scholar.google.com/scholar?cites=8674731473406692984&hl=en) [](https://daims-app.streamlit.app/) [](https://huggingface.co/spaces/ramtinzm/DAIMS) [](https://www.kaggle.com/code/remyz5/daims-dataset-checks)
|
|
31
|
+
|
|
32
|
+
**DAIMS (Datasheets for AI and Medical Datasets)** helps researchers check and document datasets before machine learning analysis. It combines a 24-point checklist, automated data checks, a dataset documentation form, a data dictionary template, and a flowchart for choosing analysis methods.
|
|
33
|
+
|
|
34
|
+
Use the [online app](https://daims-app.streamlit.app/) to run the automated checks, and the templates in this repository to document your dataset. DAIMS builds on the *Datasheets for Datasets* framework with guidance tailored to medical data and AI research.
|
|
35
|
+
|
|
36
|
+
## Key Features
|
|
37
|
+
|
|
38
|
+
1. **Comprehensive Checklist**
|
|
39
|
+
A 24-point checklist that covers common data standardization requirements. A subset of these checks is automated by the DAIMS software tool to validate dataset readiness.
|
|
40
|
+
|
|
41
|
+
2. **Data Documentation Form**
|
|
42
|
+
An extended documentation form designed to capture essential metadata, pose relevant research questions, and ensure datasets are well-prepared for ML analysis.
|
|
43
|
+
|
|
44
|
+
3. **Data Dictionary Table**
|
|
45
|
+
A tabular format to document variable descriptions, data types, units, and any relevant details about the dataset.
|
|
46
|
+
|
|
47
|
+
4. **Flowchart for ML Analyses**
|
|
48
|
+
A guided flowchart that maps research questions to suggested ML methods, providing researchers with a clear pathway to address their objectives.
|
|
49
|
+
|
|
50
|
+
5. **Software Tool**
|
|
51
|
+
A publicly available tool to assist in dataset preparation by automating key aspects of the checklist validation process.
|
|
52
|
+
|
|
53
|
+
6. **Online App**
|
|
54
|
+
DAIMS is available as an easy-to-use online app hosted at [https://daims-app.streamlit.app/](https://daims-app.streamlit.app/), enabling efficient dataset evaluation and preparation.
|
|
55
|
+
|
|
56
|
+
## Benefits of DAIMS
|
|
57
|
+
|
|
58
|
+
- **Standardization**: Promotes consistent practices for preparing datasets in medical research.
|
|
59
|
+
- **Guidance**: Offers actionable insights through the flowchart and checklist, helping researchers align datasets with their ML objectives.
|
|
60
|
+
- **Automation**: Saves time by automating key validation processes.
|
|
61
|
+
- **Documentation**: Enhances transparency and reproducibility through detailed data documentation.
|
|
62
|
+
|
|
63
|
+
## Choose how to start
|
|
64
|
+
|
|
65
|
+
| What you want to do | Where to start |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| Check and document a sample dataset | [Try the worked example](https://github.com/PERSIMUNE/DAIMS/tree/main/examples/synthetic-clinic/) |
|
|
68
|
+
| Run the sample checks and compare the results | [DAIMS notebook on Kaggle](https://www.kaggle.com/code/remyz5/daims-dataset-checks) |
|
|
69
|
+
| Check your own dataset | [Open the DAIMS app](https://daims-app.streamlit.app/) |
|
|
70
|
+
| Document your dataset | [DAIMS datasheet template](https://github.com/PERSIMUNE/DAIMS/blob/main/DAIMS_DatasetName_DDMMYYYY.md) |
|
|
71
|
+
| Download the versioned templates | [DAIMS v1.0.0 templates ZIP](https://github.com/PERSIMUNE/DAIMS/releases/download/v1.0.0/DAIMS-templates.zip) |
|
|
72
|
+
| Review the full checklist and analysis flowchart | [DAIMS methods paper](https://arxiv.org/abs/2501.14094) |
|
|
73
|
+
|
|
74
|
+
## Run the checks in Python
|
|
75
|
+
|
|
76
|
+
Install the Python preview from PyPI:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
python -m pip install --pre daims-validation
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
From a [repository checkout](https://github.com/PERSIMUNE/DAIMS), try the same synthetic inputs used in the app walkthrough:
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
import pandas as pd
|
|
86
|
+
from daims import validate_dataset
|
|
87
|
+
|
|
88
|
+
folder = "examples/synthetic-clinic"
|
|
89
|
+
data = pd.read_csv(f"{folder}/starter-data.csv", dtype=str, keep_default_na=False)
|
|
90
|
+
dictionary = pd.read_csv(f"{folder}/starter-dictionary.csv")
|
|
91
|
+
report = validate_dataset(data, dictionary)
|
|
92
|
+
|
|
93
|
+
print(report.checklist.loc[[8, 10, 12], ["Mark if true", "Notification"]])
|
|
94
|
+
report.checklist.to_csv("daims-checklist.csv")
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The report contains all 24 checklist items and any informational notes. The nine manual items start as `Unknown` and can be reviewed in the Streamlit app. Use `dtype=str` when reading the dataset to preserve formatting that the checks can inspect.
|
|
98
|
+
|
|
99
|
+
## DAIMS in research
|
|
100
|
+
|
|
101
|
+
**[Cited by 11 works on Google Scholar](https://scholar.google.com/scholar?cites=8674731473406692984&hl=en)** · As of 3 November 2026.
|
|
102
|
+
|
|
103
|
+
DAIMS is cited across medical research, dataset documentation, pharmaceutical data quality, scientific software, and responsible AI. All 11 citing works are listed below, grouped by research area.
|
|
104
|
+
|
|
105
|
+
| Research area | Citing publication |
|
|
106
|
+
| --- | --- |
|
|
107
|
+
| Cancer research | [Machine learning and deep learning in glioblastoma: systematic review and meta-analysis](https://doi.org/10.1007/s12672-025-03303-7) |
|
|
108
|
+
| Cancer research | [Testicular cancer relapse prediction](https://doi.org/10.1111/andr.70195) |
|
|
109
|
+
| Gynecologic diagnostics | [Optical coherence tomography and AI in gynecologic diagnostics](https://www.authorea.com/doi/full/10.22541/au.176790712.29291970) |
|
|
110
|
+
| Clinical data preparation | [From medical records to AI-ready datasets: a practical guide](https://www.mdpi.com/2077-0383/15/16/6297) |
|
|
111
|
+
| Healthcare AI | [Responsible foundation models for healthcare](https://doi.org/10.1201/9781003737810-7) |
|
|
112
|
+
| Pharmaceutical data quality | [Evaluating data fitness for AI: the PAIR framework](https://sarcouncil.com/2025/07/evaluating-data-fitness-for-ai-in-pharmaceutical-applications-the-pair-framework) |
|
|
113
|
+
| Dataset documentation | [From reflection to repair: a scoping review of dataset documentation tools](https://doi.org/10.1145/3772318.3791344) |
|
|
114
|
+
| Scientific software and physics | [Scientific software development in the AI era: reproducibility, MLOps, and soft matter physics](https://doi.org/10.3389/fphy.2025.1711356) |
|
|
115
|
+
| Responsible AI and risk management | [Open problems in frontier AI risk management](https://arxiv.org/abs/2604.25982) |
|
|
116
|
+
| Responsible AI and risk management | [Engineering trustworthy AI: the VERITAS framework](https://ieeexplore.ieee.org/abstract/document/11662190/) |
|
|
117
|
+
| Document processing and automation | [Automated data extraction from documents using AI](https://run.unl.pt/server/api/core/bitstreams/d44147b1-0557-4deb-bba3-065cee392bed/content) |
|
|
118
|
+
|
|
119
|
+
The [testicular cancer study](https://doi.org/10.1111/andr.70195) applied the DAIMS checklist to guide data curation and preprocessing.
|
|
120
|
+
|
|
121
|
+
Used DAIMS in your research? [Share your work](https://github.com/PERSIMUNE/DAIMS/issues/new) to be featured here.
|
|
122
|
+
|
|
123
|
+
## Citation
|
|
124
|
+
|
|
125
|
+
If you use DAIMS in your research, please cite our work:
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
@article{marandi2025daims,
|
|
129
|
+
title={Datasheets for AI and medical datasets (DAIMS): a data validation and documentation framework before machine learning analysis in medical research},
|
|
130
|
+
author={Ramtin Zargari Marandi and Anne Svane Frahm and Maja Milojevic},
|
|
131
|
+
journal={arXiv preprint arXiv:2501.14094},
|
|
132
|
+
year={2025},
|
|
133
|
+
url={https://arxiv.org/abs/2501.14094}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
You can find the preprint of our work on [arXiv](https://arxiv.org/abs/2501.14094).
|
|
138
|
+
|
|
139
|
+
## Contributing
|
|
140
|
+
|
|
141
|
+
We welcome contributions to improve DAIMS! Feel free to open issues, submit pull requests, or provide feedback on the GitHub repository.
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
This project is licensed under the [MIT License](https://github.com/PERSIMUNE/DAIMS/blob/main/LICENSE).
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
CITATION.cff
|
|
2
|
+
LICENSE
|
|
3
|
+
MANIFEST.in
|
|
4
|
+
README.md
|
|
5
|
+
daims.py
|
|
6
|
+
pyproject.toml
|
|
7
|
+
daims_validation.egg-info/PKG-INFO
|
|
8
|
+
daims_validation.egg-info/SOURCES.txt
|
|
9
|
+
daims_validation.egg-info/dependency_links.txt
|
|
10
|
+
daims_validation.egg-info/requires.txt
|
|
11
|
+
daims_validation.egg-info/top_level.txt
|
|
12
|
+
examples/synthetic-clinic/reviewed-data.csv
|
|
13
|
+
examples/synthetic-clinic/reviewed-dictionary.csv
|
|
14
|
+
examples/synthetic-clinic/source-records.csv
|
|
15
|
+
examples/synthetic-clinic/starter-data.csv
|
|
16
|
+
examples/synthetic-clinic/starter-dictionary.csv
|
|
17
|
+
tests/test_validation.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
daims
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
visit_id,systolic_bp,visit_type,follow_up
|
|
2
|
+
v01,118,routine,no
|
|
3
|
+
v02,135,urgent,yes
|
|
4
|
+
v03,126,routine,no
|
|
5
|
+
v04,142,routine,yes
|
|
6
|
+
v05,129,urgent,no
|
|
7
|
+
v06,151,urgent,yes
|
|
8
|
+
v07,123,routine,no
|
|
9
|
+
v08,132,routine,yes
|
|
10
|
+
v09,145,urgent,no
|
|
11
|
+
v10,121,urgent,yes
|
|
12
|
+
v11,137,routine,no
|
|
13
|
+
v12,128,urgent,yes
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Variable Name,Role,Variable Type,Units,Categories or range,Description
|
|
2
|
+
visit_id,identifier,categorical,unitless,v01 through v12,Synthetic visit identifier
|
|
3
|
+
systolic_bp,feature,continuous,mmHg,80;200,Systolic blood pressure at the index visit
|
|
4
|
+
visit_type,feature,categorical,unitless,routine;urgent,Visit category at intake
|
|
5
|
+
follow_up,outcome,categorical,unitless,no;yes,Whether a follow-up occurred within 30 days
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
visit_id,systolic_bp,visit_type,follow_up
|
|
2
|
+
v01,118,routine,no
|
|
3
|
+
v02,135,urgent,yes
|
|
4
|
+
v03,126,routine,no
|
|
5
|
+
v04,142,rtne,yes
|
|
6
|
+
v05,129,urgent,no
|
|
7
|
+
v06,151,urgent,yes
|
|
8
|
+
v07,123,routine,no
|
|
9
|
+
v08,NA,routine,yes
|
|
10
|
+
v09,145,urgent,no
|
|
11
|
+
v10,121,urgent,yes
|
|
12
|
+
v11,137,routine,no
|
|
13
|
+
v12,128,urgent,yes
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Variable Name,Role,Variable Type,Units,Categories or range,Description
|
|
2
|
+
visit_id,identifier,categorical,unitless,v01 through v12,Synthetic visit identifier
|
|
3
|
+
systolic_bp,feature,continuous,,80;200,Systolic blood pressure at the index visit
|
|
4
|
+
visit_type,feature,categorical,unitless,routine;urgent,Visit category at intake
|
|
5
|
+
follow_up,outcome,categorical,unitless,no;yes,Whether a follow-up occurred within 30 days
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "daims-validation"
|
|
7
|
+
version = "0.1.0a1"
|
|
8
|
+
description = "Validate and document datasets for biomedical and clinical machine learning"
|
|
9
|
+
license = "MIT"
|
|
10
|
+
license-files = ["LICENSE"]
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "Ramtin Zargari Marandi"},
|
|
13
|
+
{name = "Anne Svane Frahm"},
|
|
14
|
+
{name = "Maja Milojevic"},
|
|
15
|
+
]
|
|
16
|
+
keywords = ["dataset validation", "data quality", "data dictionary", "metadata", "biomedical research", "clinical machine learning"]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 3 - Alpha",
|
|
19
|
+
"Intended Audience :: Science/Research",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Topic :: Scientific/Engineering :: Bio-Informatics",
|
|
22
|
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
23
|
+
]
|
|
24
|
+
readme = "README.md"
|
|
25
|
+
requires-python = ">=3.10"
|
|
26
|
+
dependencies = ["pandas>=2.1", "numpy>=1.24"]
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Repository = "https://github.com/PERSIMUNE/DAIMS"
|
|
30
|
+
Documentation = "https://github.com/PERSIMUNE/DAIMS#readme"
|
|
31
|
+
Issues = "https://github.com/PERSIMUNE/DAIMS/issues"
|
|
32
|
+
"Research paper" = "https://arxiv.org/abs/2501.14094"
|
|
33
|
+
|
|
34
|
+
[tool.setuptools]
|
|
35
|
+
py-modules = ["daims"]
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
import unittest
|
|
3
|
+
|
|
4
|
+
import pandas as pd
|
|
5
|
+
|
|
6
|
+
from daims import validate_dataset
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
EXAMPLE = Path(__file__).resolve().parents[1] / "examples" / "synthetic-clinic"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ValidationTests(unittest.TestCase):
|
|
13
|
+
def load_example(self, stage):
|
|
14
|
+
data = pd.read_csv(EXAMPLE / f"{stage}-data.csv", dtype=str, keep_default_na=False)
|
|
15
|
+
dictionary = pd.read_csv(EXAMPLE / f"{stage}-dictionary.csv")
|
|
16
|
+
return data, dictionary
|
|
17
|
+
|
|
18
|
+
def test_synthetic_checklist(self):
|
|
19
|
+
for stage, expected in (("starter", "Fail"), ("reviewed", "Pass")):
|
|
20
|
+
with self.subTest(stage=stage):
|
|
21
|
+
data, dictionary = self.load_example(stage)
|
|
22
|
+
report = validate_dataset(data, dictionary)
|
|
23
|
+
self.assertEqual(list(report.checklist.index), list(range(1, 25)))
|
|
24
|
+
self.assertEqual(report.checklist.loc[[8, 10, 12], "Mark if true"].tolist(), [expected] * 3)
|
|
25
|
+
self.assertEqual(report.checklist.loc[16:24, "Mark if true"].tolist(), ["Unknown"] * 9)
|
|
26
|
+
|
|
27
|
+
def test_typed_input_and_non_default_dictionary_index(self):
|
|
28
|
+
data, dictionary = self.load_example("reviewed")
|
|
29
|
+
data["systolic_bp"] = pd.to_numeric(data["systolic_bp"])
|
|
30
|
+
dictionary.index += 10
|
|
31
|
+
original_data, original_dictionary = data.copy(), dictionary.copy()
|
|
32
|
+
|
|
33
|
+
report = validate_dataset(data, dictionary)
|
|
34
|
+
|
|
35
|
+
self.assertEqual(report.checklist.loc[[5, 7, 11], "Mark if true"].tolist(), ["Pass"] * 3)
|
|
36
|
+
pd.testing.assert_frame_equal(data, original_data)
|
|
37
|
+
pd.testing.assert_frame_equal(dictionary, original_dictionary)
|
|
38
|
+
|
|
39
|
+
def test_reports_missing_dictionary_column(self):
|
|
40
|
+
data, dictionary = self.load_example("starter")
|
|
41
|
+
with self.assertRaisesRegex(ValueError, "Missing data dictionary columns: variable name"):
|
|
42
|
+
validate_dataset(data, dictionary.drop(columns="Variable Name"))
|