示例#1
0
def nearest_neighbour(query_sequence, training_set, params):
    distances = [
        cdtw_sakoe_chiba(query_sequence, training_sequence, params['r'])
        for training_sequence in training_set
    ]
    best_seq_index = argmin(distances)
    return best_seq_index, distances
示例#2
0
def test_cdtw():
    """Simple test to run cDTW with different values of r"""
    print("\n\n== Testing cDTW ==\n")
    a = array([1, 2, 2, 2, 3, 4, 5, 6, 7], dtype="float64")
    b = array([1, 2, 3, 4, 5, 6, 6, 6, 7], dtype="float64")

    results = [(r, cdtw_sakoe_chiba(a, b, r)) for r in [0, 1, 2]]
    print("a: {0}".format(a))
    print("b: {0}".format(b))
    print("cDTW results: (should be 8, 4, and 0)")
    for result in results:
        print("r={0[0]}: {0[1]}".format(result))
    print("\n")
示例#3
0
def test_cdtw():
    """Simple test to run cDTW with different values of r"""
    print("\n\n== Testing cDTW ==\n")
    a = array([1,2,2,2,3,4,5,6,7], dtype="float64")
    b = array([1,2,3,4,5,6,6,6,7], dtype="float64")
    
    results = [(r, cdtw_sakoe_chiba(a, b, r)) for r in [0,1,2]]
    print("a: {0}".format(a))
    print("b: {0}".format(b))
    print("cDTW results: (should be 8, 4, and 0)")
    for result in results:
        print("r={0[0]}: {0[1]}".format(result))
    print("\n")
示例#4
0
 def metric(x, y):
     return cdtw_sakoe_chiba(x, y, 2)
示例#5
0
def nearest_neighbour(query_sequence, training_set, params):
    distances = [cdtw_sakoe_chiba(query_sequence, training_sequence, params['r']) for training_sequence in training_set]
    best_seq_index = argmin(distances)
    return best_seq_index, distances