# obtain error for unconstrained dtw
    dist = lambda query, subject: ds.dtw(query, subject, squared)
    E, L = cl.obtain_1NN_error(testLabels, testSet, trainLabels, trainSet, dist)
    
    print "BESTFULLDTW=%s\n" % str(E)
    f.write("BESTFULLDTW=%s\n" % str(E))
    f.write("LISTFULLDTW=%s\n\n" % str(L))
    
    # obtain error for constrained dtw
    window = int(np.round(best_dtw[1][0]*len(trainSet[0])))
    dist = lambda query, subject: ds.cdtw(query, subject, window, squared)
    E, L = cl.obtain_1NN_error(testLabels, testSet, trainLabels, trainSet, dist)
    
    print "BESTCONSDTW=%s\n" % str(E)
    f.write("BESTCONSDTW=%s\n" % str(E))
    f.write("LISTCONSDTW=%s\n\n" % str(L))
    
    # obtain error for gem
    St0, St1, E = best_gem[1][0], best_gem[1][1], best_gem[1][2]
    dist = lambda query, subject: \
                        ds.gem(query, subject, St0, St1, E, symmetric, squared)
    E, L = cl.obtain_1NN_error(testLabels, testSet, trainLabels, trainSet, dist)
    
    print "BESTGEM=%s\n" % str(E)
    f.write("BESTGEM=%s\n" % str(E))
    f.write("LISTGEM=%s\n\n" % str(L))
    
    # close the log file
    f.close()
    
Exemple #2
0
    #pl.axis("off")
    pl.tight_layout()
        

    # now the same for gem
    #pl.figure(2, figsize=(21, 7))
    ax = pl.subplot("212")

    # get query
    query = parent[100+index]

    # taken from dn_M-sn_0-lp_100-sq_True-sy_True BESTLEARNGEMONE
    St0, St1, E = 2, 2, 0.0625
    
    # entries of distance matrix
    AB = ds.gem(query, child[100+index], St0, St1, E, True, True)
    AC = ds.gem(query, child[100+best], St0, St1, E, True, True)
    BC = ds.gem(child[100+best], child[100+index], St0, St1, E, True, True)
    
    print index, best, AC, AB
    
    # distance matrix (rescale to cdtw errors)
    M = np.array([[0, AB, AC], [AB, 0, BC], [AC, BC, 0]])*np.max(M)/np.max([AB, AC, BC])
        
    # label function
    L = lambda x: {0: "P", 1: "C", 2: "L"}[int(x)]
    
    # render dendrogram
    D = h.dendrogram(h.complete(M), orientation="left", leaf_label_func=L, 
                     link_color_func=lambda k: "b", leaf_font_size=40)
    
Exemple #3
0
    E, L = cl.obtain_1NN_error(testLabels, testSet, trainLabels, trainSet,
                               dist)

    print "BESTFULLDTW=%s\n" % str(E)
    f.write("BESTFULLDTW=%s\n" % str(E))
    f.write("LISTFULLDTW=%s\n\n" % str(L))

    # obtain error for constrained dtw
    window = int(np.round(best_dtw[1][0] * len(trainSet[0])))
    dist = lambda query, subject: ds.cdtw(query, subject, window, squared)
    E, L = cl.obtain_1NN_error(testLabels, testSet, trainLabels, trainSet,
                               dist)

    print "BESTCONSDTW=%s\n" % str(E)
    f.write("BESTCONSDTW=%s\n" % str(E))
    f.write("LISTCONSDTW=%s\n\n" % str(L))

    # obtain error for gem
    St0, St1, E = best_gem[1][0], best_gem[1][1], best_gem[1][2]
    dist = lambda query, subject: \
                        ds.gem(query, subject, St0, St1, E, symmetric, squared)
    E, L = cl.obtain_1NN_error(testLabels, testSet, trainLabels, trainSet,
                               dist)

    print "BESTGEM=%s\n" % str(E)
    f.write("BESTGEM=%s\n" % str(E))
    f.write("LISTGEM=%s\n\n" % str(L))

    # close the log file
    f.close()
Exemple #4
0
    ax.set_xticks([])
    #pl.axis("off")
    pl.tight_layout()

    # now the same for gem
    #pl.figure(2, figsize=(21, 7))
    ax = pl.subplot("212")

    # get query
    query = parent[100 + index]

    # taken from dn_M-sn_0-lp_100-sq_True-sy_True BESTLEARNGEMONE
    St0, St1, E = 2, 2, 0.0625

    # entries of distance matrix
    AB = ds.gem(query, child[100 + index], St0, St1, E, True, True)
    AC = ds.gem(query, child[100 + best], St0, St1, E, True, True)
    BC = ds.gem(child[100 + best], child[100 + index], St0, St1, E, True, True)

    print index, best, AC, AB

    # distance matrix (rescale to cdtw errors)
    M = np.array([[0, AB, AC], [AB, 0, BC], [AC, BC, 0]]) * np.max(M) / np.max(
        [AB, AC, BC])

    # label function
    L = lambda x: {0: "P", 1: "C", 2: "L"}[int(x)]

    # render dendrogram
    D = h.dendrogram(h.complete(M),
                     orientation="left",