Skip to main content

GRAIL

A Python implementation of GRAIL, a generic framework to learn compact time series representations.

Requirements

  • Python 3.6+
  • numpy
  • scipy
  • tslearn

Installation

Installation using pip:

pip install grailts

To install from the source:

python setup.py install

Main Contributors

Karhan Kayan (karhan@uchicago.edu)

Usage

Full Example

Here is an example where we load a UCR dataset and run approximate k-nearest neighbors on its GRAIL representations:

from GRAIL.TimeSeries import TimeSeries
from GRAIL.Representation import GRAIL
from GRAIL.kNN import kNN

TRAIN, train_labels = TimeSeries.load("ECG200_TRAIN", "UCR")
TEST, test_labels = TimeSeries.load("ECG200_TEST", "UCR")

representation = GRAIL(kernel="SINK", d = 100, gamma = 5)
repTRAIN, repTEST = representation.get_rep_train_test(TRAIN, TEST, exact=True)
neighbors, _, _ = kNN(repTRAIN, repTEST, method="ED", k=5, representation=None,
                              pq_method='opq')

print(neighbors)

Loading Datasets

To load UCR type datasets:

TRAIN, train_labels = TimeSeries.load("ECG200_TRAIN", "UCR")
TEST, test_labels = TimeSeries.load("ECG200_TEST", "UCR")

In this package, we assume that each row of the datasets is a time series.

Fetch GRAIL Representations

To fetch exact GRAIL representations of a training and a test dataset:

representation = GRAIL(kernel="SINK", d = 100, gamma = 5)
repTRAIN, repTEST = representation.get_rep_train_test(TRAIN, TEST, exact=True)

Here d specifies the number of landmark series, and gamma specifies the hyperparameter used for the SINK kernel. If gamma is not specified, it will be tuned by the algorithm.

If a single dataset is used instead:

repX = representation.get_representation(X)

Get Approximate k-Nearest-Neighbors

To get the approximate k-Nearest-Neighbors of TEST in TRAIN use:

neighbors, correlations, return_time = kNN(repTRAIN, repTEST, method="ED", k=5, representation=None,
                              pq_method='opq')

Note that Euclidean Distance in the GRAIL representation space estimates the SINK correlation in the original space.

Metadata

Release files for grailts 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for grailts 0.1.0
File Size Uploaded
grailts-0.1.0.tar.gz 18.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for grailts 0.1.0
File Interpreter ABI Platform
grailts-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 40.1 kB

Release files / grailts-0.1.0.tar.gz

Download URL grailts-0.1.0.tar.gz
Size 18.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d8c5c831b9fd2b28bccf5ebf98fbce55cacba6615df41f398d69fe1dbe774ef8
BLAKE2b-256 checksum
How to use checksums
50c6a46c9ec0580ab65b98a73f5b9851b6443c3fc06dbae7cad13ee5f8fc7b63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

Release files / grailts-0.1.0-py3-none-any.whl

Download URL grailts-0.1.0-py3-none-any.whl
Size 21.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cfef2626dfd8ac6077348a42002a8c09989981791f10c10b20a9c3ec24f8546d
BLAKE2b-256 checksum
How to use checksums
25fe2354bd3059c8469d7a827ba9ca7943b8a083fda7d4ae597621a4bd192f4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page