timesead.data.statistics

Functions

get_data_all(→ torch.Tensor)

Extract data matrix from dataset.

compute_whiten_matrix(→ torch.Tensor)

Compute whiten matrix of dataset.

compute_feature_statistics(...)

Compute statistics of each feature.

compute_feature_mean_std(...)

Compute the mean and standard deviation of each feature.

compute_ts_statisitcs(→ Tuple[Optional[torch.Tensor], ...)

training_means(dataset)

compute_anomaly_positions(→ List[int])

Computes the positions of anomalies in the dataset.

compute_anomaly_lengths(→ List[int])

Computes the length of each anomalous window in the dataset.

compute_total_time_steps(→ int)

Compute the total amount of time steps in the dataset (normal + anormal)

Module Contents

timesead.data.statistics.get_data_all(dataset: torch.utils.data.Dataset, take_fd: bool = False) torch.Tensor

Extract data matrix from dataset.

Parameters:
  • dataset (torch.utils.data.Dataset take_id: bool) – Time-series dataset. take_fd: flag, to take first differences.

  • take_fd (bool)

Returns:

data matrix

Return type:

torch.Tensor

timesead.data.statistics.compute_whiten_matrix(dataset: torch.utils.data.Dataset, take_fd: bool = False) torch.Tensor

Compute whiten matrix of dataset.

Parameters:
Returns:

whiten matrix

Return type:

torch.Tensor

timesead.data.statistics.compute_feature_statistics(dataset: torch.utils.data.Dataset, take_fd: bool = False) Tuple[torch.Tensor | None, torch.Tensor | None, torch.Tensor | None, torch.Tensor | None, torch.Tensor, torch.Tensor]

Compute statistics of each feature.

Parameters:
Returns:

Normal mean, normal std, anomaly mean, anomaly std, minimum, and maximum

Return type:

Tuple[Optional[torch.Tensor], Optional[torch.Tensor], Optional[torch.Tensor], Optional[torch.Tensor], torch.Tensor, torch.Tensor]

timesead.data.statistics.compute_feature_mean_std(dataset: timesead.data.dataset.BaseTSDataset, take_fd: bool = False) Tuple[torch.Tensor | None, torch.Tensor | None, torch.Tensor | None, torch.Tensor | None]

Compute the mean and standard deviation of each feature. :param dataset: Time-series dataset. :type dataset: torch.utils.data.Dataset :return: Normal mean, normal std, anomaly mean, anomaly std :rtype: Tuple[Optional[torch.Tensor], Optional[torch.Tensor], Optional[torch.Tensor], Optional[torch.Tensor]]

Parameters:
Return type:

Tuple[Optional[torch.Tensor], Optional[torch.Tensor], Optional[torch.Tensor], Optional[torch.Tensor]]

timesead.data.statistics.compute_ts_statisitcs(timeseries: torch.Tensor, targets: torch.Tensor, dim_order: str = 'tf') Tuple[torch.Tensor | None, torch.Tensor | None, torch.Tensor | None, torch.Tensor | None, torch.Tensor, torch.Tensor]
Parameters:
Return type:

Tuple[Optional[torch.Tensor], Optional[torch.Tensor], Optional[torch.Tensor], Optional[torch.Tensor], torch.Tensor, torch.Tensor]

timesead.data.statistics.training_means(dataset)
timesead.data.statistics.compute_anomaly_positions(dataset: torch.utils.data.Dataset) List[int]

Computes the positions of anomalies in the dataset.

Parameters:

dataset (torch.utils.data.Dataset) – Dataset to compute the statistics of.

Returns:

List of all the relative positions of anomalies in the dataset.

Return type:

List[int]

timesead.data.statistics.compute_anomaly_lengths(dataset: torch.utils.data.Dataset) List[int]

Computes the length of each anomalous window in the dataset.

Parameters:

dataset (torch.utils.data.Dataset) – Dataset to compute the statistics of.

Returns:

List of lengths of anomalies in the dataset.

Return type:

List[int]

timesead.data.statistics.compute_total_time_steps(dataset: torch.utils.data.Dataset) int

Compute the total amount of time steps in the dataset (normal + anormal)

Parameters:

dataset (torch.utils.data.Dataset) – Dataset to compute the statistics of.

Returns:

Number of time steps in the dataset

Return type:

int