Skip to main content

cocoa bean

Cocoa: a configurable collator

PyPI Version DOI SWH tests codecov

☕️ Chicago's second favorite bean

About

This library provides a configurable way to (1) collate data from multiple sources into a single denormalized dataframe, (2) tokenize the records into sequences of discrete integers, (3) winnow the records in preparation for downstream inference tasks, and (4) visualize both individual records and the tokenization process. It benefits from previous experience preparing data for training foundation models on tokenized electronic health records. 1 2 3 4 5

Installation

Install the latest release from PyPI:

pip install cocoa-tokenizer

This installs the cocoa command. To see it run end to end on public data, follow the MIMIC-IV demo, which installs cocoa with its demo extra (on Python 3.11 to 3.14):

pip install 'cocoa-tokenizer[demo]'

The extra brings clifpy, the CLIF consortium's Python package, which ships the demo as CLIF tables, and cocoa get-demo writes them out.

Usage

Each stage of the pipeline is a cocoa command, driven by a YAML config, and cocoa pipeline runs the first three in turn:

collate  →  tokenize  →  winnow
                      ↘  visualize

The documentation covers:

  • cocoa collate: pulls raw tables into a single denormalized, MEDS-like table of events, and splits the subjects into train, tuning, and held-out sets.
  • cocoa tokenize: turns each subject's events into a sequence of integer tokens, with a vocabulary and quantile bins learned on the training split.
  • cocoa winnow: cuts timelines into a past and a future at a threshold and flags the outcome tokens on each side, for evaluation.
  • cocoa visualize: draws a subject's tokenized timeline, or the learned vocabulary, as an interactive page.
  • cocoa combine-datasets: merges processed directories into one.
  • Configuration: the YAML config each stage reads, and how to change its keys on the command line.
  • The CLI reference, with every command's options, and the recipes, worked examples from a run on public data to tokenizer transfer.

Contributing

Contributions are welcome, from bug reports and typo fixes to new features. To get started, see the contributing guide.

Next steps

For training models and running inference on this data, check out cotorra.

  1. M. Burkhart, B. Ramadan, Z. Liao, K. Chhikara, J. Rojas, W. Parker, & B. Beaulieu-Jones, Foundation models for electronic health records: representation dynamics and transferability, arXiv:2504.10422 ↩

  2. M. Burkhart, B. Ramadan, L. Solo, W. Parker, & B. Beaulieu-Jones, Quantifying surprise in clinical care: Detecting highly informative events in electronic health records with foundation models, Pacific Symposium on Biocomputing 31 (2026), 173–188 ↩

  3. L. Solo, M. McDermott, W. Parker, B. Ramadan, M. Burkhart, & B. Beaulieu-Jones, Efficient generative prediction for EHR foundation models: the SCOPE and REACH estimators, arXiv:2602.03730 ↩

  4. I. Lee, L. Solo, M. Burkhart, B. Ramadan, W. Parker, & B. Beaulieu-Jones, Representation before training: a fixed-budget benchmark for generative medical event models, arXiv:2604.16775, to appear in ML4H 2026 ↩

  5. M. Burkhart, L. Solo, I. Lee, S. Charles, Z. Liao, K. Chhikara, D. Therese, W.-T. Liao, C. Gao, W. Parker, & B. Beaulieu-Jones, Federated generative event models for tokenized electronic health records, arXiv:2608.02939 ↩

Metadata

Release files for cocoa-tokenizer 26.11.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cocoa-tokenizer 26.11.2
File Size Uploaded Provenance Actions
cocoa_tokenizer-26.11.2.tar.gz 339.2 kB With provenance Details for cocoa_tokenizer-26.11.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cocoa-tokenizer 26.11.2
File Interpreter ABI Platform Actions
cocoa_tokenizer-26.11.2-py3-none-any.whl Python 3 none any Details for cocoa_tokenizer-26.11.2-py3-none-any.whl

Total release size: 540.0 kB

Release files / cocoa_tokenizer-26.11.2.tar.gz

Download URL cocoa_tokenizer-26.11.2.tar.gz
Size 339.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3226f86fbf7fdc39dea6fb086522e94129f468748aa49d1a1825d16868f8d406
BLAKE2b-256 checksum
How to use checksums
91b3a07d394c7f3e5acc854195879a06eff9b2f29d5f34160365c5a2eaf44f87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / cocoa_tokenizer-26.11.2-py3-none-any.whl

Download URL cocoa_tokenizer-26.11.2-py3-none-any.whl
Size 200.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50d2be70c67490c0efc71d66fb61c212767f86c3e50261aa9140b78a2147dc78
BLAKE2b-256 checksum
How to use checksums
e476cf636790a2f5880f1b38d7cc9535c835d62f4f7bb637dcb3651551e502b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for cocoa-tokenizer 26.11.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cocoa_tokenizer-26.11.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page