示例#1
0
def dtw_func():
    
    f = DataReader("F", "yahoo", datetime(2000, 1, 1), datetime(2012, 1, 1))
    f_2008 = f[f.index.year == 2008]
    f_2009 = f[f.index.year == 2009]
    query = f_2008.Volume.values
    template = f_2009.Volume.values
        
    
    
    dist = distancefunc(name="manhattan")
    
    
    
    
    #windowtype="paliwal"
    
    #window, distance, path = dtwpy.dtw(query, template, dist=dist, windowtype=windowtype, windowsize=50,pattern="symmetric1", normalized=False,dist_only=False, cost=True)
    
    #pltdtw.plotwithQT(query, template, path,title="")
    #pltdtw.plotalignment_with_window(window,windowtype,path,title="")
    #pltdtw.plotalignment(path, title="")
    
    
    
    #windowtype="scband"
    
    #window, distance, path = dtwpy.dtw(query, template, dist=dist, windowtype=windowtype, windowsize=50,pattern="symmetric1", normalized=False,dist_only=False, cost=True)
    
    #pltdtw.plotwithQT(query, template, path,title="")
    #pltdtw.plotalignment_with_window(window,windowtype,path,title="")
    #pltdtw.plotalignment(path, title="")
    
    
    
    
    windowtype="itakura"
    
    window, distance, path = dtwpy.dtw(query, template, dist=dist, windowtype=windowtype, windowsize=50,pattern="symmetric1", normalized=False,dist_only=False, cost=True)
    
    #pltdtw.plotwithQT(query, template, path,title="")
    #pltdtw.plotalignment_with_window(window,windowtype,path,title="")
    #pltdtw.plotalignment(path, title="")
    return pltdtw.plotalignment_with_window(window,windowtype,path,title="")
plt.plot(D2)

query = d1
template = d2

dist = distancefunc(name="manhattan")

windowtype = "itakura"

figure_number = 3

window, distance, path = dtwpy.dtw(query,
                                   template,
                                   dist=dist,
                                   windowtype=windowtype,
                                   windowsize=50,
                                   pattern="symmetric1",
                                   normalized=False,
                                   dist_only=False,
                                   cost=True)
pltdtw.plotwithQT(query, template, path, figure_number, title=" Original")

query = d1
template = D2

dist = distancefunc(name="manhattan")

windowtype = "itakura"

figure_number = 4