コード例 #1
0
ファイル: test_transforms.py プロジェクト: basaks/uncover-ml
def test_CentreTransform(make_random_data):

    # Generate the expected data
    x, mu, std = make_random_data
    x_expected = x - mu

    # Apply the CentreTransform
    center_transformer = CentreTransform()
    x_produced = center_transformer(x)

    # Check that the values are the same
    assert np.array_equal(x_expected, x_produced)
コード例 #2
0
ファイル: test_transforms.py プロジェクト: basaks/uncover-ml
def test_StandardiseTransform_caching(make_random_data):

    # Generate an initial set of data
    x, mu, std = make_random_data

    # Apply the CentreTransform to the first dataset to preserve the mean
    x_copy = x.copy()
    center_transformer = CentreTransform()
    center_transformer(x_copy)

    # Now apply the center transform to a matrix translated by 2 * mu
    x_translated = x + 3.0 * mu
    x_expected = x_translated - mu
    x_produced = center_transformer(x_translated)

    # Check that the transformer used the mean mu instead of the translated
    # mean which was 4 * mu in this case above
    assert np.array_equal(x_expected, x_produced)