Classifier
ConvTimeNetClassifier
ConvTimeNet for time series classification.
Quickstart
python
from sktime.classification.deep_learning.convtimenet import ConvTimeNetClassifier
estimator = ConvTimeNetClassifier(d_model, patch_size, patch_stride, dropout=0, d_ff=128, dw_ks=3, device='cpu', num_epochs=16, batch_size=8, criterion=None, criterion_kwargs=None, optimizer=None, optimizer_kwargs=None, lr=0.001, verbose=False, random_state=None)Parameters(16)
- d_modelint
- Hidden dimension size for model processing.
- patch_sizeint
- Size of patches for sequence splitting.
- patch_strideint
- Stride length for patch creation.
- dropoutfloat, optional (default=0)
- Dropout rate to apply to layers.
- d_ffint, optional (default=128)
- Dimension of feedforward network.
- dw_ksint or list, optional (default=3)
- Depthwise convolution kernel size(s). Can be a single int or list of ints.
- devicestr, optional (default=”cpu”)
- Device to use for computation (“cpu” or “cuda”).
- num_epochsint, optional (default=16)
- The number of epochs to train the model.
- batch_sizeint, optional (default=8)
- The size of each mini-batch during training.
- criterioncallable, optional (default=None)
- The loss function to use. If None, CrossEntropyLoss will be used.
- criterion_kwargsdict, optional (default=None)
- Additional keyword arguments to pass to the loss function.
- optimizerstr, optional (default=None)
- The optimizer to use. If None, Adam will be used.
- optimizer_kwargsdict, optional (default=None)
- Additional keyword arguments to pass to the optimizer.
- lrfloat, optional (default=0.001)
- The learning rate to use for the optimizer.
- verbosebool, optional (default=False)
- Whether to print progress information during training.
- random_stateint, optional (default=None)
- Seed to ensure reproducibility.
Examples
>>> from sktime.classification.deep_learning import ConvTimeNetClassifier
>>> import numpy as np
>>> # Create a sample multivariate time series dataset
>>> # 48 samples, 3 variables, length 128
>>> X = np. random. randn (16 * 3, 3, 128). astype ("float32")
>>> y = np. array ([0, 1, 2 ] * 16) # 3 classes
>>> # Create and fit the classifier
>>> clf = ConvTimeNetClassifier (
... patch_size = 4,
... patch_stride = 2,
... d_model = 64,
... d_ff = 128,
... dw_ks = [5, 7, 9 ],
... batch_size = 8,
... device = "cpu",
... random_state = 10
... )
>>> clf. fit (X, y) ConvTimeNetClassifier(
... )
>>> # Make predictions
>>> y_pred = clf. predict (X)
>>> y_proba = clf. predict_proba (X)References
- [1 ] Cheng, M., Yang, J., Pan, T., Liu, Q., & Li, Z. (2024). ConvTimeNet: A deep hierarchical fully convolutional model for multivariate time series analysis. arXiv preprint arXiv:2403.01493. https://arxiv.org/abs/2403.01493 [2 ] https://github.com/Mingyue-Cheng/ConvTimeNet