Implementation of the Jaccard Timespan Event Score
Project description
Implementation of the Jaccard Timespan Event Score (JTES)
This is a reference implementation of the Jaccard Timespan Event Score (JTES) described here.
Jaccard-Timespan-Event-Score (JTES) is a timespan score based on the Jaccard index also known as Intersection over Union (IoU).
This index is designed to score events that are defined by a timespan defined by two timestamps (t0, t1)
.
Score Goals:
- Score is in range
[0-1]
, where 0 is lowest and 1 best. - False-Positives and False-Negatives are equally bad
- If a true event spans over multiple predicted events, the result is averaged
- If the predicted event spans over multiple true events, the result is accounted accordingly
- If
len(y_true) == 0 and len(y_pred) > 0
,score = 0
- If
len(y_true) > 0 and len(y_pred) == 0
,score = 0
- If
ordered(y_true) == ordered(y_pred)
,score = 1
- Overlap in
y_true
is not allowed
Jaccard index in general is defined as |A ∩ B| / |A ∪ B|.
Install
The jtes package is available on pypi
pip install jtes
Install from source (alternative)
python setup.py install
Usage
The jaccard_timespan_event_score
function expects two numpy arrays y_true
and y_pred
.
The events are defined as np.datetime64 pairs.
import numpy as np
from jtes import jaccard_timespan_event_score
y_true = np.array([
(np.datetime64('1900-01-01T00:00:00'), np.datetime64('1900-01-01T01:00:00')),
(np.datetime64('1900-01-01T03:00:00'), np.datetime64('1900-01-01T04:00:00'))
])
y_pred = np.array([
(np.datetime64('1900-01-01T00:00:00'), np.datetime64('1900-01-01T01:00:00')),
(np.datetime64('1900-01-01T03:00:00'), np.datetime64('1900-01-01T05:00:00')),
])
# Returns 0.75
jaccard_timespan_event_score(y_true, y_pred)
License
MIT licensed as found in the LICENSE file.
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 Distributions
Built Distribution
File details
Details for the file jtes-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: jtes-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6435967906269a5298669354533c57f360781fdbb69e75e60d4e49c9775496ca |
|
MD5 | d50a9115c058011bb07b5bf54cbc02ab |
|
BLAKE2b-256 | 0bfe2a4cd8cc366bc47d0567fa597c6ce35cc3426ea90c60589ed5ad9c43edd6 |