GRAIL
A Python implementation of GRAIL, a generic framework to learn compact time series representations.
Requirements
- Python 3.6+
numpyscipytslearn
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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| grailts-0.1.0.tar.gz | 18.5 kB | Without provenance | Details for grailts-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| grailts-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for grailts-0.1.0-py3-none-any.whl |
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
|
Security for grailts 0.1.0
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.