예제 #1
0
def test_pca_using_expected_num_dimensions():
    data = [[-1, -1], 
            [1, 1]]
    expected = numpy.matrix([[-1], [1]])

    assert numpy.array_equal(preprocess.pca(data, 1),
                             expected)
예제 #2
0
def test_pca_using_num_dimensions_func():
    data = [[-1, -1], [1, 1]]
    expected = numpy.matrix([[-1], [1]])

    def selection_func(eigen_values):
        return [i for i, v in enumerate(eigen_values) if v > 1]

    assert numpy.array_equal(
        preprocess.pca(data, select_dimensions_func=selection_func), expected)
예제 #3
0
def test_pca_both_expected_and_func():
    with pytest.raises(ValueError):
        preprocess.pca([], 1, lambda x: [0])
예제 #4
0
def test_pca_no_expected_or_func():
    with pytest.raises(ValueError):
        preprocess.pca([], None, None)