Skip to main content

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:

  1. Import the package:
import ctseval
  1. 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')

  1. Use the compute_metrics function 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).

  1. 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 sklearn api.
# 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ctseval-0.1.0.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ctseval-0.1.0-cp39-cp39-macosx_11_0_arm64.whl (22.2 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

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

Hashes for ctseval-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c0203405829975a3f4c0bef7ccd71049dde8699a1aaa232725ae207c087808c2
MD5 db64951c8a691f7a74aa742b2bec7f45
BLAKE2b-256 361411b9d7217debbf60d40299da9239d0e95c43a41b6dbc1f80629219053dfc

See more details on using hashes here.

File details

Details for the file ctseval-0.1.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ctseval-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f245c8336ef6bf0db8494ca28345c040625af2a213c4b92771a7a1205360a6e7
MD5 d61d8b6ade30e1f71f8f17e54d20096e
BLAKE2b-256 7bf2301a0fae42ac6c91df58c00c3b0fbdd23aeb4f9b78114c9586e718dc2385

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page