コード例 #1
0
def test_sparse_filter():
    sps_filter = SparseFeatureFilter(threshold=0.5)
    trans = sps_filter.fit_transform(sparse)

    # we should have filtered out the third col
    assert trans.shape[1] == 2
    assert 'c' not in trans.columns
コード例 #2
0
def test_sparse_filter_dense_data():
    sps_filter = SparseFeatureFilter(threshold=0.25)
    trans = sps_filter.fit_transform(iris)

    # nothing should have changed
    assert trans.equals(iris)

    # assert on values
    assert_array_almost_equal(sps_filter.sparsity_, np.zeros(4))
コード例 #3
0
def test_sparse_asdf():
    assert_transformer_asdf(SparseFeatureFilter(), iris)