def test_fit_remove_add_trend(order, n_instances, n_timepoints):
    coefs = np.random.normal(size=order + 1).reshape(-1, 1)
    x = np.column_stack([
        _generate_polynomial_series(n_timepoints, order, coefs=coefs)
        for _ in range(n_instances)
    ]).T
    # assert x.shape == (n_samples, n_obs)

    # check shape of fitted coefficients
    coefs = _fit_trend(x, order=order)
    assert coefs.shape == (n_instances, order + 1)
예제 #2
0
 def _compute_trend(y):
     # Trend calculated through least squares regression.
     coefs = _fit_trend(y.values.reshape(1, -1), order=1)
     return coefs[0, 0] / 2