dsipts.data_structure.modifiers module

class dsipts.data_structure.modifiers.VVADataset(x, y, y_orig, t, length_in, length_out, num_digits)[source]

Bases: Dataset

__init__(x, y, y_orig, t, length_in, length_out, num_digits)[source]
__len__()[source]
__getitem__(idx)[source]
class dsipts.data_structure.modifiers.Modifier(**kwargs)[source]

Bases: ABC

In the constructor you can store some parameters of the modifier. It will be saved when the timeseries is saved.

__init__(**kwargs)[source]

In the constructor you can store some parameters of the modifier. It will be saved when the timeseries is saved.

abstractmethod fit_transform(train, val)[source]

This funtion is called before the training procedure and it should tasnform the standard Dataset into the new Dataset

Parameters:
  • train (MyDataset) – initial train Dataset

  • val (MyDataset) – initial validation Dataset

Returns:

transformed train and validation Datasets

Return type:

Dataset, Dataset

abstractmethod transform(test)[source]

Similar to fit_transform but only transformation task will be performed, it is used in the inference function before calling the inference method :param test: initial test Dataset :type test: MyDataset

Returns:

transformed test Dataset

Return type:

Dataset

abstractmethod inverse_transform(res, real)[source]

The results must be reverted respect to the prediction task

Parameters:
  • res (np.array) – raw prediction

  • real (np.array) – raw real data

Returns:

inverse transfrmation of the predictions and the real data

Return type:

[np.array, np.array]

class dsipts.data_structure.modifiers.ModifierVVA(**kwargs)[source]

Bases: Modifier

This modifiers is used for the custom model VVA. The initial data are divided in smaller segments and then tokenized using a clustering procedure (fit_trasform). The centroids of the clusters are stored. A GPT model is then trained on the tokens an the predictions are reverted using the centroid information.

In the constructor you can store some parameters of the modifier. It will be saved when the timeseries is saved.

fit_transform(train, val)[source]

BisectingKMeans is used on segments of length token_split

Parameters:
  • train (MyDataset) – initial train Dataset

  • val (MyDataset) – initial validation Dataset

Returns:

transformed train and validation Datasets

Return type:

Dataset, Dataset

transform(test)[source]

Similar to fit_transform but only transformation task will be performed :param test: test val Dataset :type test: MyDataset

Returns:

transformed test Dataset

Return type:

Dataset

inverse_transform(res, real)[source]

The results must be reverted respect to the prediction task

Parameters:

res (np.array) – raw prediction

Returns:

inverse transofrmation of the predictions

Return type:

np.array