temporai


Nametemporai JSON
Version 0.0.3 PyPI version JSON
download
home_pagehttps://github.com/vanderschaarlab/temporai
SummaryTemporAI: ML-centric Toolkit for Medical Time Series
upload_time2023-12-07 23:05:06
maintainer
docs_urlNone
authorEvgeny Saveliev
requires_python>=3.7
licenseApache-2.0 license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            <!-- These are examples of badges you might want to add to your README:
     please update the URLs accordingly

[![Conda-Forge](https://img.shields.io/conda/vn/conda-forge/temporai.svg)](https://anaconda.org/conda-forge/temporai)
[![Monthly Downloads](https://pepy.tech/badge/temporai/month)](https://pepy.tech/project/temporai)
-->

<!-- exclude_docs -->
[![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/usage/tutorial04_prediction.ipynb)
[![Documentation Status](https://readthedocs.org/projects/temporai/badge/?version=latest)](https://temporai.readthedocs.io/en/latest/?badge=latest)

[![Python 3.7+](https://img.shields.io/badge/python-3.7+-blue.svg)](https://www.python.org/downloads/release/python-370/)
[![PyPI-Server](https://img.shields.io/pypi/v/temporai?color=blue)](https://pypi.org/project/temporai/)
[![Downloads](https://static.pepy.tech/badge/temporai)](https://pepy.tech/project/temporai)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://github.com/vanderschaarlab/temporai/tree/main/LICENSE.txt)

[![Tests](https://github.com/vanderschaarlab/temporai/actions/workflows/test.yml/badge.svg)](https://github.com/vanderschaarlab/temporai/actions/workflows/test.yml)
[![Tests](https://github.com/vanderschaarlab/temporai/actions/workflows/test_full.yml/badge.svg)](https://github.com/vanderschaarlab/temporai/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/vanderschaarlab/temporai/branch/main/graph/badge.svg?token=FCKO12SND7)](https://codecov.io/gh/vanderschaarlab/temporai)

[![arXiv](https://img.shields.io/badge/arXiv-2301.12260-b31b1b.svg)](https://arxiv.org/abs/2301.12260)
[![slack](https://img.shields.io/badge/chat-on%20slack-purple?logo=slack)](https://join.slack.com/t/vanderschaarlab/shared_invite/zt-1u2rmhw06-sHS5nQDMN3Ka2Zer6sAU6Q)
[![about](https://img.shields.io/badge/about-The%20van%20der%20Schaar%20Lab-blue)](https://www.vanderschaar-lab.com/)
<!-- exclude_docs_end -->

# <img src='https://raw.githubusercontent.com/vanderschaarlab/temporai/main/docs/assets/TemporAI_Logo_Icon.png' height=25> TemporAI

<!-- exclude_docs -->
> **⚗️ Status:** This project is still in *alpha*, and the API may change without warning.  
<!-- exclude_docs_end -->
<!-- include_docs
:::{important}
**Status:** This project is still in *alpha*, and the API may change without warning.  
:::
include_docs_end -->


## 📃 Overview

*TemporAI* is a Machine Learning-centric time-series library for medicine.  The tasks that are currently of focus in TemporAI are: time-to-event (survival) analysis with time-series data, treatment effects (causal inference) over time, and time-series prediction. Data preprocessing methods, including missing value imputation for static and temporal covariates, are provided. AutoML tools for hyperparameter tuning and pipeline selection are also available.

### How is TemporAI unique?

* **🏥 Medicine-first:** Focused on use cases for medicine and healthcare, such as temporal treatment effects, survival analysis over time, imputation methods, models with built-in and post-hoc interpretability, ... See [methods](https://github.com/vanderschaarlab/temporai/tree/main/#-methods).
* **🏗️ Fast prototyping:** A plugin design allowing for on-the-fly integration of new methods by the users.
* **🚀 From research to practice:** Relevant novel models from research community adapted for practical use.
* **🌍 A healthcare ecosystem vision:** A range of interactive demonstration apps, new medical problem settings, interpretability tools, data-centric tools etc. are planned.

### Key concepts

<div align="center">

<!-- exclude_docs -->
<img src='https://raw.githubusercontent.com/vanderschaarlab/temporai/main/docs/assets/Conceptual.png' alt="key concepts">
<!-- exclude_docs_end -->
<!-- include_docs
<img src='https://raw.githubusercontent.com/vanderschaarlab/temporai/main/docs/assets/Conceptual.png' alt="key concepts">
include_docs_end -->

</div>



## 🚀 Installation

### Instal with `pip`

From [the Python Package Index (PyPI)](https://pypi.org/):
```bash
$ pip install temporai
```

Or from source:
```bash
$ git clone https://github.com/vanderschaarlab/temporai.git
$ cd temporai
$ pip install .
```

### Install in a [conda](https://docs.conda.io/en/latest/) environment

While have not yet published TemporAI on `conda-forge`, you can still install TemporAI in your conda environment using `pip` as follows:

Create and activate conda environment as normal:
```bash
$ conda create -n <my_environment>
$ conda activate <my_environment>
```

Then install inside your `conda` environment with pip:
```bash
$ pip install temporai
```


## 💥 Sample Usage

<!-- exclude_docs -->
<!-- exclude_docs_end -->
<!-- include_docs
* List the available plugins
include_docs_end -->

* List the available plugins


```python
from tempor import plugin_loader

print(plugin_loader.list())
```

<!-- exclude_docs -->
<!-- exclude_docs_end -->

<!-- exclude_docs -->
<!-- exclude_docs_end -->
<!-- include_docs
* Use a time-to-event (survival) analysis model
include_docs_end -->

* Use a time-to-event (survival) analysis model


```python
from tempor import plugin_loader

# Load a time-to-event dataset:
dataset = plugin_loader.get("time_to_event.pbc", plugin_type="datasource").load()

# Initialize the model:
model = plugin_loader.get("time_to_event.dynamic_deephit")

# Train:
model.fit(dataset)

# Make risk predictions:
prediction = model.predict(dataset, horizons=[0.25, 0.50, 0.75])
```

<!-- exclude_docs -->
<!-- exclude_docs_end -->

<!-- exclude_docs -->
<!-- exclude_docs_end -->
<!-- include_docs
* Use a temporal treatment effects model
include_docs_end -->

* Use a temporal treatment effects model


```python
import numpy as np

from tempor import plugin_loader

# Load a dataset with temporal treatments and outcomes:
dataset = plugin_loader.get(
    "treatments.temporal.dummy_treatments",
    plugin_type="datasource",
    temporal_covariates_missing_prob=0.0,
    temporal_treatments_n_features=1,
    temporal_treatments_n_categories=2,
).load()

# Initialize the model:
model = plugin_loader.get("treatments.temporal.regression.crn_regressor", epochs=20)

# Train:
model.fit(dataset)

# Define target variable horizons for each sample:
horizons = [
    tc.time_indexes()[0][len(tc.time_indexes()[0]) // 2 :] for tc in dataset.time_series
]

# Define treatment scenarios for each sample:
treatment_scenarios = [
    [np.asarray([1] * len(h)), np.asarray([0] * len(h))] for h in horizons
]

# Predict counterfactuals:
counterfactuals = model.predict_counterfactuals(
    dataset,
    horizons=horizons,
    treatment_scenarios=treatment_scenarios,
)
```

<!-- exclude_docs -->
<!-- exclude_docs_end -->

<!-- exclude_docs -->
<!-- exclude_docs_end -->
<!-- include_docs
* Use a missing data imputer
include_docs_end -->

* Use a missing data imputer


```python
from tempor import plugin_loader

dataset = plugin_loader.get(
    "prediction.one_off.sine", plugin_type="datasource", with_missing=True
).load()
static_data_n_missing = dataset.static.dataframe().isna().sum().sum()
temporal_data_n_missing = dataset.time_series.dataframe().isna().sum().sum()

print(static_data_n_missing, temporal_data_n_missing)
assert static_data_n_missing > 0
assert temporal_data_n_missing > 0

# Initialize the model:
model = plugin_loader.get("preprocessing.imputation.temporal.bfill")

# Train:
model.fit(dataset)

# Impute:
imputed = model.transform(dataset)
temporal_data_n_missing = imputed.time_series.dataframe().isna().sum().sum()

print(static_data_n_missing, temporal_data_n_missing)
assert temporal_data_n_missing == 0
```

<!-- exclude_docs -->
<!-- exclude_docs_end -->


<!-- exclude_docs -->
<!-- exclude_docs_end -->
<!-- include_docs
* Use a one-off classifier (prediction)
include_docs_end -->

* Use a one-off classifier (prediction)


```python
from tempor import plugin_loader

dataset = plugin_loader.get("prediction.one_off.sine", plugin_type="datasource").load()

# Initialize the model:
model = plugin_loader.get("prediction.one_off.classification.nn_classifier", n_iter=50)

# Train:
model.fit(dataset)

# Predict:
prediction = model.predict(dataset)
```
<!-- exclude_docs -->
<!-- exclude_docs_end -->

<!-- exclude_docs -->
<!-- exclude_docs_end -->
<!-- include_docs
* Use a temporal regressor (forecasting)
include_docs_end -->

* Use a temporal regressor (forecasting)


```python
from tempor import plugin_loader

# Load a dataset with temporal targets.
dataset = plugin_loader.get(
    "prediction.temporal.dummy_prediction",
    plugin_type="datasource",
    temporal_covariates_missing_prob=0.0,
).load()

# Initialize the model:
model = plugin_loader.get("prediction.temporal.regression.seq2seq_regressor", epochs=10)

# Train:
model.fit(dataset)

# Predict:
prediction = model.predict(dataset, n_future_steps=5)
```

<!-- exclude_docs -->
<!-- exclude_docs_end -->

<!-- exclude_docs -->
<!-- exclude_docs_end -->
<!-- include_docs
* Benchmark models, time-to-event task
include_docs_end -->

* Benchmark models, time-to-event task


```python
from tempor.benchmarks import benchmark_models
from tempor import plugin_loader
from tempor.methods.pipeline import pipeline

testcases = [
    (
        "pipeline1",
        pipeline(
            [
                "preprocessing.scaling.temporal.ts_minmax_scaler",
                "time_to_event.dynamic_deephit",
            ]
        )({"ts_coxph": {"n_iter": 100}}),
    ),
    (
        "plugin1",
        plugin_loader.get("time_to_event.dynamic_deephit", n_iter=100),
    ),
    (
        "plugin2",
        plugin_loader.get("time_to_event.ts_coxph", n_iter=100),
    ),
]
dataset = plugin_loader.get("time_to_event.pbc", plugin_type="datasource").load()

aggr_score, per_test_score = benchmark_models(
    task_type="time_to_event",
    tests=testcases,
    data=dataset,
    n_splits=2,
    random_state=0,
    horizons=[2.0, 4.0, 6.0],
)

print(aggr_score)
```

<!-- exclude_docs -->
<!-- exclude_docs_end -->

<!-- exclude_docs -->
<!-- exclude_docs_end -->
<!-- include_docs
* Serialization
include_docs_end -->

* Serialization


```python
from tempor.utils.serialization import load, save
from tempor import plugin_loader

# Initialize the model:
model = plugin_loader.get("prediction.one_off.classification.nn_classifier", n_iter=50)

buff = save(model)  # Save model to bytes.
reloaded = load(buff)  # Reload model.

# `save_to_file`, `load_from_file` also available in the serialization module.
```

<!-- exclude_docs -->
<!-- exclude_docs_end -->

<!-- exclude_docs -->
<!-- exclude_docs_end -->
<!-- include_docs
* AutoML - search for the best pipeline for your task
include_docs_end -->

* AutoML - search for the best pipeline for your task


```python
from tempor.automl.seeker import PipelineSeeker

dataset = plugin_loader.get("prediction.one_off.sine", plugin_type="datasource").load()

# Specify the AutoML pipeline seeker for the task of your choice, providing candidate methods,
# metric, preprocessing steps etc.
seeker = PipelineSeeker(
    study_name="my_automl_study",
    task_type="prediction.one_off.classification",
    estimator_names=[
        "cde_classifier",
        "ode_classifier",
        "nn_classifier",
    ],
    metric="aucroc",
    dataset=dataset,
    return_top_k=3,
    num_iter=100,
    tuner_type="bayesian",
    static_imputers=["static_tabular_imputer"],
    static_scalers=[],
    temporal_imputers=["ffill", "bfill"],
    temporal_scalers=["ts_minmax_scaler"],
)

# The search will return the best pipelines.
best_pipelines, best_scores = seeker.search()  # doctest: +SKIP
```

<!-- exclude_docs -->
<!-- exclude_docs_end -->



## 📖 Tutorials

### Data

- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/data/tutorial01_data_format.ipynb) - [Data Format](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/data/tutorial01_data_format.ipynb)
- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/data/tutorial02_datasets.ipynb) - [Datasets](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/data/tutorial02_datasets.ipynb)
- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/data/tutorial03_datasources.ipynb) - [Data Loaders](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/data/tutorial03_datasources.ipynb)
- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/data/tutorial04_data_splitting.ipynb) - [Data Splitting](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/data/tutorial04_data_splitting.ipynb)
- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/data/tutorial05_other_data_formats.ipynb) - [Other Data Formats](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/data/tutorial05_other_data_formats.ipynb)
- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/data/tutorial06_mimic_use_case.ipynb) - [MIMIC Use Case](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/data/tutorial06_mimic_use_case.ipynb)

### User Guide
- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/usage/tutorial01_plugins.ipynb) - [Plugins](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/usage/tutorial01_plugins.ipynb)
- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/usage/tutorial02_imputation.ipynb) - [Imputation](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/usage/tutorial02_imputation.ipynb)
- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/usage/tutorial03_scaling.ipynb) - [Scaling](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/usage/tutorial03_scaling.ipynb)
- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/usage/tutorial04_prediction.ipynb) - [Prediction](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/usage/tutorial04_prediction.ipynb)
- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/usage/tutorial05_time_to_event.ipynb) - [Time-to-event Analysis](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/usage/tutorial05_time_to_event.ipynb)
- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/usage/tutorial06_treatments.ipynb) - [Treatment Effects](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/usage/tutorial06_treatments.ipynb)
- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/usage/tutorial07_pipeline.ipynb) - [Pipeline](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/usage/tutorial07_pipeline.ipynb)
- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/usage/tutorial08_benchmarks.ipynb) - [Benchmarks](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/usage/tutorial08_benchmarks.ipynb)
- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/usage/tutorial09_automl.ipynb) - [AutoML](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/usage/tutorial09_automl.ipynb)

### Extending TemporAI
- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/extending/tutorial01_custom_method.ipynb) - [Writing a Custom Method Plugin](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/extending/tutorial01_custom_method.ipynb)
- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/extending/tutorial02_testing_custom_method.ipynb) - [Testing a Custom Method Plugin](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/extending/tutorial02_testing_custom_method.ipynb)
- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/extending/tutorial03_custom_datasource.ipynb) - [Writing a Custom Data Source Plugin](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/extending/tutorial03_custom_datasource.ipynb)
- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/extending/tutorial04_custom_metric.ipynb) - [Writing a Custom Metric Plugin](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/extending/tutorial04_custom_metric.ipynb)
- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/extending/tutorial05_custom_dataformat.ipynb) - [Writing a Custom Data Format](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/extending/tutorial05_custom_dataformat.ipynb)



<!-- exclude_docs -->
## 📘 Documentation

See the full project documentation [here](https://temporai.readthedocs.io/en/latest/).
<!-- exclude_docs_end -->



<!--- Reusable --->
  [van der Schaar Lab]:    https://www.vanderschaar-lab.com/
  [docs]:                  https://temporai.readthedocs.io/en/latest/
<!-- exclude_docs -->
  [docs/user_guide]:       https://temporai.readthedocs.io/en/latest/user_guide/index.html
<!-- exclude_docs_end -->



## 🌍 TemporAI Ecosystem (*Experimental*)

We provide additional tools in the TemporAI ecosystem, which are in active development, and are currently (very) experimental. Suggestions and contributions are welcome!

These include:
- [`temporai-clinic`](https://github.com/vanderschaarlab/temporai-clinic): A web app tool for interacting and visualising TemporAI models, data, and predictions.
- [`temporai-mivdp`](https://github.com/vanderschaarlab/temporai-mivdp): A [MIMIC-IV-Data-Pipeline](https://github.com/healthylaife/MIMIC-IV-Data-Pipeline) adaptation for TemporAI.



<!-- include_docs
{#methods}include_docs_end -->
## 🔑 Methods

<!-- exclude_docs -->
<!-- exclude_docs_end -->

<!-- exclude_docs -->
<!-- exclude_docs_end -->
<!-- include_docs
### Time-to-Event (survival) analysis over time
include_docs_end -->

### Time-to-Event (survival) analysis over time


Risk estimation given event data (category: `time_to_event`)

| Name | Description| Reference |
| --- | --- | --- |
| `dynamic_deephit` | Dynamic-DeepHit incorporates the available longitudinal data comprising various repeated measurements (rather than only the last available measurements) in order to issue dynamically updated survival predictions | [Paper](https://pubmed.ncbi.nlm.nih.gov/30951460/) |
| `ts_coxph` | Create embeddings from the time series and use a CoxPH model for predicting the survival function| --- |
| `ts_xgb` | Create embeddings from the time series and use a SurvivalXGBoost model for predicting the survival function| --- |

<!-- exclude_docs -->
<!-- exclude_docs_end -->

<!-- exclude_docs -->
<!-- exclude_docs_end -->
<!-- include_docs
### Treatment effects
include_docs_end -->

### Treatment effects


#### One-off
Treatment effects estimation where treatments are a one-off event.

<!--
* Classification on the outcomes (category: `treatments.one_off.classification`)
-->

* Regression on the outcomes (category: `treatments.one_off.regression`)

| Name | Description| Reference |
| --- | --- | --- |
| `synctwin_regressor` | SyncTwin is a treatment effect estimation method tailored for observational studies with longitudinal data, applied to the LIP setting: Longitudinal, Irregular and Point treatment.  | [Paper](https://proceedings.neurips.cc/paper/2021/hash/19485224d128528da1602ca47383f078-Abstract.html) |

#### Temporal
Treatment effects estimation where treatments are temporal (time series).

* Classification on the outcomes (category: `treatments.temporal.classification`)

| Name | Description| Reference |
| --- | --- | --- |
| `crn_classifier` | The Counterfactual Recurrent Network (CRN), a sequence-to-sequence model that leverages the available patient observational data to estimate treatment effects over time. | [Paper](https://arxiv.org/abs/2002.04083) |

* Regression on the outcomes (category: `treatments.temporal.regression`)

| Name | Description| Reference |
| --- | --- | --- |
| `crn_regressor` | The Counterfactual Recurrent Network (CRN), a sequence-to-sequence model that leverages the available patient observational data to estimate treatment effects over time. | [Paper](https://arxiv.org/abs/2002.04083) |

<!-- exclude_docs -->
<!-- exclude_docs_end -->

<!-- exclude_docs -->
<!-- exclude_docs_end -->
<!-- include_docs
### Prediction
include_docs_end -->

### Prediction


#### One-off
Prediction where targets are static.

* Classification (category: `prediction.one_off.classification`)

| Name | Description| Reference |
| --- | --- | --- |
| `nn_classifier` | Neural-net based classifier. Supports multiple recurrent models, like RNN, LSTM, Transformer etc.  | --- |
| `ode_classifier` | Classifier based on ordinary differential equation (ODE) solvers.  | --- |
| `cde_classifier` | Classifier based Neural Controlled Differential Equations for Irregular Time Series.  | [Paper](https://arxiv.org/abs/2005.08926) |
| `laplace_ode_classifier` | Classifier based Inverse Laplace Transform (ILT) algorithms implemented in PyTorch.  | [Paper](https://arxiv.org/abs/2206.04843) |

* Regression (category: `prediction.one_off.regression`)

| Name | Description| Reference |
| --- | --- | --- |
| `nn_regressor` | Neural-net based regressor. Supports multiple recurrent models, like RNN, LSTM, Transformer etc.  | --- |
| `ode_regressor` | Regressor based on ordinary differential equation (ODE) solvers.  | --- |
| `cde_regressor` | Regressor based Neural Controlled Differential Equations for Irregular Time Series.  | [Paper](https://arxiv.org/abs/2005.08926)
| `laplace_ode_regressor` | Regressor based Inverse Laplace Transform (ILT) algorithms implemented in PyTorch.  | [Paper](https://arxiv.org/abs/2206.04843) |

#### Temporal
Prediction where targets are temporal (time series).

* Classification (category: `prediction.temporal.classification`)

| Name | Description| Reference |
| --- | --- | --- |
| `seq2seq_classifier` | Seq2Seq prediction, classification | --- |

* Regression (category: `prediction.temporal.regression`)

| Name | Description| Reference |
| --- | --- | --- |
| `seq2seq_regressor` | Seq2Seq prediction, regression | --- |

<!-- exclude_docs -->
<!-- exclude_docs_end -->

<!-- exclude_docs -->
<!-- exclude_docs_end -->
<!-- include_docs
### Preprocessing
include_docs_end -->

### Preprocessing


#### Feature Encoding

* Static data (category: `preprocessing.encoding.static`)

| Name | Description| Reference |
| --- | --- | --- |
| `static_onehot_encoder` | One-hot encode categorical static features | --- |

* Temporal data (category: `preprocessing.encoding.temporal`)

| Name | Description| Reference |
| --- | --- | --- |
| `ts_onehot_encoder` | One-hot encode categorical time series features | --- |

#### Imputation

* Static data (category: `preprocessing.imputation.static`)

| Name | Description| Reference |
| --- | --- | --- |
| `static_tabular_imputer` | Use any method from [HyperImpute](https://github.com/vanderschaarlab/hyperimpute) (HyperImpute, Mean, Median, Most-frequent, MissForest, ICE, MICE, SoftImpute, EM, Sinkhorn, GAIN, MIRACLE, MIWAE) to impute the static data | [Paper](https://arxiv.org/abs/2206.07769) |

* Temporal data (category: `preprocessing.imputation.temporal`)

| Name | Description| Reference |
| --- | --- | --- |
| `ffill` | Propagate last valid observation forward to next valid  | --- |
| `bfill` | Use next valid observation to fill gap | --- |
| `ts_tabular_imputer` | Use any method from [HyperImpute](https://github.com/vanderschaarlab/hyperimpute) (HyperImpute, Mean, Median, Most-frequent, MissForest, ICE, MICE, SoftImpute, EM, Sinkhorn, GAIN, MIRACLE, MIWAE) to impute the time series data | [Paper](https://arxiv.org/abs/2206.07769) |


#### Scaling

* Static data (category: `preprocessing.scaling.static`)

| Name | Description| Reference |
| --- | --- | --- |
| `static_standard_scaler` | Scale the static features using a StandardScaler | --- |
| `static_minmax_scaler` | Scale the static features using a MinMaxScaler | --- |

* Temporal data (category: `preprocessing.scaling.temporal`)

| Name | Description| Reference |
| --- | --- | --- |
| `ts_standard_scaler` | Scale the temporal features using a StandardScaler | --- |
| `ts_minmax_scaler` | Scale the temporal features using a MinMaxScaler | --- |


<!-- exclude_docs -->
<!-- exclude_docs_end -->



## 🔨 Tests and Development

Install the testing dependencies using:
```bash
pip install .[testing]
```
The tests can be executed using:
```bash
pytest -vsx
```

For local development, we recommend that you should install the `[dev]` extra, which includes `[testing]` and some additional dependencies:
```bash
pip install .[dev]
```

For development and contribution to TemporAI, see:
* 📓 [Extending TemporAI tutorials](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/extending/)
* 📃 [Contribution guide](https://github.com/vanderschaarlab/temporai/tree/main/CONTRIBUTING.md)
* 👩‍💻 [Developer's guide](https://github.com/vanderschaarlab/temporai/tree/main/docs/dev_guide.md)



## ✍️ Citing

If you use this code, please cite the associated paper:
```
@article{saveliev2023temporai,
  title={TemporAI: Facilitating Machine Learning Innovation in Time Domain Tasks for Medicine},
  author={Saveliev, Evgeny S and van der Schaar, Mihaela},
  journal={arXiv preprint arXiv:2301.12260},
  year={2023}
}
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/vanderschaarlab/temporai",
    "name": "temporai",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Evgeny Saveliev",
    "author_email": "e.s.saveliev@gmail.com",
    "download_url": "",
    "platform": "any",
    "description": "<!-- These are examples of badges you might want to add to your README:\r\n     please update the URLs accordingly\r\n\r\n[![Conda-Forge](https://img.shields.io/conda/vn/conda-forge/temporai.svg)](https://anaconda.org/conda-forge/temporai)\r\n[![Monthly Downloads](https://pepy.tech/badge/temporai/month)](https://pepy.tech/project/temporai)\r\n-->\r\n\r\n<!-- exclude_docs -->\r\n[![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/usage/tutorial04_prediction.ipynb)\r\n[![Documentation Status](https://readthedocs.org/projects/temporai/badge/?version=latest)](https://temporai.readthedocs.io/en/latest/?badge=latest)\r\n\r\n[![Python 3.7+](https://img.shields.io/badge/python-3.7+-blue.svg)](https://www.python.org/downloads/release/python-370/)\r\n[![PyPI-Server](https://img.shields.io/pypi/v/temporai?color=blue)](https://pypi.org/project/temporai/)\r\n[![Downloads](https://static.pepy.tech/badge/temporai)](https://pepy.tech/project/temporai)\r\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://github.com/vanderschaarlab/temporai/tree/main/LICENSE.txt)\r\n\r\n[![Tests](https://github.com/vanderschaarlab/temporai/actions/workflows/test.yml/badge.svg)](https://github.com/vanderschaarlab/temporai/actions/workflows/test.yml)\r\n[![Tests](https://github.com/vanderschaarlab/temporai/actions/workflows/test_full.yml/badge.svg)](https://github.com/vanderschaarlab/temporai/actions/workflows/test.yml)\r\n[![codecov](https://codecov.io/gh/vanderschaarlab/temporai/branch/main/graph/badge.svg?token=FCKO12SND7)](https://codecov.io/gh/vanderschaarlab/temporai)\r\n\r\n[![arXiv](https://img.shields.io/badge/arXiv-2301.12260-b31b1b.svg)](https://arxiv.org/abs/2301.12260)\r\n[![slack](https://img.shields.io/badge/chat-on%20slack-purple?logo=slack)](https://join.slack.com/t/vanderschaarlab/shared_invite/zt-1u2rmhw06-sHS5nQDMN3Ka2Zer6sAU6Q)\r\n[![about](https://img.shields.io/badge/about-The%20van%20der%20Schaar%20Lab-blue)](https://www.vanderschaar-lab.com/)\r\n<!-- exclude_docs_end -->\r\n\r\n# <img src='https://raw.githubusercontent.com/vanderschaarlab/temporai/main/docs/assets/TemporAI_Logo_Icon.png' height=25> TemporAI\r\n\r\n<!-- exclude_docs -->\r\n> **\u2697\ufe0f Status:** This project is still in *alpha*, and the API may change without warning.  \r\n<!-- exclude_docs_end -->\r\n<!-- include_docs\r\n:::{important}\r\n**Status:** This project is still in *alpha*, and the API may change without warning.  \r\n:::\r\ninclude_docs_end -->\r\n\r\n\r\n## \ud83d\udcc3 Overview\r\n\r\n*TemporAI* is a Machine Learning-centric time-series library for medicine.  The tasks that are currently of focus in TemporAI are: time-to-event (survival) analysis with time-series data, treatment effects (causal inference) over time, and time-series prediction. Data preprocessing methods, including missing value imputation for static and temporal covariates, are provided. AutoML tools for hyperparameter tuning and pipeline selection are also available.\r\n\r\n### How is TemporAI unique?\r\n\r\n* **\ud83c\udfe5 Medicine-first:** Focused on use cases for medicine and healthcare, such as temporal treatment effects, survival analysis over time, imputation methods, models with built-in and post-hoc interpretability, ... See [methods](https://github.com/vanderschaarlab/temporai/tree/main/#-methods).\r\n* **\ud83c\udfd7\ufe0f Fast prototyping:** A plugin design allowing for on-the-fly integration of new methods by the users.\r\n* **\ud83d\ude80 From research to practice:** Relevant novel models from research community adapted for practical use.\r\n* **\ud83c\udf0d A healthcare ecosystem vision:** A range of interactive demonstration apps, new medical problem settings, interpretability tools, data-centric tools etc. are planned.\r\n\r\n### Key concepts\r\n\r\n<div align=\"center\">\r\n\r\n<!-- exclude_docs -->\r\n<img src='https://raw.githubusercontent.com/vanderschaarlab/temporai/main/docs/assets/Conceptual.png' alt=\"key concepts\">\r\n<!-- exclude_docs_end -->\r\n<!-- include_docs\r\n<img src='https://raw.githubusercontent.com/vanderschaarlab/temporai/main/docs/assets/Conceptual.png' alt=\"key concepts\">\r\ninclude_docs_end -->\r\n\r\n</div>\r\n\r\n\r\n\r\n## \ud83d\ude80 Installation\r\n\r\n### Instal with `pip`\r\n\r\nFrom [the Python Package Index (PyPI)](https://pypi.org/):\r\n```bash\r\n$ pip install temporai\r\n```\r\n\r\nOr from source:\r\n```bash\r\n$ git clone https://github.com/vanderschaarlab/temporai.git\r\n$ cd temporai\r\n$ pip install .\r\n```\r\n\r\n### Install in a [conda](https://docs.conda.io/en/latest/) environment\r\n\r\nWhile have not yet published TemporAI on `conda-forge`, you can still install TemporAI in your conda environment using `pip` as follows:\r\n\r\nCreate and activate conda environment as normal:\r\n```bash\r\n$ conda create -n <my_environment>\r\n$ conda activate <my_environment>\r\n```\r\n\r\nThen install inside your `conda` environment with pip:\r\n```bash\r\n$ pip install temporai\r\n```\r\n\r\n\r\n## \ud83d\udca5 Sample Usage\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n<!-- include_docs\r\n* List the available plugins\r\ninclude_docs_end -->\r\n\r\n* List the available plugins\r\n\r\n\r\n```python\r\nfrom tempor import plugin_loader\r\n\r\nprint(plugin_loader.list())\r\n```\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n<!-- include_docs\r\n* Use a time-to-event (survival) analysis model\r\ninclude_docs_end -->\r\n\r\n* Use a time-to-event (survival) analysis model\r\n\r\n\r\n```python\r\nfrom tempor import plugin_loader\r\n\r\n# Load a time-to-event dataset:\r\ndataset = plugin_loader.get(\"time_to_event.pbc\", plugin_type=\"datasource\").load()\r\n\r\n# Initialize the model:\r\nmodel = plugin_loader.get(\"time_to_event.dynamic_deephit\")\r\n\r\n# Train:\r\nmodel.fit(dataset)\r\n\r\n# Make risk predictions:\r\nprediction = model.predict(dataset, horizons=[0.25, 0.50, 0.75])\r\n```\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n<!-- include_docs\r\n* Use a temporal treatment effects model\r\ninclude_docs_end -->\r\n\r\n* Use a temporal treatment effects model\r\n\r\n\r\n```python\r\nimport numpy as np\r\n\r\nfrom tempor import plugin_loader\r\n\r\n# Load a dataset with temporal treatments and outcomes:\r\ndataset = plugin_loader.get(\r\n    \"treatments.temporal.dummy_treatments\",\r\n    plugin_type=\"datasource\",\r\n    temporal_covariates_missing_prob=0.0,\r\n    temporal_treatments_n_features=1,\r\n    temporal_treatments_n_categories=2,\r\n).load()\r\n\r\n# Initialize the model:\r\nmodel = plugin_loader.get(\"treatments.temporal.regression.crn_regressor\", epochs=20)\r\n\r\n# Train:\r\nmodel.fit(dataset)\r\n\r\n# Define target variable horizons for each sample:\r\nhorizons = [\r\n    tc.time_indexes()[0][len(tc.time_indexes()[0]) // 2 :] for tc in dataset.time_series\r\n]\r\n\r\n# Define treatment scenarios for each sample:\r\ntreatment_scenarios = [\r\n    [np.asarray([1] * len(h)), np.asarray([0] * len(h))] for h in horizons\r\n]\r\n\r\n# Predict counterfactuals:\r\ncounterfactuals = model.predict_counterfactuals(\r\n    dataset,\r\n    horizons=horizons,\r\n    treatment_scenarios=treatment_scenarios,\r\n)\r\n```\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n<!-- include_docs\r\n* Use a missing data imputer\r\ninclude_docs_end -->\r\n\r\n* Use a missing data imputer\r\n\r\n\r\n```python\r\nfrom tempor import plugin_loader\r\n\r\ndataset = plugin_loader.get(\r\n    \"prediction.one_off.sine\", plugin_type=\"datasource\", with_missing=True\r\n).load()\r\nstatic_data_n_missing = dataset.static.dataframe().isna().sum().sum()\r\ntemporal_data_n_missing = dataset.time_series.dataframe().isna().sum().sum()\r\n\r\nprint(static_data_n_missing, temporal_data_n_missing)\r\nassert static_data_n_missing > 0\r\nassert temporal_data_n_missing > 0\r\n\r\n# Initialize the model:\r\nmodel = plugin_loader.get(\"preprocessing.imputation.temporal.bfill\")\r\n\r\n# Train:\r\nmodel.fit(dataset)\r\n\r\n# Impute:\r\nimputed = model.transform(dataset)\r\ntemporal_data_n_missing = imputed.time_series.dataframe().isna().sum().sum()\r\n\r\nprint(static_data_n_missing, temporal_data_n_missing)\r\nassert temporal_data_n_missing == 0\r\n```\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n<!-- include_docs\r\n* Use a one-off classifier (prediction)\r\ninclude_docs_end -->\r\n\r\n* Use a one-off classifier (prediction)\r\n\r\n\r\n```python\r\nfrom tempor import plugin_loader\r\n\r\ndataset = plugin_loader.get(\"prediction.one_off.sine\", plugin_type=\"datasource\").load()\r\n\r\n# Initialize the model:\r\nmodel = plugin_loader.get(\"prediction.one_off.classification.nn_classifier\", n_iter=50)\r\n\r\n# Train:\r\nmodel.fit(dataset)\r\n\r\n# Predict:\r\nprediction = model.predict(dataset)\r\n```\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n<!-- include_docs\r\n* Use a temporal regressor (forecasting)\r\ninclude_docs_end -->\r\n\r\n* Use a temporal regressor (forecasting)\r\n\r\n\r\n```python\r\nfrom tempor import plugin_loader\r\n\r\n# Load a dataset with temporal targets.\r\ndataset = plugin_loader.get(\r\n    \"prediction.temporal.dummy_prediction\",\r\n    plugin_type=\"datasource\",\r\n    temporal_covariates_missing_prob=0.0,\r\n).load()\r\n\r\n# Initialize the model:\r\nmodel = plugin_loader.get(\"prediction.temporal.regression.seq2seq_regressor\", epochs=10)\r\n\r\n# Train:\r\nmodel.fit(dataset)\r\n\r\n# Predict:\r\nprediction = model.predict(dataset, n_future_steps=5)\r\n```\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n<!-- include_docs\r\n* Benchmark models, time-to-event task\r\ninclude_docs_end -->\r\n\r\n* Benchmark models, time-to-event task\r\n\r\n\r\n```python\r\nfrom tempor.benchmarks import benchmark_models\r\nfrom tempor import plugin_loader\r\nfrom tempor.methods.pipeline import pipeline\r\n\r\ntestcases = [\r\n    (\r\n        \"pipeline1\",\r\n        pipeline(\r\n            [\r\n                \"preprocessing.scaling.temporal.ts_minmax_scaler\",\r\n                \"time_to_event.dynamic_deephit\",\r\n            ]\r\n        )({\"ts_coxph\": {\"n_iter\": 100}}),\r\n    ),\r\n    (\r\n        \"plugin1\",\r\n        plugin_loader.get(\"time_to_event.dynamic_deephit\", n_iter=100),\r\n    ),\r\n    (\r\n        \"plugin2\",\r\n        plugin_loader.get(\"time_to_event.ts_coxph\", n_iter=100),\r\n    ),\r\n]\r\ndataset = plugin_loader.get(\"time_to_event.pbc\", plugin_type=\"datasource\").load()\r\n\r\naggr_score, per_test_score = benchmark_models(\r\n    task_type=\"time_to_event\",\r\n    tests=testcases,\r\n    data=dataset,\r\n    n_splits=2,\r\n    random_state=0,\r\n    horizons=[2.0, 4.0, 6.0],\r\n)\r\n\r\nprint(aggr_score)\r\n```\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n<!-- include_docs\r\n* Serialization\r\ninclude_docs_end -->\r\n\r\n* Serialization\r\n\r\n\r\n```python\r\nfrom tempor.utils.serialization import load, save\r\nfrom tempor import plugin_loader\r\n\r\n# Initialize the model:\r\nmodel = plugin_loader.get(\"prediction.one_off.classification.nn_classifier\", n_iter=50)\r\n\r\nbuff = save(model)  # Save model to bytes.\r\nreloaded = load(buff)  # Reload model.\r\n\r\n# `save_to_file`, `load_from_file` also available in the serialization module.\r\n```\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n<!-- include_docs\r\n* AutoML - search for the best pipeline for your task\r\ninclude_docs_end -->\r\n\r\n* AutoML - search for the best pipeline for your task\r\n\r\n\r\n```python\r\nfrom tempor.automl.seeker import PipelineSeeker\r\n\r\ndataset = plugin_loader.get(\"prediction.one_off.sine\", plugin_type=\"datasource\").load()\r\n\r\n# Specify the AutoML pipeline seeker for the task of your choice, providing candidate methods,\r\n# metric, preprocessing steps etc.\r\nseeker = PipelineSeeker(\r\n    study_name=\"my_automl_study\",\r\n    task_type=\"prediction.one_off.classification\",\r\n    estimator_names=[\r\n        \"cde_classifier\",\r\n        \"ode_classifier\",\r\n        \"nn_classifier\",\r\n    ],\r\n    metric=\"aucroc\",\r\n    dataset=dataset,\r\n    return_top_k=3,\r\n    num_iter=100,\r\n    tuner_type=\"bayesian\",\r\n    static_imputers=[\"static_tabular_imputer\"],\r\n    static_scalers=[],\r\n    temporal_imputers=[\"ffill\", \"bfill\"],\r\n    temporal_scalers=[\"ts_minmax_scaler\"],\r\n)\r\n\r\n# The search will return the best pipelines.\r\nbest_pipelines, best_scores = seeker.search()  # doctest: +SKIP\r\n```\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n\r\n\r\n\r\n## \ud83d\udcd6 Tutorials\r\n\r\n### Data\r\n\r\n- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/data/tutorial01_data_format.ipynb) - [Data Format](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/data/tutorial01_data_format.ipynb)\r\n- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/data/tutorial02_datasets.ipynb) - [Datasets](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/data/tutorial02_datasets.ipynb)\r\n- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/data/tutorial03_datasources.ipynb) - [Data Loaders](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/data/tutorial03_datasources.ipynb)\r\n- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/data/tutorial04_data_splitting.ipynb) - [Data Splitting](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/data/tutorial04_data_splitting.ipynb)\r\n- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/data/tutorial05_other_data_formats.ipynb) - [Other Data Formats](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/data/tutorial05_other_data_formats.ipynb)\r\n- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/data/tutorial06_mimic_use_case.ipynb) - [MIMIC Use Case](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/data/tutorial06_mimic_use_case.ipynb)\r\n\r\n### User Guide\r\n- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/usage/tutorial01_plugins.ipynb) - [Plugins](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/usage/tutorial01_plugins.ipynb)\r\n- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/usage/tutorial02_imputation.ipynb) - [Imputation](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/usage/tutorial02_imputation.ipynb)\r\n- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/usage/tutorial03_scaling.ipynb) - [Scaling](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/usage/tutorial03_scaling.ipynb)\r\n- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/usage/tutorial04_prediction.ipynb) - [Prediction](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/usage/tutorial04_prediction.ipynb)\r\n- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/usage/tutorial05_time_to_event.ipynb) - [Time-to-event Analysis](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/usage/tutorial05_time_to_event.ipynb)\r\n- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/usage/tutorial06_treatments.ipynb) - [Treatment Effects](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/usage/tutorial06_treatments.ipynb)\r\n- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/usage/tutorial07_pipeline.ipynb) - [Pipeline](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/usage/tutorial07_pipeline.ipynb)\r\n- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/usage/tutorial08_benchmarks.ipynb) - [Benchmarks](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/usage/tutorial08_benchmarks.ipynb)\r\n- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/usage/tutorial09_automl.ipynb) - [AutoML](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/usage/tutorial09_automl.ipynb)\r\n\r\n### Extending TemporAI\r\n- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/extending/tutorial01_custom_method.ipynb) - [Writing a Custom Method Plugin](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/extending/tutorial01_custom_method.ipynb)\r\n- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/extending/tutorial02_testing_custom_method.ipynb) - [Testing a Custom Method Plugin](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/extending/tutorial02_testing_custom_method.ipynb)\r\n- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/extending/tutorial03_custom_datasource.ipynb) - [Writing a Custom Data Source Plugin](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/extending/tutorial03_custom_datasource.ipynb)\r\n- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/extending/tutorial04_custom_metric.ipynb) - [Writing a Custom Metric Plugin](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/extending/tutorial04_custom_metric.ipynb)\r\n- [![Test In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanderschaarlab/temporai/blob/main/tutorials/extending/tutorial05_custom_dataformat.ipynb) - [Writing a Custom Data Format](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/extending/tutorial05_custom_dataformat.ipynb)\r\n\r\n\r\n\r\n<!-- exclude_docs -->\r\n## \ud83d\udcd8 Documentation\r\n\r\nSee the full project documentation [here](https://temporai.readthedocs.io/en/latest/).\r\n<!-- exclude_docs_end -->\r\n\r\n\r\n\r\n<!--- Reusable --->\r\n  [van der Schaar Lab]:    https://www.vanderschaar-lab.com/\r\n  [docs]:                  https://temporai.readthedocs.io/en/latest/\r\n<!-- exclude_docs -->\r\n  [docs/user_guide]:       https://temporai.readthedocs.io/en/latest/user_guide/index.html\r\n<!-- exclude_docs_end -->\r\n\r\n\r\n\r\n## \ud83c\udf0d TemporAI Ecosystem (*Experimental*)\r\n\r\nWe provide additional tools in the TemporAI ecosystem, which are in active development, and are currently (very) experimental. Suggestions and contributions are welcome!\r\n\r\nThese include:\r\n- [`temporai-clinic`](https://github.com/vanderschaarlab/temporai-clinic): A web app tool for interacting and visualising TemporAI models, data, and predictions.\r\n- [`temporai-mivdp`](https://github.com/vanderschaarlab/temporai-mivdp): A [MIMIC-IV-Data-Pipeline](https://github.com/healthylaife/MIMIC-IV-Data-Pipeline) adaptation for TemporAI.\r\n\r\n\r\n\r\n<!-- include_docs\r\n{#methods}include_docs_end -->\r\n## \ud83d\udd11 Methods\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n<!-- include_docs\r\n### Time-to-Event (survival) analysis over time\r\ninclude_docs_end -->\r\n\r\n### Time-to-Event (survival) analysis over time\r\n\r\n\r\nRisk estimation given event data (category: `time_to_event`)\r\n\r\n| Name | Description| Reference |\r\n| --- | --- | --- |\r\n| `dynamic_deephit` | Dynamic-DeepHit incorporates the available longitudinal data comprising various repeated measurements (rather than only the last available measurements) in order to issue dynamically updated survival predictions | [Paper](https://pubmed.ncbi.nlm.nih.gov/30951460/) |\r\n| `ts_coxph` | Create embeddings from the time series and use a CoxPH model for predicting the survival function| --- |\r\n| `ts_xgb` | Create embeddings from the time series and use a SurvivalXGBoost model for predicting the survival function| --- |\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n<!-- include_docs\r\n### Treatment effects\r\ninclude_docs_end -->\r\n\r\n### Treatment effects\r\n\r\n\r\n#### One-off\r\nTreatment effects estimation where treatments are a one-off event.\r\n\r\n<!--\r\n* Classification on the outcomes (category: `treatments.one_off.classification`)\r\n-->\r\n\r\n* Regression on the outcomes (category: `treatments.one_off.regression`)\r\n\r\n| Name | Description| Reference |\r\n| --- | --- | --- |\r\n| `synctwin_regressor` | SyncTwin is a treatment effect estimation method tailored for observational studies with longitudinal data, applied to the LIP setting: Longitudinal, Irregular and Point treatment.  | [Paper](https://proceedings.neurips.cc/paper/2021/hash/19485224d128528da1602ca47383f078-Abstract.html) |\r\n\r\n#### Temporal\r\nTreatment effects estimation where treatments are temporal (time series).\r\n\r\n* Classification on the outcomes (category: `treatments.temporal.classification`)\r\n\r\n| Name | Description| Reference |\r\n| --- | --- | --- |\r\n| `crn_classifier` | The Counterfactual Recurrent Network (CRN), a sequence-to-sequence model that leverages the available patient observational data to estimate treatment effects over time. | [Paper](https://arxiv.org/abs/2002.04083) |\r\n\r\n* Regression on the outcomes (category: `treatments.temporal.regression`)\r\n\r\n| Name | Description| Reference |\r\n| --- | --- | --- |\r\n| `crn_regressor` | The Counterfactual Recurrent Network (CRN), a sequence-to-sequence model that leverages the available patient observational data to estimate treatment effects over time. | [Paper](https://arxiv.org/abs/2002.04083) |\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n<!-- include_docs\r\n### Prediction\r\ninclude_docs_end -->\r\n\r\n### Prediction\r\n\r\n\r\n#### One-off\r\nPrediction where targets are static.\r\n\r\n* Classification (category: `prediction.one_off.classification`)\r\n\r\n| Name | Description| Reference |\r\n| --- | --- | --- |\r\n| `nn_classifier` | Neural-net based classifier. Supports multiple recurrent models, like RNN, LSTM, Transformer etc.  | --- |\r\n| `ode_classifier` | Classifier based on ordinary differential equation (ODE) solvers.  | --- |\r\n| `cde_classifier` | Classifier based Neural Controlled Differential Equations for Irregular Time Series.  | [Paper](https://arxiv.org/abs/2005.08926) |\r\n| `laplace_ode_classifier` | Classifier based Inverse Laplace Transform (ILT) algorithms implemented in PyTorch.  | [Paper](https://arxiv.org/abs/2206.04843) |\r\n\r\n* Regression (category: `prediction.one_off.regression`)\r\n\r\n| Name | Description| Reference |\r\n| --- | --- | --- |\r\n| `nn_regressor` | Neural-net based regressor. Supports multiple recurrent models, like RNN, LSTM, Transformer etc.  | --- |\r\n| `ode_regressor` | Regressor based on ordinary differential equation (ODE) solvers.  | --- |\r\n| `cde_regressor` | Regressor based Neural Controlled Differential Equations for Irregular Time Series.  | [Paper](https://arxiv.org/abs/2005.08926)\r\n| `laplace_ode_regressor` | Regressor based Inverse Laplace Transform (ILT) algorithms implemented in PyTorch.  | [Paper](https://arxiv.org/abs/2206.04843) |\r\n\r\n#### Temporal\r\nPrediction where targets are temporal (time series).\r\n\r\n* Classification (category: `prediction.temporal.classification`)\r\n\r\n| Name | Description| Reference |\r\n| --- | --- | --- |\r\n| `seq2seq_classifier` | Seq2Seq prediction, classification | --- |\r\n\r\n* Regression (category: `prediction.temporal.regression`)\r\n\r\n| Name | Description| Reference |\r\n| --- | --- | --- |\r\n| `seq2seq_regressor` | Seq2Seq prediction, regression | --- |\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n<!-- include_docs\r\n### Preprocessing\r\ninclude_docs_end -->\r\n\r\n### Preprocessing\r\n\r\n\r\n#### Feature Encoding\r\n\r\n* Static data (category: `preprocessing.encoding.static`)\r\n\r\n| Name | Description| Reference |\r\n| --- | --- | --- |\r\n| `static_onehot_encoder` | One-hot encode categorical static features | --- |\r\n\r\n* Temporal data (category: `preprocessing.encoding.temporal`)\r\n\r\n| Name | Description| Reference |\r\n| --- | --- | --- |\r\n| `ts_onehot_encoder` | One-hot encode categorical time series features | --- |\r\n\r\n#### Imputation\r\n\r\n* Static data (category: `preprocessing.imputation.static`)\r\n\r\n| Name | Description| Reference |\r\n| --- | --- | --- |\r\n| `static_tabular_imputer` | Use any method from [HyperImpute](https://github.com/vanderschaarlab/hyperimpute) (HyperImpute, Mean, Median, Most-frequent, MissForest, ICE, MICE, SoftImpute, EM, Sinkhorn, GAIN, MIRACLE, MIWAE) to impute the static data | [Paper](https://arxiv.org/abs/2206.07769) |\r\n\r\n* Temporal data (category: `preprocessing.imputation.temporal`)\r\n\r\n| Name | Description| Reference |\r\n| --- | --- | --- |\r\n| `ffill` | Propagate last valid observation forward to next valid  | --- |\r\n| `bfill` | Use next valid observation to fill gap | --- |\r\n| `ts_tabular_imputer` | Use any method from [HyperImpute](https://github.com/vanderschaarlab/hyperimpute) (HyperImpute, Mean, Median, Most-frequent, MissForest, ICE, MICE, SoftImpute, EM, Sinkhorn, GAIN, MIRACLE, MIWAE) to impute the time series data | [Paper](https://arxiv.org/abs/2206.07769) |\r\n\r\n\r\n#### Scaling\r\n\r\n* Static data (category: `preprocessing.scaling.static`)\r\n\r\n| Name | Description| Reference |\r\n| --- | --- | --- |\r\n| `static_standard_scaler` | Scale the static features using a StandardScaler | --- |\r\n| `static_minmax_scaler` | Scale the static features using a MinMaxScaler | --- |\r\n\r\n* Temporal data (category: `preprocessing.scaling.temporal`)\r\n\r\n| Name | Description| Reference |\r\n| --- | --- | --- |\r\n| `ts_standard_scaler` | Scale the temporal features using a StandardScaler | --- |\r\n| `ts_minmax_scaler` | Scale the temporal features using a MinMaxScaler | --- |\r\n\r\n\r\n<!-- exclude_docs -->\r\n<!-- exclude_docs_end -->\r\n\r\n\r\n\r\n## \ud83d\udd28 Tests and Development\r\n\r\nInstall the testing dependencies using:\r\n```bash\r\npip install .[testing]\r\n```\r\nThe tests can be executed using:\r\n```bash\r\npytest -vsx\r\n```\r\n\r\nFor local development, we recommend that you should install the `[dev]` extra, which includes `[testing]` and some additional dependencies:\r\n```bash\r\npip install .[dev]\r\n```\r\n\r\nFor development and contribution to TemporAI, see:\r\n* \ud83d\udcd3 [Extending TemporAI tutorials](https://github.com/vanderschaarlab/temporai/tree/main/tutorials/extending/)\r\n* \ud83d\udcc3 [Contribution guide](https://github.com/vanderschaarlab/temporai/tree/main/CONTRIBUTING.md)\r\n* \ud83d\udc69\u200d\ud83d\udcbb [Developer's guide](https://github.com/vanderschaarlab/temporai/tree/main/docs/dev_guide.md)\r\n\r\n\r\n\r\n## \u270d\ufe0f Citing\r\n\r\nIf you use this code, please cite the associated paper:\r\n```\r\n@article{saveliev2023temporai,\r\n  title={TemporAI: Facilitating Machine Learning Innovation in Time Domain Tasks for Medicine},\r\n  author={Saveliev, Evgeny S and van der Schaar, Mihaela},\r\n  journal={arXiv preprint arXiv:2301.12260},\r\n  year={2023}\r\n}\r\n```\r\n",
    "bugtrack_url": null,
    "license": "Apache-2.0 license",
    "summary": "TemporAI: ML-centric Toolkit for Medical Time Series",
    "version": "0.0.3",
    "project_urls": {
        "Changelog": "https://github.com/vanderschaarlab/temporai/releases",
        "Documentation": "https://temporai.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/vanderschaarlab/temporai",
        "Source": "https://github.com/vanderschaarlab/temporai",
        "Tracker": "https://github.com/vanderschaarlab/temporai/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "64def58349da04815bfb0466a0b6330af4e2497c06c9a0ebdb7aa00eda00e2b8",
                "md5": "2d12b68a5552d3e85b32b0aaaba82430",
                "sha256": "f05f88fa44a40724e57c1d29101869ba7453aae7374048f39decde8a96876516"
            },
            "downloads": -1,
            "filename": "temporai-0.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2d12b68a5552d3e85b32b0aaaba82430",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 236555,
            "upload_time": "2023-12-07T23:05:06",
            "upload_time_iso_8601": "2023-12-07T23:05:06.258166Z",
            "url": "https://files.pythonhosted.org/packages/64/de/f58349da04815bfb0466a0b6330af4e2497c06c9a0ebdb7aa00eda00e2b8/temporai-0.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-07 23:05:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "vanderschaarlab",
    "github_project": "temporai",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "temporai"
}
        
Elapsed time: 0.15263s