Docs /Templates/ sinapsis-sktime

TemporalDictionaryEnsembleSKTimeWrapper

sinapsis-sktimeSKTimedynamicinferencemodelsprediction

Python template · sinapsis_sktime.templates.sktime_classifiers

Overview

Template for SkTime classification model training and inference for the dictionary_based module.

TemporalDictionaryEnsemble — inherited documentation

Temporal Dictionary Ensemble (TDE).

Implementation of the dictionary based Temporal Dictionary Ensemble as described in [1]_.

Overview: Input "n" series length "m" with "d" dimensions TDE searches "k" parameter values selected using a Gaussian processes regressor, evaluating each with a LOOCV. It then retains "s" ensemble members. There are six primary parameters for individual classifiers:

- alpha: alphabet size - w: window length - l: word length - p: normalise/no normalise - h: levels - b: MCB/IGB

For any combination, an individual TDE classifier slides a window of length w along the series. The w length window is shortened to an l length word through taking a Fourier transform and keeping the first l/2 complex coefficients. These lcoefficients are then discretised into alpha possible values, to form a word length l using breakpoints found using b. A histogram of words for each series is formed and stored, using a spatial pyramid of h levels. For multivariate series, accuracy from a reduced histogram is used to select dimensions.

fit involves finding n histograms. predict uses 1 nearest neighbour with a the histogram intersection distance function.

Parameters ---------- n_parameter_samples : int, default=250 Number of parameter combinations to consider for the final ensemble. max_ensemble_size : int, default=50 Maximum number of estimators in the ensemble. max_win_len_prop : float, default=1 Maximum window length as a proportion of series length, must be between 0 and 1. min_window : int, default=10 Minimum window length. randomly_selected_params: int, default=50 Number of parameters randomly selected before the Gaussian process parameter selection is used. bigrams : boolean or None, default=None Whether to use bigrams, defaults to true for univariate data and false for multivariate data. dim_threshold : float, default=0.85 Dimension accuracy threshold for multivariate data, must be between 0 and 1. max_dims : int, default=20 Max number of dimensions per classifier for multivariate data. time_limit_in_minutes : int, default=0 Time contract to limit build time in minutes, overriding n_parameter_samples. Default of 0 means n_parameter_samples is used. contract_max_n_parameter_samples : int, default=np.inf Max number of parameter combinations to consider when time_limit_in_minutes is set. typed_dict : bool, default=True Use a numba typed Dict to store word counts. May increase memory usage, but will be faster for larger datasets. As the Dict cannot be pickled currently, there will be some overhead converting it to a python dict with multiple threads and pickling. save_train_predictions : bool, default=False Save the ensemble member train predictions in fit for use in _get_train_probs leave-one-out cross-validation. n_jobs : int, default=1 The number of jobs to run in parallel for both ``fit`` and ``predict``. ``-1`` means using all processors. random_state : int or None, default=None Seed for random number generation.

Attributes ---------- n_classes_ : int The number of classes. classes_ : list The classes labels. n_instances_ : int The number of train cases. n_dims_ : int The number of dimensions per case. series_length_ : int The length of each series. n_estimators_ : int The final number of classifiers used (<= max_ensemble_size) estimators_ : list of shape (n_estimators) of IndividualTDE The collections of estimators trained in fit. weights_ : list of shape (n_estimators) of float Weight of each estimator in the ensemble.

See Also -------- IndividualTDE, ContractableBOSS

Notes ----- For the Java version, see `TSML <https://github.com/uea-machine-learning/tsml/blob/master/src/main/java/ tsml/classifiers/dictionary_based/TDE.java>`_.

References ---------- .. [1] Matthew Middlehurst, James Large, Gavin Cawley and Anthony Bagnall "The Temporal Dictionary Ensemble (TDE) Classifier for Time Series Classification", in proceedings of the European Conference on Machine Learning and Principles and Practice of Knowledge Discovery in Databases, 2020.

Examples -------- >>> from sktime.classification.dictionary_based import TemporalDictionaryEnsemble >>> from sktime.datasets import load_unit_test >>> X_train, y_train = load_unit_test(split="train", return_X_y=True) >>> X_test, y_test = load_unit_test(split="test", return_X_y=True) # doctest: +SKIP >>> clf = TemporalDictionaryEnsemble( ... n_parameter_samples=10, ... max_ensemble_size=3, ... randomly_selected_params=5, ... ) # doctest: +SKIP >>> clf.fit(X_train, y_train) # doctest: +SKIP TemporalDictionaryEnsemble(...) >>> y_pred = clf.predict(X_test) # doctest: +SKIP

Capabilities

Capabilities: not set

Installation

Install the published package using pip or uv.

Terminalbash
pip install sinapsis-sktime==1.0.0
uv pip install sinapsis-sktime==1.0.0
uv add sinapsis-sktime==1.0.0

Configuration

Effective fields from the inspector schema, including nested Pydantic model fields.

metadata
sinapsis_core.template_base.base_models.TemplateMetadata | None
Optional
Default: null
root_dir
str
Optional
Default: "/sinapsis-hub/private/platform/sinapsis-hub/playground/publish"
model_save_pathRequired
Path where the trained model will be saved. temporaldictionaryensemble_init n_parameter_samples <class 'int'>: default: 250 max_ensemble_size <class 'int'>: default: 50 max_win_len_prop typing.Optional[float]: default:… Read full field description

Path where the trained model will be saved. temporaldictionaryensemble_init n_parameter_samples <class 'int'>: default: 250 max_ensemble_size <class 'int'>: default: 50 max_win_len_prop typing.Optional[float]: default: 1 min_window <class 'int'>: default: 10 randomly_selected_params <class 'int'>: default: 50 bigrams <class 'NoneType'>: default: None dim_threshold <class 'float'>: default: 0.85 max_dims <class 'int'>: default: 20 time_limit_in_minutes typing.Optional[int]: default: 0.0 contract_max_n_parameter_samplestyping.Optional[int]: default: inf typed_dict <class 'bool'>: default: True save_train_predictions <class 'bool'>: default: False n_jobs <class 'int'>: default: 1 random_state typing.Optional[int]: default: None

str
Required
Default: null
temporaldictionaryensemble_initRequired
TemporalDictionaryEnsembleAttributes
Required
Default: null
n_jobs
int
Optional
Default: 1
bigrams
NoneType
Optional
Default: null
max_dims
int
Optional
Default: 20
min_window
int
Optional
Default: 10
typed_dict
bool
Optional
Default: true
random_state
typing.Optional[int]
Optional
Default: null
dim_threshold
float
Optional
Default: 0.85
max_win_len_prop
typing.Optional[float]
Optional
Default: 1
max_ensemble_size
int
Optional
Default: 50
n_parameter_samples
int
Optional
Default: 250
time_limit_in_minutes
typing.Optional[int]
Optional
Default: 0
save_train_predictions
bool
Optional
Default: false
randomly_selected_params
int
Optional
Default: 50
contract_max_n_parameter_samples
typing.Optional[int]
Optional
Default: null

Configuration example

Generated from documented defaults. Replace any placeholders and complete required nested settings before running.

yaml
templates:
  - template_name: "TemporalDictionaryEnsembleSKTimeWrapper"
    class_name: "TemporalDictionaryEnsembleSKTimeWrapper"
    attributes:
      root_dir: "/sinapsis-hub/private/platform/sinapsis-hub/playground/publish"
      model_save_path: "<required>"
      temporaldictionaryensemble_init:
        n_jobs: 1
        bigrams: null
        max_dims: 20
        min_window: 10
        typed_dict: true
        random_state: null
        dim_threshold: 0.85
        max_win_len_prop: 1
        max_ensemble_size: 50
        n_parameter_samples: 250
        time_limit_in_minutes: 0
        save_train_predictions: false
        randomly_selected_params: 50
        contract_max_n_parameter_samples: null

Inheritance

Immediate parent: sinapsis_sktime.templates.sktime_classifiers.SKTimeDictionaryClassifiers

Environment variables

Environment definitions belong to their canonical Python modules.

SINAPSIS_BUILD_DOCS · defined elsewhere