dsipts.data_structure.utils module

dsipts.data_structure.utils.beauty_string(message, type, verbose)[source]
dsipts.data_structure.utils.extend_time_df(x, freq, group=None, global_minmax=False)[source]

Utility for generating a full dataset and then merge the real data

Parameters:
  • x (pd.DataFrame) – dataframe containing the column time

  • freq (str) – frequency (in pandas notation) of the resulting dataframe

  • group (string or None) – if not None the min max are computed by the group column, default None

  • global_minmax (bool) – if True the min_max is computed globally for each group. Usually used for stacked model

Returns:

a dataframe with the column time ranging from thr minumum of x to the maximum with frequency freq

Return type:

pd.DataFrame

class dsipts.data_structure.utils.MyDataset(data, t, groups, idx_target, idx_target_future)[source]

Bases: Dataset

Extension of Dataset class. While training the returned item is a batch containing the standard keys

Parameters:
  • data (dict) – a dictionary. Each key is a np.array containing the data. The keys are: y : the target variable(s) x_num_past: the numerical past variables x_num_future: the numerical future variables x_cat_past: the categorical past variables x_cat_future: the categorical future variables idx_target: index of target features in the past array

  • t (np.array) – the time array related to the target variables

  • idx_target (Union[np.array,None]) – you can specify the index in the past data that represent the input features (for differntial analysis or detrending strategies)

  • idx_target_future (Union[np.array,None]) – you can specify the index in the future data that represent the input features (for differntial analysis or detrending strategies)

Returns:

a torch Dataset to be used in a Dataloader

Return type:

torch.utils.data.Dataset

__init__(data, t, groups, idx_target, idx_target_future)[source]

Extension of Dataset class. While training the returned item is a batch containing the standard keys

Parameters:
  • data (dict) – a dictionary. Each key is a np.array containing the data. The keys are: y : the target variable(s) x_num_past: the numerical past variables x_num_future: the numerical future variables x_cat_past: the categorical past variables x_cat_future: the categorical future variables idx_target: index of target features in the past array

  • t (np.array) – the time array related to the target variables

  • idx_target (Union[np.array,None]) – you can specify the index in the past data that represent the input features (for differntial analysis or detrending strategies)

  • idx_target_future (Union[np.array,None]) – you can specify the index in the future data that represent the input features (for differntial analysis or detrending strategies)

Returns:

a torch Dataset to be used in a Dataloader

Return type:

torch.utils.data.Dataset