예제 #1
0
def test_feature_rep():
    # multivariate ts
    frep = transform.FeatureRep(features=all_features())
    X = np.random.rand(100, 10, 5)
    y = np.ones(100)
    frep.fit(X, y)
    Xt = frep.transform(X)
    assert Xt.shape[0] == len(X)
    assert len(frep.f_labels) == Xt.shape[1]

    # univariate ts
    X = np.random.rand(100, 10)
    y = np.ones(100)
    frep.fit(X, y)
    Xt = frep.transform(X)
    assert Xt.shape[0] == len(X)
    assert len(frep.f_labels) == Xt.shape[1]

    # single feature
    frep = transform.FeatureRep(features={'mean': mean})
    frep.fit(X, y)
    Xt = frep.transform(X)
    assert Xt.shape[0] == len(X)
    assert len(frep.f_labels) == Xt.shape[1]
    assert Xt.shape[1] == 1

    # ts with multivariate contextual data
    frep = transform.FeatureRep(features=all_features())
    X = TS_Data(np.random.rand(100, 10, 5), np.random.rand(100, 3))
    y = np.ones(100)
    frep.fit(X, y)
    Xt = frep.transform(X)
    assert Xt.shape[0] == len(X)
    assert len(frep.f_labels) == Xt.shape[1]

    # ts with univariate contextual data
    X = TS_Data(np.random.rand(100, 10, 5), np.random.rand(100))
    y = np.ones(100)
    frep.fit(X, y)
    Xt = frep.transform(X)
    assert Xt.shape[0] == len(X)
    assert len(frep.f_labels) == Xt.shape[1]
예제 #2
0
def test_uv_feature_functions():
    ''' test feature functions with univariate data '''
    N = 20
    W = 30
    uv_data = np.random.rand(N, W)

    ftr_funcs = feature_functions.all_features()

    for f in ftr_funcs:
        uvf = ftr_funcs[f](uv_data)
        assert len(uvf) == N
예제 #3
0
def test_mv_feature_functions():
    ''' test feature functions with multivariate data '''

    # sliding window data is shape [n_segments, width, variables]
    N = 20
    W = 30
    mv_data = np.random.rand(N, W, 3)

    ftr_funcs = feature_functions.all_features()

    for f in ftr_funcs:
        mvf = ftr_funcs[f](mv_data)
        assert len(mvf) == N
def test_uv_feature_functions():
    """ test feature functions with univariate data """
    N = 20
    W = 30
    uv_data = np.random.rand(N, W)

    ftr_funcs = {}
    ftr_funcs.update(feature_functions.all_features())
    ftr_funcs.update(feature_functions.base_features())
    ftr_funcs.update(feature_functions.hudgins_features())
    ftr_funcs.update(feature_functions.emg_features())

    for f in ftr_funcs:
        uvf = ftr_funcs[f](uv_data)
        assert len(uvf) == N
def test_mv_feature_functions():
    """ test feature functions with multivariate data """

    # sliding window data is shape [n_segments, width, variables]
    N = 20
    W = 30
    mv_data = np.random.rand(N, W, 3)

    ftr_funcs = {}
    ftr_funcs.update(feature_functions.all_features())
    ftr_funcs.update(feature_functions.base_features())
    ftr_funcs.update(feature_functions.hudgins_features())
    ftr_funcs.update(feature_functions.emg_features())

    for f in ftr_funcs:
        mvf = ftr_funcs[f](mv_data)
        assert len(mvf) == N