Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/angus924/hydra

HYDRA: Competing convolutional kernels for fast and accurate time series classification
https://github.com/angus924/hydra

convolution dictionary rocket scalable time-series-classification

Last synced: 4 months ago
JSON representation

HYDRA: Competing convolutional kernels for fast and accurate time series classification

Awesome Lists containing this project

README

        

[`ROCKET`](https://github.com/angus924/rocket) · [`MINIROCKET`](https://github.com/angus924/minirocket) · [**`HYDRA`**](https://github.com/angus924/hydra)

# HYDRA

***HYDRA: Competing convolutional kernels for fast and accurate time series classification***

[Data Mining and Knowledge Discovery](https://doi.org/10.1007/s10618-023-00939-3) / [arXiv:2203.13652](https://arxiv.org/abs/2203.13652) (preprint)

>

We demonstrate a simple connection between dictionary methods for time series classification, which involve extracting and counting symbolic patterns in time series, and methods based on transforming input time series using convolutional kernels, namely ROCKET and its variants. We show that by adjusting a single hyperparameter it is possible to move by degrees between models resembling dictionary methods and models resembling ROCKET. We present HYDRA, a simple, fast, and accurate dictionary method for time series classification using competing convolutional kernels, combining key aspects of both ROCKET and conventional dictionary methods. HYDRA is faster and more accurate than the most accurate existing dictionary methods, and can be combined with ROCKET and its variants to further improve the accuracy of these methods.

Please cite as:

```bibtex
@article{dempster_etal_2023,
author = {Dempster, Angus and Schmidt, Daniel F and Webb, Geoffrey I},
title = {Hydra: Competing Convolutional Kernels for Fast and Accurate Time Series Classification},
year = {2023},
journal = {Data Mining and Knowledge Discovery},
volume = {37},
pages = {1779--1805},
}
```

## Results

#### UCR Archive (112 Datasets, 30 Resamples)

* [Hydra](./results/results_ucr112_hydra.csv)
* [Hydra+MiniRocket, Hydra+MultiRocket, Hydra+Rocket](./results/results_ucr112_variants.csv)

## Requirements

* Python
* PyTorch
* NumPy
* scikit-learn (or similar)

## Code

### [`hydra.py`](./code/hydra.py)
### [`hydra_multivariate.py`](./code/hydra_multivariate.py)†
### [`softmax.py`](./code/softmax.py)\*

† *experimental*
\* *Hydra + SGD for larger datasets (i.e., more than approx. 10,000 training examples)*

## Examples

```python
from hydra import Hydra, SparseScaler
from sklearn.linear_model import RidgeClassifierCV

[...] # load data (torch.FloatTensor, shape = (num_examples, 1, length))

transform = Hydra(X_training.shape[-1])

X_training_transform = transform(X_training)
X_test_transform = transform(X_test)

scaler = SparseScaler()

X_training_transform = scaler.fit_transform(X_training_transform)
X_test_transform = scaler.transform(X_test_transform)

classifier = RidgeClassifierCV(alphas = np.logspace(-3, 3, 10))
classifier.fit(X_training_transform, Y_training)

predictions = classifier.predict(X_test_transform)
```

## Acknowledgements

We thank Professor Eamonn Keogh and all the people who have contributed to the UCR time series classification archive. Figures in our paper showing mean ranks were produced using code from [Ismail Fawaz et al. (2019)](https://github.com/hfawaz/cd-diagram).

:dragon_face: