PromptEHR


NamePromptEHR JSON
Version 0.0.6 PyPI version JSON
download
home_pagehttps://github.com/RyanWangZf/PromptEHR
SummarySequence patient electronic healthcare record generation with large language models (LLMs) as the neural database.
upload_time2023-06-08 05:26:18
maintainer
docs_urlNone
authorZifeng Wang
requires_python
license
keywords synthetic data healthcare ehr deep learning ai
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PromptEHR
[![PyPI version](https://badge.fury.io/py/transtab.svg)](https://badge.fury.io/py/promptehr)
[![Downloads](https://pepy.tech/badge/promptehr)](https://pepy.tech/project/promptehr)
![GitHub Repo stars](https://img.shields.io/github/stars/ryanwangzf/promptehr)
![GitHub Repo forks](https://img.shields.io/github/forks/ryanwangzf/promptehr)

Wang, Zifeng and Sun, Jimeng. (2022). PromptEHR: Conditional Electronic Healthcare Records Generation with Prompt Learning. EMNLP'22.

# News
- [2023/01/08] `PromptEHR` is now integrated into [`PyTrial`](https://github.com/RyanWangZf/PyTrial) with a complete [documentation](https://pytrial.readthedocs.io/en/latest/trial_simulation/sequence/promptehr.html) and [example](https://colab.research.google.com/drive/1EbzLdSwTrbgsEgz8z70qzTLQWiPWlyRm?usp=sharing), please check! New version with bugs fixed is also released!


# Usage

Get pretrained PromptEHR model (learned on MIMIC-III sequence EHRs) in three lines:

```python
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

```bash
pip install git+https://github.com/RyanWangZf/PromptEHR.git
```

or

```bash
pip install promptehr
```



# Load demo synthetic EHRs (generated by PromptEHR)

```python
from promptehr import load_synthetic_data
data = load_synthetic_data()
```



# Use PromptEHR for generation

```python
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)
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/RyanWangZf/PromptEHR",
    "name": "PromptEHR",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "synthetic data,healthcare,EHR,deep learning,AI",
    "author": "Zifeng Wang",
    "author_email": "zifengw2@illinois.edu",
    "download_url": "https://files.pythonhosted.org/packages/ad/bb/9aadbcb822c0d5c358c49b9d4486639821bb389c8ac43f30eb2260611dca/PromptEHR-0.0.6.tar.gz",
    "platform": null,
    "description": "# PromptEHR\n[![PyPI version](https://badge.fury.io/py/transtab.svg)](https://badge.fury.io/py/promptehr)\n[![Downloads](https://pepy.tech/badge/promptehr)](https://pepy.tech/project/promptehr)\n![GitHub Repo stars](https://img.shields.io/github/stars/ryanwangzf/promptehr)\n![GitHub Repo forks](https://img.shields.io/github/forks/ryanwangzf/promptehr)\n\nWang, Zifeng and Sun, Jimeng. (2022). PromptEHR: Conditional Electronic Healthcare Records Generation with Prompt Learning. EMNLP'22.\n\n# News\n- [2023/01/08] `PromptEHR` is now integrated into [`PyTrial`](https://github.com/RyanWangZf/PyTrial) with a complete [documentation](https://pytrial.readthedocs.io/en/latest/trial_simulation/sequence/promptehr.html) and [example](https://colab.research.google.com/drive/1EbzLdSwTrbgsEgz8z70qzTLQWiPWlyRm?usp=sharing), please check! New version with bugs fixed is also released!\n\n\n# Usage\n\nGet pretrained PromptEHR model (learned on MIMIC-III sequence EHRs) in three lines:\n\n```python\nfrom promptehr import PromptEHR\n\nmodel = PromptEHR()\n\nmodel.from_pretrained()\n```\n\nA jupyter example is available at https://github.com/RyanWangZf/PromptEHR/blob/main/example/demo_promptehr.ipynb.\n\n\n\n# How to install\n\nInstall the correct `PyTorch` version by referring to https://pytorch.org/get-started/locally/.\n\nThen try to install `PromptEHR` by\n\n```bash\npip install git+https://github.com/RyanWangZf/PromptEHR.git\n```\n\nor\n\n```bash\npip install promptehr\n```\n\n\n\n# Load demo synthetic EHRs (generated by PromptEHR)\n\n```python\nfrom promptehr import load_synthetic_data\ndata = load_synthetic_data()\n```\n\n\n\n# Use PromptEHR for generation\n\n```python\nfrom promptehr import SequencePatient\nfrom promptehr import load_synthetic_data\nfrom promptehr import PromptEHR\n\n# init model\nmodel = PromptEHR()\nmodel.from_pretrained()\n\n# load input data\ndemo = load_synthetic_data(n_sample=1000) # we have 10,000 samples in total\n\n# build the standard input data for train or test PromptEHR models\nseqdata = SequencePatient(data={'v':demo['visit'], 'y':demo['y'], 'x':demo['feature'],},\n    metadata={\n        'visit':{'mode':'dense'},\n        'label':{'mode':'tensor'}, \n        'voc':demo['voc'],\n        'max_visit':20,\n        }\n    )\n# you can try to fit on this data by\n# model.fit(seqdata)\n\n# start generate\n# n: the target total number of samples to generate\n# n_per_sample: based on each sample, how many fake samples will be generated\n# the output will have the same format of `SequencePatient`\nfake_data = model.predict(seqdata, n=1000, n_per_sample=10)\n```\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Sequence patient electronic healthcare record generation with large language models (LLMs) as the neural database.",
    "version": "0.0.6",
    "project_urls": {
        "Homepage": "https://github.com/RyanWangZf/PromptEHR"
    },
    "split_keywords": [
        "synthetic data",
        "healthcare",
        "ehr",
        "deep learning",
        "ai"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bd71067429415052340eba76d82a0adf9135b59b8cf4781703a45e123b1372cd",
                "md5": "d303d6162a1150b811c1df1918e4c90f",
                "sha256": "a2eae33478b51b3a84ad8b9d676dd9acf439250dfe1908f07c0257749654e775"
            },
            "downloads": -1,
            "filename": "PromptEHR-0.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d303d6162a1150b811c1df1918e4c90f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 312862,
            "upload_time": "2023-06-08T05:26:16",
            "upload_time_iso_8601": "2023-06-08T05:26:16.423154Z",
            "url": "https://files.pythonhosted.org/packages/bd/71/067429415052340eba76d82a0adf9135b59b8cf4781703a45e123b1372cd/PromptEHR-0.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "adbb9aadbcb822c0d5c358c49b9d4486639821bb389c8ac43f30eb2260611dca",
                "md5": "f11f68f386c719591c21580f9969f260",
                "sha256": "31638dbdf274b35a37b8930cc47619b6467ef689cd9205204a04b01c83f20fe6"
            },
            "downloads": -1,
            "filename": "PromptEHR-0.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "f11f68f386c719591c21580f9969f260",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 230161,
            "upload_time": "2023-06-08T05:26:18",
            "upload_time_iso_8601": "2023-06-08T05:26:18.176011Z",
            "url": "https://files.pythonhosted.org/packages/ad/bb/9aadbcb822c0d5c358c49b9d4486639821bb389c8ac43f30eb2260611dca/PromptEHR-0.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-08 05:26:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "RyanWangZf",
    "github_project": "PromptEHR",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "promptehr"
}
        
Elapsed time: 0.06984s