A package for evaluating clinical time series predictions
Project description
Clinical Time Series Evaluation (CTSEval)
CTSEval is a Python package for evaluating clinical time series predictions. It provides a set of metrics to assess the performance of time series prediction models, with a focus on clinical settings. (TODO: Link DOI)
Installation
You can install CTSEval using pip:
pip install ctseval
Usage
To use CTSEval in your project, follow these steps:
- Import the package:
import ctseval
- The ctseval.compute_metrics function requires a list of trajectories. A trajectory is a dictionary with the following keys:
predicted_times: A list of predicted times.predicted_risks: A list of predicted risks.event_occurred: Whether the event occurred.event_time: The time the event occurred.
The package contains a helper function to convert a pandas dataframe to a list of trajectories.
If your dataset has the following structure:
| episode_id | event_occurred | event_time | predicted_times | predicted_risks |
| ---------- | -------------- | ---------- | --------------- | --------------- |
| 1 | True | 10.0 | 1 | 0.1 |
| 1 | True | 10.0 | 2 | 0.2 |
| 2 | False | 0.0 | 1 | 0.15 |
| 2 | False | 0.0 | 2 | 0.25 |
| 2 | False | 0.0 | 3 | 0.35 |
Then you can convert it to a compatible trajectory list:
trajectories = ctseval.convert_df_to_trajectory_list(df, 'episode_id', 'event_occurred', 'event_time', 'predicted_times', 'predicted_risks')
- Use the
compute_metricsfunction to evaluate your predictions:
metrics = ctseval.compute_metrics(trajectories, snooze_window, detection_window)
Running with a snooze window of 0 will automatically route the function to an efficient implementation which will run fast. However, if snoozing is required, note that the implementation is slow (O(N^2)), as we describe. In the future, intermediate updates will help to estimate the total runtime (TODO).
- Using the output, you can calculate metrics such as AUROC, AUPRC, etc. and provide the points on the ROC curve, precision-recall curve to plot etc. similar to the
sklearnapi.
# Calculate scores
ctseval.auroc_score(metrics)
ctseval.auprc_score(metrics)
# Get points on the curves
ctseval.roc_curve(metrics)
ctseval.precision_recall_curve(metrics)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ctseval-0.1.0.tar.gz.
File metadata
- Download URL: ctseval-0.1.0.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0203405829975a3f4c0bef7ccd71049dde8699a1aaa232725ae207c087808c2
|
|
| MD5 |
db64951c8a691f7a74aa742b2bec7f45
|
|
| BLAKE2b-256 |
361411b9d7217debbf60d40299da9239d0e95c43a41b6dbc1f80629219053dfc
|
File details
Details for the file ctseval-0.1.0-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: ctseval-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 22.2 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f245c8336ef6bf0db8494ca28345c040625af2a213c4b92771a7a1205360a6e7
|
|
| MD5 |
d61d8b6ade30e1f71f8f17e54d20096e
|
|
| BLAKE2b-256 |
7bf2301a0fae42ac6c91df58c00c3b0fbdd23aeb4f9b78114c9586e718dc2385
|