How to use the tsfresh.feature_extraction.feature_calculators.autocorrelation function in tsfresh

To help you get started, we’ve selected a few tsfresh examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pdkit / pdkit / pdkit / tremor_processor.py View on Github external
where :math:`n` is the length of the time series :math:`X_i`, :math:`\sigma^2` its variance and :math:`\mu` its
        mean. `l` denotes the lag.

        :param x: the time series to calculate the feature of
        :type x: pandas.Series
        :param lag: the lag
        :type lag: int
        :return: the value of this feature
        :rtype: float
        """
        # This is important: If a series is passed, the product below is calculated
        # based on the index, which corresponds to squaring the series.
        if lag is None:
            lag = 0
        _autoc = feature_calculators.autocorrelation(x, lag)
        logging.debug("autocorrelation by tsfresh calculated")
        return _autoc
github h2oai / driverlessai-recipes / transformers / signal_processing / signal_processing.py View on Github external
'sig_l1_energy': np.abs(sig).mean(),
        'sig_l2_energy': np.abs((sig) ** 2).mean() ** .5,

        # Wavelet features
        "denoise_threshold_d": threshold_d,
        "desnoise_abs_sum_d": np.sum(np.abs(denoised_d)),
        "denoise_nb_peaks_d": (denoised_d != 0).astype(int).sum(),
        "denoise_threshold_a": threshold_a,
        "desnoise_abs_sum_a": np.sum(np.abs(denoised_a)),
        "denoise_nb_peaks_a": (denoised_a != 0).astype(int).sum(),
        "amp_max_a": np.max(abs(denoised_a)),
        "amp_max_d": np.max(abs(denoised_d)),

        # More complex features
        "autocorr1": feature_calculators.autocorrelation(sig, 1),
        "autocorr2": feature_calculators.autocorrelation(sig, 2),
        "autocorr3": feature_calculators.autocorrelation(sig, 3),
        "autocorr5": feature_calculators.autocorrelation(sig, 5),
        "autocorr10": feature_calculators.autocorrelation(sig, 10),

        "autocorr_abs_01": feature_calculators.autocorrelation(x=np.abs(sig), lag=1),
        "autocorr_abs_02": feature_calculators.autocorrelation(x=np.abs(sig), lag=2),
        "autocorr_abs_03": feature_calculators.autocorrelation(x=np.abs(sig), lag=3),
        "autocorr_abs_05": feature_calculators.autocorrelation(x=np.abs(sig), lag=5),
        "autocorr_abs_10": feature_calculators.autocorrelation(x=np.abs(sig), lag=10),

        # Trend error
        "trend_stderr": feature_calculators.linear_trend(x=sig, param=[{"attr": "stderr"}])[0][1],

        "abs_change": feature_calculators.absolute_sum_of_changes(x=sig),
        "mean_change": np.mean(diff),
        "ratio_diff": (diff[diff >= 0].sum() + eps) / (diff[diff < 0].sum() + eps),
github h2oai / driverlessai-recipes / transformers / signal_processing / signal_processing.py View on Github external
# Wavelet features
        "denoise_threshold_d": threshold_d,
        "desnoise_abs_sum_d": np.sum(np.abs(denoised_d)),
        "denoise_nb_peaks_d": (denoised_d != 0).astype(int).sum(),
        "denoise_threshold_a": threshold_a,
        "desnoise_abs_sum_a": np.sum(np.abs(denoised_a)),
        "denoise_nb_peaks_a": (denoised_a != 0).astype(int).sum(),
        "amp_max_a": np.max(abs(denoised_a)),
        "amp_max_d": np.max(abs(denoised_d)),

        # More complex features
        "autocorr1": feature_calculators.autocorrelation(sig, 1),
        "autocorr2": feature_calculators.autocorrelation(sig, 2),
        "autocorr3": feature_calculators.autocorrelation(sig, 3),
        "autocorr5": feature_calculators.autocorrelation(sig, 5),
        "autocorr10": feature_calculators.autocorrelation(sig, 10),

        "autocorr_abs_01": feature_calculators.autocorrelation(x=np.abs(sig), lag=1),
        "autocorr_abs_02": feature_calculators.autocorrelation(x=np.abs(sig), lag=2),
        "autocorr_abs_03": feature_calculators.autocorrelation(x=np.abs(sig), lag=3),
        "autocorr_abs_05": feature_calculators.autocorrelation(x=np.abs(sig), lag=5),
        "autocorr_abs_10": feature_calculators.autocorrelation(x=np.abs(sig), lag=10),

        # Trend error
        "trend_stderr": feature_calculators.linear_trend(x=sig, param=[{"attr": "stderr"}])[0][1],

        "abs_change": feature_calculators.absolute_sum_of_changes(x=sig),
        "mean_change": np.mean(diff),
        "ratio_diff": (diff[diff >= 0].sum() + eps) / (diff[diff < 0].sum() + eps),
        "abs_energy": feature_calculators.abs_energy(x=sig - np.mean(sig)),
        "agg_autocorr_mean":
github Tencent / Metis / time_series_detector / feature / classification_features.py View on Github external
.. rubric:: References

    [1] https://en.wikipedia.org/wiki/Autocorrelation#Estimation

    :param x: the time series to calculate the feature of
    :type x: pandas.Series
    :param lag: the lag
    :type lag: int
    :return: the value of this feature
    :return type: float
    """
    lag = int((len(x) - 3) / 5)
    if np.sqrt(np.var(x)) < 1e-10:
        return 0
    return ts_feature_calculators.autocorrelation(x, lag)
github h2oai / driverlessai-recipes / transformers / signal_processing / signal_processing.py View on Github external
# Energy features
        'sig_l1_energy': np.abs(sig).mean(),
        'sig_l2_energy': np.abs((sig) ** 2).mean() ** .5,

        # Wavelet features
        "denoise_threshold_d": threshold_d,
        "desnoise_abs_sum_d": np.sum(np.abs(denoised_d)),
        "denoise_nb_peaks_d": (denoised_d != 0).astype(int).sum(),
        "denoise_threshold_a": threshold_a,
        "desnoise_abs_sum_a": np.sum(np.abs(denoised_a)),
        "denoise_nb_peaks_a": (denoised_a != 0).astype(int).sum(),
        "amp_max_a": np.max(abs(denoised_a)),
        "amp_max_d": np.max(abs(denoised_d)),

        # More complex features
        "autocorr1": feature_calculators.autocorrelation(sig, 1),
        "autocorr2": feature_calculators.autocorrelation(sig, 2),
        "autocorr3": feature_calculators.autocorrelation(sig, 3),
        "autocorr5": feature_calculators.autocorrelation(sig, 5),
        "autocorr10": feature_calculators.autocorrelation(sig, 10),

        "autocorr_abs_01": feature_calculators.autocorrelation(x=np.abs(sig), lag=1),
        "autocorr_abs_02": feature_calculators.autocorrelation(x=np.abs(sig), lag=2),
        "autocorr_abs_03": feature_calculators.autocorrelation(x=np.abs(sig), lag=3),
        "autocorr_abs_05": feature_calculators.autocorrelation(x=np.abs(sig), lag=5),
        "autocorr_abs_10": feature_calculators.autocorrelation(x=np.abs(sig), lag=10),

        # Trend error
        "trend_stderr": feature_calculators.linear_trend(x=sig, param=[{"attr": "stderr"}])[0][1],

        "abs_change": feature_calculators.absolute_sum_of_changes(x=sig),
        "mean_change": np.mean(diff),