예제 #1
0
def test_normalize_features_two_feats2():
    """Test create_ffiles._normalize_features with two points."""
    feature_list = [features.Width(), features.Height()]
    prepared = [([123, 123], 1), ([100, 100], 1)]
    is_traindata = True
    out = create_ffiles._normalize_features(feature_list, prepared,
                                            is_traindata)
    # Mean: 111.5; Range: 23
    assert out == [([0.5, 0.5], 1), ([-0.5, -0.5], 1)]

    # Now the other set
    prepared = [([111.5, 146], 1), ([146, 111.5], 1), ([54, 54], 1)]
    is_traindata = False
    out = create_ffiles._normalize_features(feature_list, prepared,
                                            is_traindata)
    assert out == [([0.0, 1.5], 1), ([1.5, 0.0], 1), ([-2.5, -2.5], 1)]
예제 #2
0
def test_normalize_features_two():
    """Test create_ffiles._normalize_features with two points."""
    feature_list = [features.Width(), features.Height()]
    prepared = [([123], 1), ([100], 1)]
    is_traindata = True
    out = create_ffiles._normalize_features(feature_list, prepared,
                                            is_traindata)
    # Mean: 111.5; Range: 23
    assert out == [([0.5], 1), ([-0.5], 1)]

    # Now the other set
    prepared = [([111.5], 1), ([90], 1), ([180], 1)]
    is_traindata = False
    out = create_ffiles._normalize_features(feature_list, prepared,
                                            is_traindata)
    assert out == [([0.0], 1), ([-0.93478260869565222], 1),
                   ([2.9782608695652173], 1)]
예제 #3
0
def normalize_features_one_test():
    """Test create_ffiles._normalize_features with one point."""
    feature_list = [features.Width(), features.Height()]
    prepared = [([123], 1)]
    is_traindata = True
    out = create_ffiles._normalize_features(feature_list, prepared,
                                            is_traindata)
    nose.tools.assert_equal(out, [([0.0], 1)])
예제 #4
0
def test_normalize_features_one():
    """Test create_ffiles._normalize_features with one point."""
    feature_list = [features.Width(), features.Height()]
    prepared = [([123], 1)]
    is_traindata = True
    out = create_ffiles._normalize_features(feature_list, prepared,
                                            is_traindata)
    assert out == [([0.0], 1)]
예제 #5
0
def test_normalize_features_two_classes():
    """Test create_ffiles._normalize_features with two classes."""
    feature_list = [features.Width(), features.Height()]
    prepared = [([123], 1), ([100], 1), ([500], 2)]
    is_traindata = True
    out = create_ffiles._normalize_features(feature_list, prepared,
                                            is_traindata)
    # Mean: 241; Range: 400
    assert out == [([-0.295], 1), ([-0.3525], 1), ([0.6475], 2)]
예제 #6
0
def normalize_features_one_test():
    """Test create_ffiles._normalize_features with one point."""
    feature_list = [features.Width(), features.Height()]
    prepared = [([123], 1)]
    is_traindata = True
    out = create_ffiles._normalize_features(feature_list,
                                            prepared,
                                            is_traindata)
    nose.tools.assert_equal(out, [([0.0], 1)])
예제 #7
0
def normalize_features_two_feats_test():
    """Test create_ffiles._normalize_features with two points."""
    feature_list = [features.Width(), features.Height()]
    prepared = [([123, 123], 1), ([100, 100], 1)]
    is_traindata = True
    out = create_ffiles._normalize_features(feature_list,
                                            prepared,
                                            is_traindata)
    # Mean: 111.5; Range: 23
    nose.tools.assert_equal(out, [([0.5, 0.5], 1), ([-0.5, -0.5], 1)])

    # Now the other set
    prepared = [([111.5, 111.5], 1), ([146, 146], 1), ([54, 54], 1)]
    is_traindata = False
    out = create_ffiles._normalize_features(feature_list,
                                            prepared,
                                            is_traindata)
    nose.tools.assert_equal(out, [([0.0, 0.0], 1),
                                  ([1.5, 1.5], 1),
                                  ([-2.5, -2.5], 1)])
예제 #8
0
def normalize_features_two_test():
    """Test create_ffiles._normalize_features with two points."""
    feature_list = [features.Width(), features.Height()]
    prepared = [([123], 1), ([100], 1)]
    is_traindata = True
    out = create_ffiles._normalize_features(feature_list,
                                            prepared,
                                            is_traindata)
    # Mean: 111.5; Range: 23
    nose.tools.assert_equal(out, [([0.5], 1), ([-0.5], 1)])

    # Now the other set
    prepared = [([111.5], 1), ([90], 1), ([180], 1)]
    is_traindata = False
    out = create_ffiles._normalize_features(feature_list,
                                            prepared,
                                            is_traindata)
    nose.tools.assert_equal(out, [([0.0], 1),
                                  ([-0.93478260869565222], 1),
                                  ([2.9782608695652173], 1)])
예제 #9
0
def normalize_features_two_classes_test():
    """Test create_ffiles._normalize_features with two classes."""
    feature_list = [features.Width(), features.Height()]
    prepared = [([123], 1), ([100], 1), ([500], 2)]
    is_traindata = True
    out = create_ffiles._normalize_features(feature_list,
                                            prepared,
                                            is_traindata)
    # Mean: 241; Range: 400
    nose.tools.assert_equal(out, [([-0.295], 1),
                                  ([-0.3525], 1),
                                  ([0.6475], 2)])