trustcv 1.0.0__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.
- trustcv-1.0.0/AUTHORS.md +27 -0
- trustcv-1.0.0/CONTRIBUTING.md +246 -0
- trustcv-1.0.0/LICENSE +26 -0
- trustcv-1.0.0/MANIFEST.in +30 -0
- trustcv-1.0.0/PKG-INFO +340 -0
- trustcv-1.0.0/README.md +261 -0
- trustcv-1.0.0/examples/all_cv_methods_demo.py +485 -0
- trustcv-1.0.0/examples/data_leakage_detection_demo.py +416 -0
- trustcv-1.0.0/examples/disease_spread_modeling.py +713 -0
- trustcv-1.0.0/examples/framework_agnostic_demo.py +310 -0
- trustcv-1.0.0/examples/heart_disease_classification.py +207 -0
- trustcv-1.0.0/examples/heart_disease_prediction.py +351 -0
- trustcv-1.0.0/examples/icu_patient_monitoring.py +537 -0
- trustcv-1.0.0/examples/monai_3d_imaging_cv.py +346 -0
- trustcv-1.0.0/examples/multisite_clinical_trial.py +576 -0
- trustcv-1.0.0/examples/pytorch_medical_cv.py +265 -0
- trustcv-1.0.0/examples/tensorflow_medical_cv.py +330 -0
- trustcv-1.0.0/requirements-dev.txt +16 -0
- trustcv-1.0.0/requirements-frameworks.txt +41 -0
- trustcv-1.0.0/requirements.txt +22 -0
- trustcv-1.0.0/setup.cfg +4 -0
- trustcv-1.0.0/setup.py +114 -0
- trustcv-1.0.0/tests/test_all_29_methods.py +541 -0
- trustcv-1.0.0/tests/test_cv_methods.py +294 -0
- trustcv-1.0.0/tests/test_data_leakage.py +432 -0
- trustcv-1.0.0/tests/test_framework_integration.py +613 -0
- trustcv-1.0.0/tests/test_grouped_methods.py +346 -0
- trustcv-1.0.0/tests/test_iid_methods.py +273 -0
- trustcv-1.0.0/tests/test_integration_examples.py +378 -0
- trustcv-1.0.0/tests/test_medicalvalidator_deprecation.py +12 -0
- trustcv-1.0.0/tests/test_spatial_methods.py +384 -0
- trustcv-1.0.0/tests/test_temporal_methods.py +312 -0
- trustcv-1.0.0/tests/test_temporal_param_aliases.py +61 -0
- trustcv-1.0.0/trustcv/__init__.py +300 -0
- trustcv-1.0.0/trustcv/checkers/__init__.py +12 -0
- trustcv-1.0.0/trustcv/checkers/balance.py +353 -0
- trustcv-1.0.0/trustcv/checkers/leakage.py +746 -0
- trustcv-1.0.0/trustcv/core/__init__.py +29 -0
- trustcv-1.0.0/trustcv/core/base.py +541 -0
- trustcv-1.0.0/trustcv/core/callbacks.py +485 -0
- trustcv-1.0.0/trustcv/core/runner.py +459 -0
- trustcv-1.0.0/trustcv/datasets/__init__.py +23 -0
- trustcv-1.0.0/trustcv/datasets/loaders.py +414 -0
- trustcv-1.0.0/trustcv/frameworks/__init__.py +75 -0
- trustcv-1.0.0/trustcv/frameworks/monai.py +631 -0
- trustcv-1.0.0/trustcv/frameworks/pytorch.py +564 -0
- trustcv-1.0.0/trustcv/frameworks/tensorflow.py +452 -0
- trustcv-1.0.0/trustcv/metrics/__init__.py +122 -0
- trustcv-1.0.0/trustcv/metrics/clinical.py +551 -0
- trustcv-1.0.0/trustcv/metrics/medical_metrics.py +387 -0
- trustcv-1.0.0/trustcv/reporting/__init__.py +11 -0
- trustcv-1.0.0/trustcv/reporting/regulatory_report.py +909 -0
- trustcv-1.0.0/trustcv/reporting/universal_report.py +393 -0
- trustcv-1.0.0/trustcv/splitters/__init__.py +131 -0
- trustcv-1.0.0/trustcv/splitters/grouped.py +679 -0
- trustcv-1.0.0/trustcv/splitters/iid.py +592 -0
- trustcv-1.0.0/trustcv/splitters/spatial.py +709 -0
- trustcv-1.0.0/trustcv/splitters/temporal.py +853 -0
- trustcv-1.0.0/trustcv/validators.py +1678 -0
- trustcv-1.0.0/trustcv/visualization/__init__.py +31 -0
- trustcv-1.0.0/trustcv/visualization/plots.py +521 -0
- trustcv-1.0.0/trustcv.egg-info/PKG-INFO +340 -0
- trustcv-1.0.0/trustcv.egg-info/SOURCES.txt +64 -0
- trustcv-1.0.0/trustcv.egg-info/dependency_links.txt +1 -0
- trustcv-1.0.0/trustcv.egg-info/requires.txt +53 -0
- trustcv-1.0.0/trustcv.egg-info/top_level.txt +1 -0
trustcv-1.0.0/AUTHORS.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Authors and Contributors
|
|
2
|
+
|
|
3
|
+
## Core Development Team
|
|
4
|
+
|
|
5
|
+
### Lead Developers
|
|
6
|
+
- **Farhad Abtahi**
|
|
7
|
+
- Email: farhad.abtahi@ki.se
|
|
8
|
+
|
|
9
|
+
- **Abdelamir Karbalaie**
|
|
10
|
+
- Email: abdolamir.karbalaie@ki.se
|
|
11
|
+
|
|
12
|
+
## Acknowledgments
|
|
13
|
+
|
|
14
|
+
We thank all contributors who have helped improve trustcv through:
|
|
15
|
+
- Bug reports and feature requests
|
|
16
|
+
- Documentation improvements
|
|
17
|
+
- Code contributions
|
|
18
|
+
- Testing and validation
|
|
19
|
+
- Community support
|
|
20
|
+
|
|
21
|
+
## Contributing
|
|
22
|
+
|
|
23
|
+
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details on how to get involved.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
*Last updated: August 2024*
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# Contributing to trustcv
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to trustcv! This toolkit aims to improve medical machine learning validation practices, and we welcome contributions from the community.
|
|
4
|
+
|
|
5
|
+
## 🤝 Code of Conduct
|
|
6
|
+
|
|
7
|
+
By participating in this project, you agree to abide by our [Code of Conduct](CODE_OF_CONDUCT.md). Please read it before contributing.
|
|
8
|
+
|
|
9
|
+
## 🚀 How to Contribute
|
|
10
|
+
|
|
11
|
+
### 1. Reporting Bugs
|
|
12
|
+
|
|
13
|
+
Before creating bug reports, please check existing issues to avoid duplicates.
|
|
14
|
+
|
|
15
|
+
**To report a bug:**
|
|
16
|
+
1. Use the [Bug Report](.github/ISSUE_TEMPLATE/bug_report.md) template
|
|
17
|
+
2. Include:
|
|
18
|
+
- Clear description of the bug
|
|
19
|
+
- Steps to reproduce
|
|
20
|
+
- Expected vs actual behavior
|
|
21
|
+
- System information (OS, Python version)
|
|
22
|
+
- Minimal code example
|
|
23
|
+
|
|
24
|
+
### 2. Suggesting Features
|
|
25
|
+
|
|
26
|
+
We welcome feature suggestions that align with trustcv's mission.
|
|
27
|
+
|
|
28
|
+
**To suggest a feature:**
|
|
29
|
+
1. Use the [Feature Request](.github/ISSUE_TEMPLATE/feature_request.md) template
|
|
30
|
+
2. Include:
|
|
31
|
+
- Clear use case
|
|
32
|
+
- Medical/clinical context
|
|
33
|
+
- Proposed implementation (if applicable)
|
|
34
|
+
- Alternative solutions considered
|
|
35
|
+
|
|
36
|
+
### 3. Contributing Code
|
|
37
|
+
|
|
38
|
+
#### Setup Development Environment
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Fork and clone the repository
|
|
42
|
+
git clone https://github.com/your-username/trustcv.git
|
|
43
|
+
cd trustcv
|
|
44
|
+
|
|
45
|
+
# Create virtual environment
|
|
46
|
+
python -m venv venv
|
|
47
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
48
|
+
|
|
49
|
+
# Install in development mode
|
|
50
|
+
pip install -e .[dev]
|
|
51
|
+
|
|
52
|
+
# Install pre-commit hooks
|
|
53
|
+
pre-commit install
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
#### Development Workflow
|
|
57
|
+
|
|
58
|
+
1. **Create a branch**
|
|
59
|
+
```bash
|
|
60
|
+
git checkout -b feature/your-feature-name
|
|
61
|
+
# or
|
|
62
|
+
git checkout -b fix/issue-number
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
2. **Make your changes**
|
|
66
|
+
- Follow the coding standards (see below)
|
|
67
|
+
- Add/update tests
|
|
68
|
+
- Update documentation
|
|
69
|
+
|
|
70
|
+
3. **Test your changes**
|
|
71
|
+
```bash
|
|
72
|
+
# Run tests
|
|
73
|
+
pytest tests/
|
|
74
|
+
|
|
75
|
+
# Check code style
|
|
76
|
+
flake8 trustcv/
|
|
77
|
+
black --check trustcv/
|
|
78
|
+
|
|
79
|
+
# Run type checking
|
|
80
|
+
mypy trustcv/
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
4. **Commit your changes**
|
|
84
|
+
```bash
|
|
85
|
+
git add .
|
|
86
|
+
git commit -m "feat: add new cross-validation method for spatial data"
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Follow [Conventional Commits](https://www.conventionalcommits.org/):
|
|
90
|
+
- `feat:` New feature
|
|
91
|
+
- `fix:` Bug fix
|
|
92
|
+
- `docs:` Documentation changes
|
|
93
|
+
- `test:` Test additions/changes
|
|
94
|
+
- `refactor:` Code refactoring
|
|
95
|
+
- `style:` Code style changes
|
|
96
|
+
- `perf:` Performance improvements
|
|
97
|
+
|
|
98
|
+
5. **Push and create Pull Request**
|
|
99
|
+
```bash
|
|
100
|
+
git push origin feature/your-feature-name
|
|
101
|
+
```
|
|
102
|
+
Then create a PR on GitHub.
|
|
103
|
+
|
|
104
|
+
## 📝 Coding Standards
|
|
105
|
+
|
|
106
|
+
### Python Style Guide
|
|
107
|
+
|
|
108
|
+
We follow PEP 8 with these additions:
|
|
109
|
+
- Line length: 88 characters (Black default)
|
|
110
|
+
- Use type hints for function parameters and returns
|
|
111
|
+
- Document all public functions with docstrings (NumPy style)
|
|
112
|
+
|
|
113
|
+
### Example Code Style
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
from typing import Optional, Tuple, Union
|
|
117
|
+
import numpy as np
|
|
118
|
+
import pandas as pd
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def calculate_clinical_metric(
|
|
122
|
+
y_true: np.ndarray,
|
|
123
|
+
y_pred: np.ndarray,
|
|
124
|
+
metric: str = "sensitivity",
|
|
125
|
+
confidence_level: float = 0.95
|
|
126
|
+
) -> Tuple[float, Tuple[float, float]]:
|
|
127
|
+
"""
|
|
128
|
+
Calculate clinical metric with confidence interval.
|
|
129
|
+
|
|
130
|
+
Parameters
|
|
131
|
+
----------
|
|
132
|
+
y_true : np.ndarray
|
|
133
|
+
True labels
|
|
134
|
+
y_pred : np.ndarray
|
|
135
|
+
Predicted labels
|
|
136
|
+
metric : str, default='sensitivity'
|
|
137
|
+
Metric to calculate
|
|
138
|
+
confidence_level : float, default=0.95
|
|
139
|
+
Confidence level for interval
|
|
140
|
+
|
|
141
|
+
Returns
|
|
142
|
+
-------
|
|
143
|
+
metric_value : float
|
|
144
|
+
Calculated metric value
|
|
145
|
+
confidence_interval : Tuple[float, float]
|
|
146
|
+
Lower and upper bounds of CI
|
|
147
|
+
|
|
148
|
+
Examples
|
|
149
|
+
--------
|
|
150
|
+
>>> sensitivity, (ci_lower, ci_upper) = calculate_clinical_metric(
|
|
151
|
+
... y_true, y_pred, metric="sensitivity"
|
|
152
|
+
... )
|
|
153
|
+
"""
|
|
154
|
+
# Implementation
|
|
155
|
+
pass
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Testing Requirements
|
|
159
|
+
|
|
160
|
+
- All new features must have tests
|
|
161
|
+
- Maintain test coverage above 80%
|
|
162
|
+
- Use pytest for testing
|
|
163
|
+
- Include both unit and integration tests
|
|
164
|
+
|
|
165
|
+
### Documentation
|
|
166
|
+
|
|
167
|
+
- Update docstrings for all changes
|
|
168
|
+
- Update relevant .md files in `/docs`
|
|
169
|
+
- Add examples to docstrings
|
|
170
|
+
- Update notebooks if applicable
|
|
171
|
+
|
|
172
|
+
## 🏥 Medical/Clinical Considerations
|
|
173
|
+
|
|
174
|
+
When contributing medical-specific features:
|
|
175
|
+
|
|
176
|
+
1. **Cite sources**: Include references to medical literature
|
|
177
|
+
2. **Clinical validation**: Explain clinical relevance
|
|
178
|
+
3. **Safety checks**: Consider patient safety implications
|
|
179
|
+
4. **Regulatory aspects**: Note any FDA/CE considerations
|
|
180
|
+
5. **Privacy**: Ensure no PHI in examples
|
|
181
|
+
|
|
182
|
+
## 📚 Areas We Need Help
|
|
183
|
+
|
|
184
|
+
### High Priority
|
|
185
|
+
- [ ] Additional CV methods from literature
|
|
186
|
+
- [ ] Integration with medical imaging libraries
|
|
187
|
+
- [ ] Real-world clinical case studies
|
|
188
|
+
- [ ] Performance optimization
|
|
189
|
+
- [ ] More comprehensive tests
|
|
190
|
+
|
|
191
|
+
### Documentation
|
|
192
|
+
- [ ] Video tutorials
|
|
193
|
+
- [ ] Clinical use case examples
|
|
194
|
+
- [ ] Translation to other languages
|
|
195
|
+
- [ ] API documentation improvements
|
|
196
|
+
|
|
197
|
+
### Research
|
|
198
|
+
- [ ] Implementing new CV methods from recent papers
|
|
199
|
+
- [ ] Benchmarking against other libraries
|
|
200
|
+
- [ ] Clinical validation studies
|
|
201
|
+
|
|
202
|
+
## 🔄 Pull Request Process
|
|
203
|
+
|
|
204
|
+
1. **PR Title**: Use conventional commit format
|
|
205
|
+
2. **Description**: Use the PR template
|
|
206
|
+
3. **Tests**: Ensure all tests pass
|
|
207
|
+
4. **Documentation**: Update if needed
|
|
208
|
+
5. **Review**: Address reviewer feedback
|
|
209
|
+
6. **Squash**: We squash commits on merge
|
|
210
|
+
|
|
211
|
+
### PR Checklist
|
|
212
|
+
- [ ] Tests pass locally
|
|
213
|
+
- [ ] Code follows style guidelines
|
|
214
|
+
- [ ] Documentation updated
|
|
215
|
+
- [ ] Changelog entry added (if applicable)
|
|
216
|
+
- [ ] No sensitive medical data included
|
|
217
|
+
|
|
218
|
+
## 📦 Release Process
|
|
219
|
+
|
|
220
|
+
We use semantic versioning (MAJOR.MINOR.PATCH):
|
|
221
|
+
- MAJOR: Breaking changes
|
|
222
|
+
- MINOR: New features (backward compatible)
|
|
223
|
+
- PATCH: Bug fixes
|
|
224
|
+
|
|
225
|
+
Releases are automated via GitHub Actions when tags are pushed.
|
|
226
|
+
|
|
227
|
+
## 💬 Getting Help
|
|
228
|
+
|
|
229
|
+
- **Discord**: [Join our community](https://discord.gg/medicalcv)
|
|
230
|
+
- **Discussions**: Use GitHub Discussions for questions
|
|
231
|
+
- **Email**: medicalcv@example.com
|
|
232
|
+
|
|
233
|
+
## 🙏 Recognition
|
|
234
|
+
|
|
235
|
+
Contributors are recognized in:
|
|
236
|
+
- [AUTHORS.md](AUTHORS.md) file
|
|
237
|
+
- Release notes
|
|
238
|
+
- Project documentation
|
|
239
|
+
|
|
240
|
+
## 📄 License
|
|
241
|
+
|
|
242
|
+
By contributing, you agree that your contributions will be licensed under the MIT License.
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
Thank you for helping make medical machine learning more reliable! 🏥🤖
|
trustcv-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 trustcv 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.
|
|
22
|
+
|
|
23
|
+
MEDICAL DISCLAIMER:
|
|
24
|
+
This software is for research and educational purposes only. It is not intended
|
|
25
|
+
for clinical use or medical diagnosis. Always consult with qualified healthcare
|
|
26
|
+
professionals and validate any models thoroughly before clinical deployment.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Include documentation
|
|
2
|
+
include README.md
|
|
3
|
+
include LICENSE
|
|
4
|
+
include CONTRIBUTING.md
|
|
5
|
+
include AUTHORS.md
|
|
6
|
+
include requirements.txt
|
|
7
|
+
include requirements-dev.txt
|
|
8
|
+
include requirements-frameworks.txt
|
|
9
|
+
|
|
10
|
+
# Include all package data
|
|
11
|
+
recursive-include trustcv *.py
|
|
12
|
+
|
|
13
|
+
# Include example scripts
|
|
14
|
+
recursive-include examples *.py
|
|
15
|
+
|
|
16
|
+
# Include test files
|
|
17
|
+
recursive-include tests *.py
|
|
18
|
+
|
|
19
|
+
# Exclude unnecessary files
|
|
20
|
+
global-exclude *.pyc
|
|
21
|
+
global-exclude __pycache__
|
|
22
|
+
global-exclude .DS_Store
|
|
23
|
+
global-exclude *.swp
|
|
24
|
+
global-exclude *~
|
|
25
|
+
|
|
26
|
+
# Exclude development files
|
|
27
|
+
exclude .gitignore
|
|
28
|
+
exclude .git
|
|
29
|
+
exclude pyproject.toml
|
|
30
|
+
exclude PYPI_DEPLOYMENT_GUIDE.md
|
trustcv-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: trustcv
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Trustworthy Cross-Validation: Framework-agnostic CV with data leakage detection
|
|
5
|
+
Home-page: https://github.com/ki-smile/trustcv
|
|
6
|
+
Author: SMAILE Team, Karolinska Institutet
|
|
7
|
+
Author-email: "SMAILE Team, Karolinska Institutet" <contact@smile.ki.se>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/ki-smile/trustcv
|
|
10
|
+
Project-URL: Documentation, https://ki-smile.github.io/trustcv
|
|
11
|
+
Project-URL: Repository, https://github.com/ki-smile/trustcv
|
|
12
|
+
Project-URL: Bug Tracker, https://github.com/ki-smile/trustcv/issues
|
|
13
|
+
Keywords: cross-validation,medical,machine-learning,healthcare,validation
|
|
14
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
15
|
+
Classifier: Intended Audience :: Healthcare Industry
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
25
|
+
Requires-Python: >=3.8
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
License-File: AUTHORS.md
|
|
29
|
+
Requires-Dist: numpy>=1.20.0
|
|
30
|
+
Requires-Dist: pandas>=1.3.0
|
|
31
|
+
Requires-Dist: scikit-learn>=1.0.0
|
|
32
|
+
Requires-Dist: scipy>=1.7.0
|
|
33
|
+
Requires-Dist: matplotlib>=3.4.0
|
|
34
|
+
Requires-Dist: seaborn>=0.11.0
|
|
35
|
+
Requires-Dist: plotly>=5.0.0
|
|
36
|
+
Requires-Dist: joblib>=1.0.0
|
|
37
|
+
Requires-Dist: tqdm>=4.60.0
|
|
38
|
+
Provides-Extra: dev
|
|
39
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
40
|
+
Requires-Dist: pytest-cov>=3.0.0; extra == "dev"
|
|
41
|
+
Requires-Dist: flake8>=4.0.0; extra == "dev"
|
|
42
|
+
Requires-Dist: mypy>=0.950; extra == "dev"
|
|
43
|
+
Requires-Dist: black>=22.0.0; extra == "dev"
|
|
44
|
+
Requires-Dist: isort>=5.10.0; extra == "dev"
|
|
45
|
+
Requires-Dist: bandit>=1.7.0; extra == "dev"
|
|
46
|
+
Provides-Extra: docs
|
|
47
|
+
Requires-Dist: sphinx>=4.5.0; extra == "docs"
|
|
48
|
+
Requires-Dist: sphinx-rtd-theme>=1.0.0; extra == "docs"
|
|
49
|
+
Requires-Dist: sphinx-autodoc-typehints>=1.12.0; extra == "docs"
|
|
50
|
+
Requires-Dist: myst-parser>=0.18.0; extra == "docs"
|
|
51
|
+
Requires-Dist: nbsphinx>=0.9.0; extra == "docs"
|
|
52
|
+
Provides-Extra: viz
|
|
53
|
+
Requires-Dist: bokeh>=2.4.0; extra == "viz"
|
|
54
|
+
Provides-Extra: pytorch
|
|
55
|
+
Requires-Dist: torch; extra == "pytorch"
|
|
56
|
+
Requires-Dist: torchvision; extra == "pytorch"
|
|
57
|
+
Provides-Extra: tensorflow
|
|
58
|
+
Requires-Dist: tensorflow>=2.16; extra == "tensorflow"
|
|
59
|
+
Provides-Extra: monai
|
|
60
|
+
Requires-Dist: monai>=1.0.0; extra == "monai"
|
|
61
|
+
Requires-Dist: nibabel>=3.2.0; extra == "monai"
|
|
62
|
+
Provides-Extra: all
|
|
63
|
+
Requires-Dist: torch; extra == "all"
|
|
64
|
+
Requires-Dist: torchvision; extra == "all"
|
|
65
|
+
Requires-Dist: tensorflow>=2.16; extra == "all"
|
|
66
|
+
Requires-Dist: monai>=1.0.0; extra == "all"
|
|
67
|
+
Requires-Dist: nibabel>=3.2.0; extra == "all"
|
|
68
|
+
Requires-Dist: pytest>=7.0.0; extra == "all"
|
|
69
|
+
Requires-Dist: flake8>=4.0.0; extra == "all"
|
|
70
|
+
Requires-Dist: mypy>=0.950; extra == "all"
|
|
71
|
+
Requires-Dist: black>=22.0.0; extra == "all"
|
|
72
|
+
Requires-Dist: sphinx>=4.5.0; extra == "all"
|
|
73
|
+
Requires-Dist: nbsphinx>=0.9.0; extra == "all"
|
|
74
|
+
Requires-Dist: pytest-cov>=3.0.0; extra == "all"
|
|
75
|
+
Dynamic: author
|
|
76
|
+
Dynamic: home-page
|
|
77
|
+
Dynamic: license-file
|
|
78
|
+
Dynamic: requires-python
|
|
79
|
+
|
|
80
|
+
# trustcv — Trustworthy Cross-Validation Toolkit
|
|
81
|
+
|
|
82
|
+
[](https://opensource.org/licenses/MIT)
|
|
83
|
+
[](https://www.python.org/downloads/)
|
|
84
|
+
[](https://github.com/ki-smile/trustcv)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
**TrustCV** is a framework-agnostic toolkit for **reliable cross-validation** in safety-critical and regulated settings.
|
|
89
|
+
It builds on familiar scikit-learn idioms, but adds:
|
|
90
|
+
|
|
91
|
+
- Carefully designed cross-validation splitters (starting with IID in v0.1).
|
|
92
|
+
- Automatic **data leakage** and **class balance** checks.
|
|
93
|
+
- **Clinical/industrial metrics** with confidence intervals.
|
|
94
|
+
- Simple, **regulatory-ready reporting**.
|
|
95
|
+
|
|
96
|
+
> **Status:** v1.0.0 – Production release with 29 CV methods across IID, Grouped, Temporal, and Spatial categories. Full data leakage detection and regulatory compliance features.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Why TrustCV?
|
|
101
|
+
|
|
102
|
+
Standard cross-validation is easy to misuse:
|
|
103
|
+
|
|
104
|
+
- Train/test splits can accidentally **leak information** (e.g., shared patients, timestamps, engineered features).
|
|
105
|
+
- Imbalanced datasets can give **overly optimistic** metrics if not stratified or monitored.
|
|
106
|
+
- For clinical and industrial applications, we often need **meaningful metrics** and reproducible reports, not just accuracy.
|
|
107
|
+
|
|
108
|
+
TrustCV addresses these issues by:
|
|
109
|
+
|
|
110
|
+
- Providing **well-tested IID splitters** with clear semantics.
|
|
111
|
+
- Running **leakage and balance checks** alongside your CV.
|
|
112
|
+
- Exposing **clinical metrics** and simple **reporting utilities** for audits and regulatory files.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## What's in v1.0.0
|
|
117
|
+
|
|
118
|
+
This release includes **29 cross-validation methods** across four categories:
|
|
119
|
+
|
|
120
|
+
- **IID splitters** (9 methods):
|
|
121
|
+
`HoldOut`, `KFold`, `StratifiedKFold`, `RepeatedKFold`, `LeaveOneOut`, `LeavePOut`, `BootstrapValidation`, `MonteCarloCV`, `NestedCV`
|
|
122
|
+
|
|
123
|
+
- **Grouped splitters** (6 methods):
|
|
124
|
+
`GroupKFold`, `StratifiedGroupKFold`, `LeaveOneGroupOut`, `RepeatedGroupKFold`, `NestedGroupedCV`, `HierarchicalGroupKFold`
|
|
125
|
+
|
|
126
|
+
- **Temporal splitters** (8 methods):
|
|
127
|
+
`TimeSeriesSplit`, `BlockedTimeSeriesSplit`, `RollingWindowCV`, `ExpandingWindowCV`, `PurgedKFold`, `CombinatorialPurgedKFold`, `PurgedGroupTimeSeriesSplit`, `NestedTemporalCV`
|
|
128
|
+
|
|
129
|
+
- **Spatial splitters** (4 methods):
|
|
130
|
+
`SpatialBlockCV`, `BufferedSpatialCV`, `SpatiotemporalBlockCV`, `EnvironmentalHealthCV`
|
|
131
|
+
|
|
132
|
+
- **Framework-agnostic runner**:
|
|
133
|
+
`UniversalCVRunner` + `CVResults` for consistent, reusable CV loops across scikit-learn, PyTorch, TensorFlow, MONAI, and JAX.
|
|
134
|
+
|
|
135
|
+
- **High-level validator**:
|
|
136
|
+
`TrustCVValidator` with automatic method selection and leakage detection.
|
|
137
|
+
|
|
138
|
+
- **Data integrity checks**:
|
|
139
|
+
`DataLeakageChecker` (6 leakage types), `BalanceChecker`, and `LeakageReport`.
|
|
140
|
+
|
|
141
|
+
- **Clinical/medical metrics**:
|
|
142
|
+
`ClinicalMetrics` with confidence intervals (sensitivity, specificity, PPV/NPV, etc.).
|
|
143
|
+
|
|
144
|
+
- **Regulatory reporting**:
|
|
145
|
+
`RegulatoryReport` for FDA/CE MDR compliance documentation.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
## Quick Start
|
|
151
|
+
|
|
152
|
+
### Installation
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# Install from source (recommended for latest features)
|
|
156
|
+
git clone https://github.com/ki-smile/trustcv.git
|
|
157
|
+
cd trustcv
|
|
158
|
+
pip install -e .
|
|
159
|
+
|
|
160
|
+
# Or install from PyPI (when released)
|
|
161
|
+
pip install trustcv
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
## Quickstart – IID CV with TrustCV
|
|
166
|
+
|
|
167
|
+
Here is a minimal example using `StratifiedKFold` and `UniversalCVRunner`:
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
from trustcv import TrustCVValidator
|
|
172
|
+
from sklearn.datasets import load_breast_cancer
|
|
173
|
+
from sklearn.ensemble import RandomForestClassifier
|
|
174
|
+
from sklearn.pipeline import make_pipeline
|
|
175
|
+
from sklearn.preprocessing import StandardScaler
|
|
176
|
+
|
|
177
|
+
X, y = load_breast_cancer(return_X_y=True)
|
|
178
|
+
model = make_pipeline(StandardScaler(), RandomForestClassifier(random_state=42))
|
|
179
|
+
|
|
180
|
+
# Validates with leakage checks and computes clinical CIs
|
|
181
|
+
validator = TrustCVValidator(
|
|
182
|
+
method="StratifiedKfold", # IID, stratified
|
|
183
|
+
n_splits=5,
|
|
184
|
+
random_state=42,
|
|
185
|
+
check_leakage=True,
|
|
186
|
+
check_balance=True,
|
|
187
|
+
)
|
|
188
|
+
results = validator.validate(model=model, X=X, y=y)
|
|
189
|
+
|
|
190
|
+
print(results.summary())
|
|
191
|
+
|
|
192
|
+
# Output:
|
|
193
|
+
#=== Trustworthy Cross-Validation Results ===
|
|
194
|
+
|
|
195
|
+
#Performance Metrics (mean +/- std) (method: bootstrap):
|
|
196
|
+
# accuracy: 0.956 +/- 0.014 [95% CI (bootstrap): 0.946-0.967]
|
|
197
|
+
# roc_auc: 0.989 +/- 0.009 [95% CI (bootstrap): 0.981-0.995]
|
|
198
|
+
# sensitivity: 0.966 +/- 0.030 [95% CI (bootstrap): 0.939-0.986]
|
|
199
|
+
# specificity: 0.939 +/- 0.056 [95% CI (bootstrap): 0.893-0.981]
|
|
200
|
+
# precision: 0.965 +/- 0.031 [95% CI (bootstrap): 0.937-0.989]
|
|
201
|
+
# recall: 0.966 +/- 0.030 [95% CI (bootstrap): 0.939-0.986]
|
|
202
|
+
# f1: 0.965 +/- 0.011 [95% CI (bootstrap): 0.957-0.973]
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
#Data Integrity Checks:
|
|
206
|
+
# Leakage Check: PASSED
|
|
207
|
+
# Class Balance: PASSED
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
For a higher-level workflow with leakage and balance checks, see the
|
|
211
|
+
[Quickstart: IID CV with TrustCV](https://github.com/ki-smile/trustcv/blob/main/docs/Quickstart%3A%20IID%20Cross-Validation%20with%20TrustCV.md) and [IID Splitters](https://github.com/ki-smile/trustcv/blob/main/docs/iid_splitters.md) tutorial.
|
|
212
|
+
|
|
213
|
+
### Run the example notebooks
|
|
214
|
+
|
|
215
|
+
Prefer to learn by running code? From the repo root, open the notebooks in `notebooks/`:
|
|
216
|
+
|
|
217
|
+
- `notebooks/01_IID_Methods_Showcase.ipynb` – quick tour of the IID splitters and metrics.
|
|
218
|
+
- `notebooks/02_Advanced_Workflow_UniversalRunner.ipynb` – end-to-end UniversalCVRunner workflow.
|
|
219
|
+
- `notebooks/03_TrustCVValidator_Showcase.ipynb` – TrustCVValidator examples with leakage/balance checks.
|
|
220
|
+
- `notebooks/04_TrustCVValidator_IID_Comparison.ipynb` – side-by-side IID method comparison.
|
|
221
|
+
- `notebooks/05_CrossValidation_Comparison.ipynb` – comprehensive CV methods comparison.
|
|
222
|
+
- Reports generated by the notebooks are saved in `notebooks/reports/` (HTML/PDF).
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
------
|
|
227
|
+
|
|
228
|
+
## How TrustCV relates to scikit-learn
|
|
229
|
+
|
|
230
|
+
**Similarities:**
|
|
231
|
+
|
|
232
|
+
- Uses familiar scikit-learn idioms: estimators with `fit`/`predict`, splitter objects with `split(X, y)`.
|
|
233
|
+
- Works seamlessly with scikit-learn models, pipelines, and metrics.
|
|
234
|
+
- IID splitters follow scikit-learn semantics (e.g., `KFold`, `StratifiedKFold`).
|
|
235
|
+
|
|
236
|
+
**Added value:**
|
|
237
|
+
|
|
238
|
+
- **Leakage and balance checks**: `DataLeakageChecker` and `BalanceChecker` run alongside your CV.
|
|
239
|
+
- **Clinical metrics**: `ClinicalMetrics` computes sensitivity, specificity, PPV/NPV, ROC/PR metrics, and CIs.
|
|
240
|
+
- **Structured results**: `CVResults` and `ValidationResult` standardize fold-level outputs.
|
|
241
|
+
- **Reporting**: `UniversalRegulatoryReport` turns your evaluation into a reproducible HTML/JSON report.
|
|
242
|
+
|
|
243
|
+
------
|
|
244
|
+
|
|
245
|
+
## Roadmap
|
|
246
|
+
|
|
247
|
+
TrustCV v1.0.0 includes all 29 CV methods. Future versions will focus on:
|
|
248
|
+
|
|
249
|
+
- **v1.1 – Enhanced reporting**
|
|
250
|
+
Extended regulatory report templates and audit trail features.
|
|
251
|
+
- **v1.2 – Additional frameworks**
|
|
252
|
+
Expanded support for JAX/Flax, XGBoost, LightGBM, and CatBoost.
|
|
253
|
+
- **v1.3 – AutoML integration**
|
|
254
|
+
Integration with Optuna for hyperparameter tuning within nested CV.
|
|
255
|
+
|
|
256
|
+
------
|
|
257
|
+
|
|
258
|
+
## Contributors
|
|
259
|
+
|
|
260
|
+
See [AUTHORS.md](https://github.com/ki-smile/trustcv/blob/main/AUTHORS.md) for a full list of contributors and acknowledgments.
|
|
261
|
+
|
|
262
|
+
### Lead Contributors
|
|
263
|
+
- **[Farhad Abtahi](https://github.com/farhad-abtahi)**
|
|
264
|
+
- **[Abdelamir Karbalaie](https://github.com/abdkar)**
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
### Contributing
|
|
271
|
+
We welcome contributions!
|
|
272
|
+
- Code contributions
|
|
273
|
+
- Medical use case examples
|
|
274
|
+
- Documentation improvements
|
|
275
|
+
- Bug reports and feature requests
|
|
276
|
+
|
|
277
|
+
Please see:
|
|
278
|
+
|
|
279
|
+
- [`CONTRIBUTING.md`](https://github.com/ki-smile/trustcv/blob/main/CONTRIBUTING.md)
|
|
280
|
+
- [`CODE_OF_CONDUCT.md`](https://github.com/ki-smile/trustcv/blob/main/CODE_OF_CONDUCT.md)
|
|
281
|
+
|
|
282
|
+
------
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
## 3. Quickstart: IID CV with TrustCV – outline
|
|
287
|
+
|
|
288
|
+
**See file:** `docs/quickstart_iid.md`
|
|
289
|
+
(and a matching notebook: `notebooks/Quickstart_IID_TrustCV.ipynb`)
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
## Repository Structure
|
|
293
|
+
|
|
294
|
+
```
|
|
295
|
+
trustcv/ # Python package (splitters, validators, metrics, core)
|
|
296
|
+
docs/ # Documentation & guides
|
|
297
|
+
notebooks/ # Jupyter tutorials
|
|
298
|
+
examples/ # Real-world examples
|
|
299
|
+
tests/ # Unit & integration tests
|
|
300
|
+
website/ # Static site and visualizations
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## Development
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
pip install -e .[dev]
|
|
307
|
+
pytest tests/
|
|
308
|
+
cd docs && make html
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## Citation
|
|
312
|
+
|
|
313
|
+
If you use trustcv in your research, please cite:
|
|
314
|
+
|
|
315
|
+
```bibtex
|
|
316
|
+
@software{trustcv2025,
|
|
317
|
+
title = {trustcv: Trustworthy Cross-Validation Toolkit},
|
|
318
|
+
author = {Abtahi, Farhad and Karbalaie, Abdolamir},
|
|
319
|
+
year = {2025},
|
|
320
|
+
url = {https://github.com/ki-smile/trustcv}
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## License
|
|
325
|
+
|
|
326
|
+
MIT License — see [LICENSE](LICENSE).
|
|
327
|
+
|
|
328
|
+
## Contact & Support
|
|
329
|
+
|
|
330
|
+
- GitHub Issues: https://github.com/ki-smile/trustcv/issues
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## ⚠️ Disclaimer
|
|
335
|
+
|
|
336
|
+
This toolkit is for research and educational purposes. Always validate results with domain experts before clinical deployment.
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
Advancing Medical AI Through Rigorous Validation
|