Skip to main content

Wasserstein Time Series Kernel

Installation

The easiest way is to install WTK from the Python Package Index (PyPI) via

$ pip install wtk

Usage

The package provides functions to transform a set of n training time series and o test time series into an n x n distance matrix for training and an o x n distance matrix for testing. Additionally, we provide a way to run a grid search for a krein space SVM. krein_svm_grid_search runs a 5-fold cross-validation on the training set to determine the best hyperparameters. Then, its classification accuracy is computed on the test set.

from wtk import transform_to_dist_matrix
from wtk.utilities import get_ucr_dataset, krein_svm_grid_search

# Read UCR data
X_train, y_train, X_test, y_test = get_ucr_dataset('../data/UCR/raw_data/', 'DistalPhalanxTW')

# Compute wasserstein distance matrices with subsequent length k=10
D_train, D_test = transform_to_dist_matrix(X_train, X_test, 10)

# Run the grid search
svm_clf = krein_svm_grid_search(D_train, D_test, y_train, y_test)

Alternatively, you can get the kernel matrices computed from the distance matrices and train your own classifier.

from sklearn.svm import SVC
from wtk import get_kernel_matrix
from sklearn.metrics import accuracy_score

# Get the kernel matrices
K_train = get_kernel_matrix(D_train, psd=True, gamma=0.2)
K_test = get_kernel_matrix(D_test, psd=False, gamma=0.2)

# Train your classifier
clf = SVC(C=5, kernel='precomputed')
clf.fit(K_train, y_train)

y_pred = clf.predict(K_test)
print(accuracy_score(y_test, y_pred))

Help

If you have questions concerning WTK or you encounter problems when trying to build the tool under your own system, please open an issue in the issue tracker. Try to describe the issue in sufficient detail in order to make it possible for us to help you.

Contributors

WTK is developed and maintained by members of the Machine Learning and Computational Biology Lab of Prof. Dr. Karsten Borgwardt:

Metadata

Release files for wtk 0.2.1.3

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

Source distribution (sdist)

Source distribution for wtk 0.2.1.3
File Size Uploaded Provenance Actions
wtk-0.2.1.3.tar.gz 6.5 kB Without provenance Details for wtk-0.2.1.3.tar.gz

Built distribution (wheel)

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

Total release size: 24.8 kB

Release files / wtk-0.2.1.3.tar.gz

Download URL wtk-0.2.1.3.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f5314ed315fd97d1de2ac05f995364971a73e65b878faec5deaabe8484d2ebb6
BLAKE2b-256 checksum
How to use checksums
54b93f7c48e8a621a2ce79125e070fdfd30cd8de42882fe4b230356a9346e190
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.22.0

Release files / wtk-0.2.1.3-py3-none-any.whl

Download URL wtk-0.2.1.3-py3-none-any.whl
Size 18.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8b73ea9154f3be39734518b766642fdae3e0b273a86eb0298e2eee0f28d1d72f
BLAKE2b-256 checksum
How to use checksums
28857043dde5f14f8c9080767839d6f4a521907f24b6f05e5d01d2e1320fa231
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.22.0

Security for wtk 0.2.1.3

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.

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