How to use the ruptures.datasets.pw_linear function in ruptures

To help you get started, we’ve selected a few ruptures 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 deepcharles / ruptures / tests / test_pelt.py View on Github external
def test2_ruptures1D():
    n_regimes = 5
    n_samples = 500

    # Piecewise constant signal
    signal, chg_pts = pw_constant(n=n_samples, clusters=n_regimes,
                                  min_size=50, noisy=True, snr=0.1)

    func_to_minimize = gaussmean(signal)  # - log likelihood
    pen = 10
    pe = Pelt(func_to_minimize, penalty=pen,
              n=signal.shape[0], K=0, min_size=1)
    pe.fit()

    # Piecewise linear signal
    signal, chg_pts = pw_linear(n=n_samples, clusters=n_regimes,
                                min_size=50, noisy=True, snr=0.1)

    func_to_minimize = linear_mse(signal)  # mean squared error
    for pen in np.linspace(0.1, 100, 20):
        pe = Pelt(func_to_minimize, penalty=pen, n=signal.shape[0], K=0)
        pe.fit()
github deepcharles / ruptures / tests / test_pelt.py View on Github external
def test1_ruptures1D():
    n_regimes = 5
    n_samples = 500

    # Piecewise constant signal
    signal, chg_pts = pw_constant(n=n_samples, clusters=n_regimes,
                                  min_size=50, noisy=True, snr=0.1)

    func_to_minimize = gaussmean(signal)  # - log likelihood
    for pen in np.linspace(0.1, 100, 20):
        pe = Pelt(func_to_minimize, penalty=pen, n=signal.shape[0], K=0)
        pe.fit()

    # Piecewise linear signal
    signal, chg_pts = pw_linear(n=n_samples, clusters=n_regimes,
                                min_size=50, noisy=True, snr=0.1)

    func_to_minimize = linear_mse(signal)  # mean squared error
    for pen in np.linspace(0.1, 100, 20):
        pe = Pelt(func_to_minimize, penalty=pen,
                  n=signal.shape[0], K=0, min_size=3)
        pe.fit()
github deepcharles / ruptures / tests / test_pelt.py View on Github external
def test3_ruptures1D():
    n_regimes = 5
    n_samples = 500

    # Piecewise linear signal
    signal, chg_pts = pw_linear(n=n_samples, clusters=n_regimes,
                                min_size=50, noisy=True, snr=0.1)

    func_to_minimize = linear_mse(signal)  # mean squared error
    pen = 10
    pe = Pelt(func_to_minimize, penalty=pen,
              n=signal.shape[0], K=0, min_size=2)
    pe.fit()
github deepcharles / ruptures / tests / test_datasets.py View on Github external
                         product([pw_linear],
                                 range(20, 1000, 200),
                                 range(1, 4),
                                 [2, 5, 3],
                                 [None, 1, 2]))
def test_linear(func, n_samples, n_features, n_bkps, noise_std):
    signal, bkps = func(
        n_samples=n_samples, n_features=n_features, n_bkps=n_bkps, noise_std=noise_std)
    assert signal.shape == (n_samples, n_features + 1)
    assert len(bkps) == n_bkps + 1
    assert bkps[-1] == n_samples