qumphy.models.minirocket module
File: qumphy/models/minrocket.py Project: 22HLT01 QUMPHY Contact: oskar.pfeffer@ptb.de Gitlab: https://gitlab.com/qumphy Description: MiniRocKeT implementation as from […].
- class qumphy.models.minirocket.MiniRocket(*args: Any, **kwargs: Any)[source]
Bases:
ModuleMiniRocket model with feature extractor and prediction head.
- class qumphy.models.minirocket.MiniRocketFeatures(*args: Any, **kwargs: Any)[source]
Bases:
ModuleThis is a Pytorch implementation of MiniRocket developed by Malcolm McLean and Ignacio Oguiza This module extracts MiniRocket features from time-series data using fixed convolutional kernels, multiple dilations, and proportion of positive values features.
MiniRocket paper citation: @article{dempster_etal_2020,
author = {Dempster, Angus and Schmidt, Daniel F and Webb, Geoffrey I}, title = {{MINIROCKET}: A Very Fast (Almost) Deterministic Transform for Time Series Classification}, year = {2020}, journal = {arXiv:2012.08791}
} Original paper: https://arxiv.org/abs/2012.08791 Original code: https://github.com/angus924/minirocket
- extract_features(data)[source]
Extract MiniRocket features from input data.
- Parameters:
data (torch.Tensor) – Input data of shape (batch_size, seq_len) or (batch_size, c_in, seq_len).
- Returns:
Extracted MiniRocket features.
- Return type:
torch.Tensor
- fitting = False
- forward(x)[source]
Extract MiniRocket features from an input tensor.
- Parameters:
x (torch.Tensor) – Input tensor of shape (batch_size, c_in, seq_len).
- Returns:
Extracted MiniRocket features of shape (batch_size, num_features).
- Return type:
torch.Tensor
- get_quantiles(num_quantiles)[source]
Calculate quantile values using the golden ratio.
- Parameters:
num_quantiles (int) – Number of quantile values to calculate.
- Returns:
List containing the calculated quantile values.
- Return type:
list
- kernel_size = 9
- num_kernels = 84
- qumphy.models.minirocket.get_minirocket_features(o, model, chunksize=1024, use_cuda=None, to_np=True)[source]
Extract MiniRocket features from a large dataset in chunks.
- Parameters:
o (np.ndarray or torch.Tensor) – Input dataset.
model (nn.Module) – MiniRocket feature extraction model.
chunksize (int) – Number of samples processed in each chunk.
use_cuda (bool) – If True, use CUDA. If False, use CPU. If None, CUDA is used when available.
to_np (bool) – If True, return the features as a NumPy array. If False, return them as a torch.Tensor.
- Returns:
Extracted MiniRocket features.
- Return type:
np.ndarray or torch.Tensor