示例#1
0
 
 print "BESTLP=%s\n" % str(E)
 f.write("BESTLP=%s\n" % str(E))
 f.write("LISTLP=%s\n\n" % str(L))
 
 # 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))
示例#2
0
 # taken from dn_M-sn_0-lp_100-sq_True-sy_True LISTGEMONE
Mask = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]

# get misclassified time series
for index in zip(*filter(lambda (i, v): v[0] == 1 and v[1] == 0, 
                 enumerate(zip(mask, Mask))))[0][2:]:

    pl.figure(1, figsize=(21, 14))
    ax = pl.subplot("211")

    # get query
    query = zparent[100+index]

    # taken from dn_M-sn_0-lp_100-sq_True-sy_True BESTLEARNCONSDTWONE
    window = int(np.round(0.01*len(parent[0])))
    dist_func= lambda query, subject: ds.cdtw(query, subject, window, True)

    # search nearest neighbor for cdtw
    dist = [dist_func(query, subject) for subject in zchild[100:500]]
    best = np.array(dist).argmin()

    # entries of distance matrix
    AB = ds.cdtw(query, zchild[100+index], window, True)
    AC = np.array(dist).min()
    BC = ds.cdtw(zchild[100+best], zchild[100+index], window, True)
    
    print index, best, AC, AB
    
    # distance matrix
    M = np.array([[0, AB, AC], [AB, 0, BC], [AC, BC, 0]])
    
示例#3
0
    print "BESTLP=%s\n" % str(E)
    f.write("BESTLP=%s\n" % str(E))
    f.write("LISTLP=%s\n\n" % str(L))

    # 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)
示例#4
0
    0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0
]

# get misclassified time series
for index in zip(*filter(lambda (i, v): v[0] == 1 and v[1] == 0,
                         enumerate(zip(mask, Mask))))[0][2:]:

    pl.figure(1, figsize=(21, 14))
    ax = pl.subplot("211")

    # get query
    query = zparent[100 + index]

    # taken from dn_M-sn_0-lp_100-sq_True-sy_True BESTLEARNCONSDTWONE
    window = int(np.round(0.01 * len(parent[0])))
    dist_func = lambda query, subject: ds.cdtw(query, subject, window, True)

    # search nearest neighbor for cdtw
    dist = [dist_func(query, subject) for subject in zchild[100:500]]
    best = np.array(dist).argmin()

    # entries of distance matrix
    AB = ds.cdtw(query, zchild[100 + index], window, True)
    AC = np.array(dist).min()
    BC = ds.cdtw(zchild[100 + best], zchild[100 + index], window, True)

    print index, best, AC, AB

    # distance matrix
    M = np.array([[0, AB, AC], [AB, 0, BC], [AC, BC, 0]])