timesead.data.statistics ======================== .. py:module:: timesead.data.statistics Functions --------- .. autoapisummary:: timesead.data.statistics.get_data_all timesead.data.statistics.compute_whiten_matrix timesead.data.statistics.compute_feature_statistics timesead.data.statistics.compute_feature_mean_std timesead.data.statistics.compute_ts_statisitcs timesead.data.statistics.training_means timesead.data.statistics.compute_anomaly_positions timesead.data.statistics.compute_anomaly_lengths timesead.data.statistics.compute_total_time_steps Module Contents --------------- .. py:function:: get_data_all(dataset: torch.utils.data.Dataset, take_fd: bool = False) -> torch.Tensor Extract data matrix from dataset. :param dataset: Time-series dataset. take_fd: flag, to take first differences. :type dataset: torch.utils.data.Dataset take_id: bool :return: data matrix :rtype: torch.Tensor .. py:function:: compute_whiten_matrix(dataset: torch.utils.data.Dataset, take_fd: bool = False) -> torch.Tensor Compute whiten matrix of dataset. :param dataset: Time-series dataset. :type dataset: torch.utils.data.Dataset :return: whiten matrix :rtype: torch.Tensor .. py:function:: compute_feature_statistics(dataset: torch.utils.data.Dataset, take_fd: bool = False) -> Tuple[Optional[torch.Tensor], Optional[torch.Tensor], Optional[torch.Tensor], Optional[torch.Tensor], torch.Tensor, torch.Tensor] Compute statistics of each feature. :param dataset: Time-series dataset. :type dataset: torch.utils.data.Dataset :return: Normal mean, normal std, anomaly mean, anomaly std, minimum, and maximum :rtype: Tuple[Optional[torch.Tensor], Optional[torch.Tensor], Optional[torch.Tensor], Optional[torch.Tensor], torch.Tensor, torch.Tensor] .. py:function:: compute_feature_mean_std(dataset: timesead.data.dataset.BaseTSDataset, take_fd: bool = False) -> Tuple[Optional[torch.Tensor], Optional[torch.Tensor], Optional[torch.Tensor], Optional[torch.Tensor]] 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]] .. py:function:: compute_ts_statisitcs(timeseries: torch.Tensor, targets: torch.Tensor, dim_order: str = 'tf') -> Tuple[Optional[torch.Tensor], Optional[torch.Tensor], Optional[torch.Tensor], Optional[torch.Tensor], torch.Tensor, torch.Tensor] .. py:function:: training_means(dataset) .. py:function:: compute_anomaly_positions(dataset: torch.utils.data.Dataset) -> List[int] Computes the positions of anomalies in the dataset. :param dataset: Dataset to compute the statistics of. :type dataset: torch.utils.data.Dataset :return: List of all the relative positions of anomalies in the dataset. :rtype: List[int] .. py:function:: compute_anomaly_lengths(dataset: torch.utils.data.Dataset) -> List[int] Computes the length of each anomalous window in the dataset. :param dataset: Dataset to compute the statistics of. :type dataset: torch.utils.data.Dataset :return: List of lengths of anomalies in the dataset. :rtype: List[int] .. py:function:: compute_total_time_steps(dataset: torch.utils.data.Dataset) -> int Compute the total amount of time steps in the dataset (normal + anormal) :param dataset: Dataset to compute the statistics of. :type dataset: torch.utils.data.Dataset :return: Number of time steps in the dataset :rtype: int