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. The examples below come from that demo and use its paths: it reads CLIF tables from data-raw/demo and writes processed data to processed/demo.

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:

  • Collation: pulling raw tables into a single denormalized, MEDS-like table of events, and splitting the subjects into train, tuning, and held-out sets, with cocoa collate.
  • Tokenization: turning each subject's events into a sequence of integer tokens, with a vocabulary and quantile bins learned on the training split, with cocoa tokenize.
  • Winnowing: cutting timelines into a past and a future at a threshold and flagging the outcome tokens on each side, for evaluation, with cocoa winnow.
  • Visualization: drawing a subject's tokenized timeline, or the learned vocabulary, as an interactive page, with cocoa visualize.
  • Combining datasets: merging processed directories into one with cocoa combine-datasets.
  • 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.1

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.1
File Size Uploaded Provenance Actions
cocoa_tokenizer-26.11.1.tar.gz 338.4 kB With provenance Details for cocoa_tokenizer-26.11.1.tar.gz

Built distribution (wheel)

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

Total release size: 539.1 kB

Release files / cocoa_tokenizer-26.11.1.tar.gz

Download URL cocoa_tokenizer-26.11.1.tar.gz
Size 338.4 kB
Tags Source
SHA-256 checksum
How to use checksums
695e96cfb413ed8fdf300e40e8f6ba90ba9ed95169c2ab7b4cf64d6a14acbb5a
BLAKE2b-256 checksum
How to use checksums
c7c844180ef569785b386e27d18c74d2b90f01d5a2291f7ac5665a9f035ba1cc
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 11, 2026.

Transparency log

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

Download URL cocoa_tokenizer-26.11.1-py3-none-any.whl
Size 200.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e0b32905727d387f693b7aa0bdb28f28d8d77adc3dd43dfb26febb84ba992303
BLAKE2b-256 checksum
How to use checksums
dae6c91a5afaabb9d426093fd415e351efef0f02a99aee695e584a2e14a97bdf
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 11, 2026.

Transparency log

Security for cocoa-tokenizer 26.11.1

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.1.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 11, 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