Beispiel #1
0
def test_list_feature_union_drops(X):
    """Check the the drop of ``ListFeatureUnion`` keeps the correct
    number of samples"""
    drop_0_1 = ListFeatureUnion([('drop' + str(k), 'drop') for k in range(2)])
    x_01_a = drop_0_1.fit_transform(X)
    x_01_b = drop_0_1.transform(X)
    assert x_01_a.shape == (X.shape[0], 0)
    assert x_01_b.shape == (X.shape[0], 0)
Beispiel #2
0
def test_list_feature_union_transform(X):
    """Check that a ``ListFeatureUnion`` of two projections gives the same
    result as stacking the projections."""
    list_dim = [0, 1]
    p_1_2 = ListFeatureUnion([("proj" + str(k), Projection(columns=k))
                              for k in list_dim])
    p12 = Projection(columns=list_dim)
    for p in [p12, p_1_2]:
        p.fit(X)
    x_12 = p12.transform(X)
    x_1_2 = np.concatenate(p_1_2.transform(X), axis=1)

    assert_almost_equal(x_12, x_1_2)