MVTSTransformerClassifierSKTimeWrapper
Python template · sinapsis_sktime.templates.sktime_classifiers
Overview
Template for SkTime classification model training and inference for the deep_learning module.
MVTSTransformerClassifier — inherited documentation
Multivariate Time Series Transformer for Classification, as described in [1]_.
This classifier has been wrapped around the official pytorch implementation of Transformer from [2]_, provided by the authors of the paper [1]_.
References ---------- .. [1] George Zerveas, Srideepika Jayaraman, Dhaval Patel, Anuradha Bhamidipaty, and Carsten Eickhoff. 2021. A Transformer-based Framework for Multivariate Time Series Representation Learning. In Proceedings of the 27th ACM SIGKDD Conference on Knowledge Discovery & Data Mining (KDD '21). Association for Computing Machinery, New York, NY, USA, 2114-2124. https://doi.org/10.1145/3447548.3467401. .. [2] https://github.com/gzerveas/mvts_transformer
Parameters ---------- d_model : int, optional (default=256) The number of expected features in the input (i.e., the dimension of the model). n_heads : int, optional (default=4) The number of heads in the multihead attention mechanism. num_layers : int, optional (default=4) The number of layers (or blocks) in the transformer encoder. dim_feedforward : int, optional (default=128) The dimension of the feedforward network model. dropout : float, optional (default=0.1) The dropout rate to apply. pos_encoding : str, optional (default="fixed") The type of positional encoding to use. Options: ["fixed", "learnable"]. activation : str, optional (default="relu") The activation function to use. Options: ["relu", "gelu"]. norm : str, optional (default="BatchNorm") The type of normalization to use. Options: ["BatchNorm", "LayerNorm"]. freeze : bool, optional (default=False) If True, the transformer layers will be frozen and not trained. num_epochs : int, optional (default=10) The number of epochs to train the model. batch_size : int, optional (default=8) The size of each mini-batch during training. criterion : callable, optional (default=None) The loss function to use. If None, CrossEntropyLoss will be used. criterion_kwargs : dict, optional (default=None) Additional keyword arguments to pass to the loss function. optimizer : str, optional (default=None) The optimizer to use. If None, Adam optimizer will be used. optimizer_kwargs : dict, optional (default=None) Additional keyword arguments to pass to the optimizer. lr : float, optional (default=0.001) The learning rate for the optimizer. verbose : bool, optional (default=True) If True, prints progress messages during training. random_state : int or None, optional (default=None) Seed for the random number generator.
Examples -------- >>> from sktime.datasets import load_unit_test >>> from sktime.classification.deep_learning import MVTSTransformerClassifier >>> >>> X_train, y_train = load_unit_test(split="train") >>> X_test, _ = load_unit_test(split="test") >>> >>> model = MVTSTransformerClassifier() >>> model.fit(X_train, y_train) # doctest: +SKIP >>> preds = model.predict(X_test) # doctest: +SKIP
Capabilities
Capabilities: not setInstallation
Install the published package using pip or uv.
pip install sinapsis-sktime==1.0.0uv pip install sinapsis-sktime==1.0.0uv add sinapsis-sktime==1.0.0Configuration
Effective fields from the inspector schema, including nested Pydantic model fields.
Optional
Default: null
Optional
Default: "/sinapsis-hub/private/platform/sinapsis-hub/playground/publish"
Path where the trained model will be saved. mvtstransformerclassifier_init d_model <class 'int'>: default: 256 n_heads <class 'int'>: default: 4 num_layers <class 'int'>: default: 4 dim_feedforward <class 'int'>:… Read full field description
Path where the trained model will be saved. mvtstransformerclassifier_init d_model <class 'int'>: default: 256 n_heads <class 'int'>: default: 4 num_layers <class 'int'>: default: 4 dim_feedforward <class 'int'>: default: 128 dropout <class 'float'>: default: 0.1 pos_encoding <class 'str'>: default: fixed activation <class 'str'>: default: relu norm <class 'str'>: default: BatchNorm freeze <class 'bool'>: default: False num_epochs <class 'int'>: default: 10 batch_size <class 'int'>: default: 8 criterion <class 'NoneType'>: default: None criterion_kwargs typing.Optional[dict]: default: None optimizer typing.Optional[str]: default: None optimizer_kwargs typing.Optional[dict]: default: None lr <class 'float'>: default: 0.001 verbose <class 'bool'>: default: True random_state typing.Optional[int]: default: None
Required
Default: null
Required
Default: null
Optional
Default: 0.001
Optional
Default: "BatchNorm"
Optional
Default: false
Optional
Default: 256
Optional
Default: 0.1
Optional
Default: 4
Optional
Default: true
Optional
Default: null
Optional
Default: null
Optional
Default: "relu"
Optional
Default: 8
Optional
Default: 10
Optional
Default: 4
Optional
Default: "fixed"
Optional
Default: null
Optional
Default: 128
Optional
Default: null
Optional
Default: null
Configuration example
Generated from documented defaults. Replace any placeholders and complete required nested settings before running.
templates:
- template_name: "MVTSTransformerClassifierSKTimeWrapper"
class_name: "MVTSTransformerClassifierSKTimeWrapper"
attributes:
root_dir: "/sinapsis-hub/private/platform/sinapsis-hub/playground/publish"
model_save_path: "<required>"
mvtstransformerclassifier_init:
lr: 0.001
norm: "BatchNorm"
freeze: false
d_model: 256
dropout: 0.1
n_heads: 4
verbose: true
criterion: null
optimizer: null
activation: "relu"
batch_size: 8
num_epochs: 10
num_layers: 4
pos_encoding: "fixed"
random_state: null
dim_feedforward: 128
criterion_kwargs: null
optimizer_kwargs: null
Inheritance
sinapsis_sktime.templates.sktime_classifiers.SKTimeDeepLearningClassifiersEnvironment variables
Environment definitions belong to their canonical Python modules.