<jupyter_start><jupyter_text><jupyter_code>!pip install --upgrade git+https://github.com/ariaghora/robust-period.git<jupyter_output>Collecting git+https://github.com/ariaghora/robust-period.git
  Cloning https://github.com/ariaghora/robust-period.git to /tmp/pip-req-build-9kxqymv4
  Running command git clone -q https://github.com/ariaghora/robust-period.git /tmp/pip-req-build-9kxqymv4
Building wheels for collected packages: RobustPeriod
  Building wheel for RobustPeriod (setup.py) ... [?25l[?25hdone
  Created wheel for RobustPeriod: filename=RobustPeriod-0.2.1-py3-none-any.whl size=7871 sha256=1f7d150891aa584b4fc9d04440b4954abe35b93080cdd3c788d995a6ee26d950
  Stored in directory: /tmp/pip-ephem-wheel-cache-ezmh7y0o/wheels/84/a1/ac/eb08a7987d95ff5fb80e91a524306053841977f81dd7c0559b
Successfully built RobustPeriod
Installing collected packages: RobustPeriod
Successfully installed RobustPeriod-0.2.1<jupyter_text>Code below is from https://github.com/ariaghora/robust-period<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
from robustperiod import robust_period, robust_period_full, plot_robust_period
from robustperiod.utils import sinewave, triangle
from statsmodels.datasets.co2.data import load_pandas

if __name__ == '__main__':
    '''
    Dummy dataset
    '''
    m = 1000
    y1 = sinewave(m, 20, 1)
    y2 = sinewave(m, 50, 1)
    y3 = sinewave(m, 100, 1)
    tri = triangle(m, 10)
    noise = np.random.normal(0, 0.1, m)
    y = y1+y2+y3+tri+noise
    y[m // 2] += 10  # sudden spike

    plt.plot(y)
    plt.title('Dummy dataset')
    plt.show()

    lmb = 1e+6
    c = 2
    num_wavelets = 8
    zeta = 1.345

    periods, W, bivar, periodograms, p_vals, ACF = robust_period_full(
        y, 'db10', num_wavelets, lmb, c, zeta)
    plot_robust_period(periods, W, bivar, periodograms, p_vals, ACF)

    '''
    CO_2 dataset
    '''
    co2 = load_pandas()

    # We only take 1000 samples due to numerical error by binom coef. computation
    # when N is large
    y_co2 = co2.data.fillna(method='ffill').values.squeeze()[:1000]
    plt.plot(y_co2)
    plt.title('$CO_2$ dataset')
    plt.show()

    periods, W, bivar, periodograms, p_vals, ACF = robust_period_full(
        y_co2, 'db10', num_wavelets, lmb, c, zeta)
    plot_robust_period(periods, W, bivar, periodograms, p_vals, ACF)

    '''
    RobustPeriod on multiple series combined
    '''
    combined = np.array([y, y_co2]).T
    periods_list = robust_period(combined, 'db10', num_wavelets, lmb, c, zeta)

    for i, periods in enumerate(periods_list):
        print(f'Periods for series {i+1}: {periods}')<jupyter_output>/usr/local/lib/python3.7/dist-packages/statsmodels/tools/_testing.py:19: FutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead.
  import pandas.util.testing as tm
{'fraction_non_alphanumeric': 0.11533052039381153, 'fraction_numerical': 0.05907172995780591, 'mean_word_length': 3.991228070175439, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '550318', 'license': 'MIT', 'n_tokens_mistral': 1171, 'n_tokens_neox': 1060, 'n_words': 228, 'path': 'code/preprocessing_and_decomposition/RobustPeriod.ipynb', 'repo_name': 'iotanalytics/IoTTutorial', 'size': '2844'}