PromptEHR
Wang, Zifeng and Sun, Jimeng. (2022). PromptEHR: Conditional Electronic Healthcare Records Generation with Prompt Learning. EMNLP'22.
News
- [2023/01/08]
PromptEHRis now integrated intoPyTrialwith a complete documentation and example, please check! New version with bugs fixed is also released!
Usage
Get pretrained PromptEHR model (learned on MIMIC-III sequence EHRs) in three lines:
from promptehr import PromptEHR
model = PromptEHR()
model.from_pretrained()
A jupyter example is available at https://github.com/RyanWangZf/PromptEHR/blob/main/example/demo_promptehr.ipynb.
How to install
Install the correct PyTorch version by referring to https://pytorch.org/get-started/locally/.
Then try to install PromptEHR by
pip install git+https://github.com/RyanWangZf/PromptEHR.git
or
pip install promptehr
Load demo synthetic EHRs (generated by PromptEHR)
from promptehr import load_synthetic_data
data = load_synthetic_data()
Use PromptEHR for generation
from promptehr import SequencePatient
from promptehr import load_synthetic_data
from promptehr import PromptEHR
# init model
model = PromptEHR()
model.from_pretrained()
# load input data
demo = load_synthetic_data(n_sample=1000) # we have 10,000 samples in total
# build the standard input data for train or test PromptEHR models
seqdata = SequencePatient(data={'v':demo['visit'], 'y':demo['y'], 'x':demo['feature'],},
metadata={
'visit':{'mode':'dense'},
'label':{'mode':'tensor'},
'voc':demo['voc'],
'max_visit':20,
}
)
# you can try to fit on this data by
# model.fit(seqdata)
# start generate
# n: the target total number of samples to generate
# n_per_sample: based on each sample, how many fake samples will be generated
# the output will have the same format of `SequencePatient`
fake_data = model.predict(seqdata, n=1000, n_per_sample=10)
Metadata
Release files for PromptEHR 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| PromptEHR-0.0.6.tar.gz | 230.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| PromptEHR-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 543.0 kB
Release files / PromptEHR-0.0.6.tar.gz
| Download URL | PromptEHR-0.0.6.tar.gz |
|---|---|
| Size | 230.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
31638dbdf274b35a37b8930cc47619b6467ef689cd9205204a04b01c83f20fe6
|
|
BLAKE2b-256 checksum How to use checksums |
adbb9aadbcb822c0d5c358c49b9d4486639821bb389c8ac43f30eb2260611dca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / PromptEHR-0.0.6-py3-none-any.whl
| Download URL | PromptEHR-0.0.6-py3-none-any.whl |
|---|---|
| Size | 312.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a2eae33478b51b3a84ad8b9d676dd9acf439250dfe1908f07c0257749654e775
|
|
BLAKE2b-256 checksum How to use checksums |
bd71067429415052340eba76d82a0adf9135b59b8cf4781703a45e123b1372cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Security for PromptEHR 0.0.6
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.