MEDS Random Task Sampler
Model-independent generation of query-based task rows from MEDS datasets.
The package provides two separate workflows:
random_sample: random(code, duration)specifications paired with random patient contexts; anddense_grid: explicitcode x durationgrids at sampled patient prediction times.
These names describe how rows are sampled, not how a downstream model must use them. For example, either output could be used for training, validation, benchmarking, probing, or analysis.
Both workflows follow
payalchandak/EveryQuery@9bd85a1.
The package owns the shared task schema, code-source resolution, future-occurrence labeling, death and censoring
semantics, deterministic seeds, and atomic output writes. It does not depend on Hydra or a model framework.
Random task samples
from meds_random_task_sampler import RandomTaskSamplerConfig, sample_random_tasks
config = RandomTaskSamplerConfig(
num_queries=1024,
num_contexts_per_query=1,
min_prediction_times_per_subject=50,
query_codes="/path/to/MEDS", # resolves metadata/codes.parquet
min_duration=1,
max_duration=731,
duration_distribution="log-uniform",
)
result = sample_random_tasks(
data_dir="/path/to/MEDS",
output_dir="/path/to/random_tasks",
split="train",
config=config,
)
Output is partitioned under random_tasks/{split}/*.parquet; restartable intermediate artifacts use the sibling
random_tasks_artifacts/{split}/ directory. Machine-readable summary statistics are written to
random_tasks_artifacts/{split}/_summary.json.
Dense task grids
from meds_random_task_sampler import (
TaskGridGeneratorConfig,
generate_task_grid,
)
config = TaskGridGeneratorConfig(
prediction_times_per_subject=1,
min_context_per_subject=50,
query_codes=["CODE_A", "CODE_B"],
durations=[30, 90, 180, 365, 731],
write_unique_prediction_times=True,
censored_rows="keep", # or "drop" for current EveryQuery evaluation behavior
)
result = generate_task_grid(
data_dir="/path/to/MEDS",
output_dir="/path/to/task_grid",
split="held_out",
input_shard="0",
config=config,
)
Grid rows are written to task_grid/{split}/{shard}.parquet. Optional unique prediction times use the sibling
task_grid_unique/ root and per-shard summaries use task_grid_summary/. Nullable/censored labels are retained
by default; use censored_rows="drop" to reproduce current EveryQuery evaluation output.
See DESIGN.md for the behavioral contract and planned EveryQuery adapter boundary.
Development
uv sync --group dev
uv run pytest -v
uv run pre-commit run --all-files
This repository retains the
McDermottHealthAI/MHAL-template project structure.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file meds_random_task_sampler-0.1.0.tar.gz.
File metadata
- Download URL: meds_random_task_sampler-0.1.0.tar.gz
- Upload date:
- Size: 132.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
598e269d8a201879c11db185fb4ec3cb9f922b4f4faa02dd4e7ce139533c7865
|
|
| MD5 |
ea33bb0dc4e50dc85cdde103663ebd5c
|
|
| BLAKE2b-256 |
b18df05de0843d180a575c6c6a6015ae5043bbc0e270da0e71d6530d638a5148
|
Provenance
The following attestation bundles were made for meds_random_task_sampler-0.1.0.tar.gz:
Publisher:
python-build.yaml on florian6973/meds-random-task-sampler
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
meds_random_task_sampler-0.1.0.tar.gz -
Subject digest:
598e269d8a201879c11db185fb4ec3cb9f922b4f4faa02dd4e7ce139533c7865 - Sigstore transparency entry: 2226452279
- Sigstore integration time:
-
Permalink:
florian6973/meds-random-task-sampler@9b1fee8e22239116d6a5d4add2b8ac8c8cb07f0c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/florian6973
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-build.yaml@9b1fee8e22239116d6a5d4add2b8ac8c8cb07f0c -
Trigger Event:
push
-
Statement type:
File details
Details for the file meds_random_task_sampler-0.1.0-py3-none-any.whl.
File metadata
- Download URL: meds_random_task_sampler-0.1.0-py3-none-any.whl
- Upload date:
- Size: 39.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1d64d519ca30a5bd383f2dbefe7551289b496470256801a8f430179b992e699
|
|
| MD5 |
156672207e37183506cca41d32b40cce
|
|
| BLAKE2b-256 |
5ada1b28bd1b375d46354733fe8a70272807e05b46391ce7da898dcb9f989676
|
Provenance
The following attestation bundles were made for meds_random_task_sampler-0.1.0-py3-none-any.whl:
Publisher:
python-build.yaml on florian6973/meds-random-task-sampler
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
meds_random_task_sampler-0.1.0-py3-none-any.whl -
Subject digest:
d1d64d519ca30a5bd383f2dbefe7551289b496470256801a8f430179b992e699 - Sigstore transparency entry: 2226452623
- Sigstore integration time:
-
Permalink:
florian6973/meds-random-task-sampler@9b1fee8e22239116d6a5d4add2b8ac8c8cb07f0c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/florian6973
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-build.yaml@9b1fee8e22239116d6a5d4add2b8ac8c8cb07f0c -
Trigger Event:
push
-
Statement type: