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_trueis 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.
Metadata
Release files for jtes 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jtes-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for jtes-1.0.1-py3-none-any.whl |
Release files / jtes-1.0.1-py3-none-any.whl
| Download URL | jtes-1.0.1-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6435967906269a5298669354533c57f360781fdbb69e75e60d4e49c9775496ca
|
|
BLAKE2b-256 checksum How to use checksums |
0bfe2a4cd8cc366bc47d0567fa597c6ce35cc3426ea90c60589ed5ad9c43edd6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for jtes 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.