示例#1
0
    def draw_topK(search_type=0, bar_type=0):
        # testSampleResultFile.t=0.ns=500.r=1.k=10.nw=1
        alg_type = ['SPBase', 'SPBest']
        ns = 200
        radius = 2
        ks = [1, 3, 5, 8, 10, 15, 20]
        nw = 5

        if bar_type==0:
            ys = [i*1000 for i in range(13)]
            ys = None
            y_label = 'Runtime (ms)'
        elif bar_type==1:
            ys = [i*100 for i in range(5)]
            y_label = '# of TQSP Computations'
        else:
            ys = [i*10 for i in range(6)]
            y_label = '# of R-tree nodes accessed'

        base_dir = 'D:\\nowMask\KnowledgeBase\\sample_result\\yago2s_single_date\\k_nw\\'

        if bar_type==0:
            timeBar = Bar(xLabel=r'top-$k$', yLabel=y_label, is_stack=True, title=r'top-k type=' + str(search_type), ys=ys)
            for i in range(len(alg_type)):
                datas = []
                for k in ks:
                    data = Data.getData(fp=PathUtility.sample_res_path(base_dir, sp=alg_type[i], nwlen=1000000, mds=1000, t=search_type, ns=200, r=2, k=k, nw=5, wf=500, dr=7))
                    print(data)
                    datas.append(data)
                timeOthers = []
                timeSemantics = []
                for data in datas:
                    timeSemantics.append(data.timeSemantic)
                    timeOthers.append(data.timeOther)

                timeBar.draw_bar(i, timeSemantics, hatch=Bar.hatchx, label=alg_type[i])
                timeBar.draw_bar(i, timeOthers, ys=timeSemantics, faceColor='white')
            timeBar.show()
        else:
            if 1==bar_type: y_type = 'TQSP'
            elif 2==bar_type: y_type = 'RTree'
            bar = Bar(xLabel=r'top-$k$', yLabel=y_label, title=r'top-k type=' + str(search_type), ys=ys, y_type=y_type)
            for i in range(len(alg_type)):
                datas = []
                for k in ks:
                    data = Data.getData(fp=PathUtility.sample_res_path(base_dir, sp=alg_type[i], nwlen=1000000, mds=1000, t=search_type, ns=200, r=2, k=k, nw=5, wf=500, dr=7))
                    print(data)
                    datas.append(data)
                list1 = []
                for data in datas:
                    if 1==bar_type:
                        list1.append(data.numTQSP)
                    elif 2==bar_type:
                        list1.append(data.numAccessedRTreeNode)
                bar.draw_bar(i, list1, label=alg_type[i])
            bar.show()
示例#2
0
    def draw_date_range(label=r'$|q.\delta|$', base_y=None, x_rotation=0, fpath='test.pdf'):
        if base_y!=None: ys = [base_y+i*100 for i in range(0, 17)]
        # x_txts = [r'$5\times10^8$', r'$1\times10^8$', r'$5\times10^7$', r'$1\times10^7$',
        #           r'$5\times10^6$', r'$1\times10^6$', r'$5\times10^5$', r'$1\times10^5$',
        #           r'$1\times10^4$', '0']
        # x_txts = [0,3,7,15,30,50,100,150,300,600]
        # drs = [0,3,7,15,30,50,100,150,300,600]
        drs = [0,3,7,15,30,50,100,150]
        x_txts = [0,6,14,30,60,100,200,300]
        xs=[i for  i in  range(len(drs))]

        if base_y!=None: chart = LineChart(xs, x_txts, ys=ys, yscale='liner', xLabel=label, title=label, yLabel='Runtime (ms)', xlabel_rotation=x_rotation, fpath = fpath)
        else:   chart = LineChart(xs, x_txts, xLabel=label, title=label, yLabel='Runtime (ms)', xlabel_rotation=x_rotation, fpath=fpath)

        base_dir = 'D:\\nowMask\KnowledgeBase\\sample_result\\yago2s_single_date\\dr\\'
        alg_types=['SPBase', 'SPBest']
        for alg_type in alg_types:
            runtimes = []
            for dr in drs:
                data = Data.getData(fp=PathUtility.sample_res_path(base_dir, sp=alg_type, nwlen=1000000, mds=1000, t=1, ns=200, r=2, k=5, nw=5, wf=500, dr=dr))
                # print(data)
                runtimes.append(data.timeTotal)
            print(runtimes)
            if alg_type=='SPBase':
                chart.draw_line(runtimes, r'$SPTR$')
            elif alg_type=='SPBest':
                chart.draw_line(runtimes, r'$SPTR^*$')
        chart.show()
示例#3
0
    def draw_differ_size(line_type=0, title='Graph Vertex Size (in million)', fpath='test.pdf'):
        # testSampleResultFile.t=0.ns=500.r=1.k=10.nw=1
        xs = [1, 2, 3, 4]
        x_txts = [2.0, 4.0, 6.0, 8.0]

        if line_type==0:    yLabel='Runtime (ms)'
        elif line_type==1:  yLabel = '# of R-tree nodes accessed'

        chart = LineChart(xs, x_txts, xLabel=r'Graph Vertex Size (in million)', yLabel=yLabel, title=title, fpath=fpath)

        alg_types = ['SPBase', 'SPBest']
        ts = [0, 1]
        sizes = ['2000000', '4000000', '6000000', 'org']
        alg_names = [r'$SPTD$', r'$SPTR$', r'$SPTD^*$', r'$SPTR^*$']
        base_dir = 'D:\\nowMask\KnowledgeBase\\sample_result\\yago2s_single_date\\diff_size\\'

        alg_names_index = 0
        for alg_type in alg_types:
            for t in ts:
                runtimes = []
                for i in range(len(sizes)):
                    data = Data.getData(fp=PathUtility.sample_res_path(base_dir + sizes[i] + '\\', sp=alg_type, nwlen=1000000, mds=1000, t=t, ns=200, r=2, k=5, nw=5, wf=500, dr=7))
                    print(data)
                    if line_type==0:    runtimes.append(data.timeTotal)
                    elif line_type==1:  runtimes.append(data.numAccessedRTreeNode)
                chart.draw_line(runtimes, label=alg_names[alg_names_index])
                alg_names_index = alg_names_index + 1
        chart.show()
示例#4
0
    def draw_nw(base_y=None, fpath='test.pdf'):
        ys = None
        if base_y != None:
            ys = [base_y+i*100 for i in range(0, 11)]
        x_txts = [1.0, 3.0, 5.0, 8.0, 10.0]
        xs=[i for  i in  range(len(x_txts))]

        yLabel = 'Runtime (ms)'

        chart = LineChart(xs, x_txts, ys=ys, xLabel=r'|$q.\psi$|', yLabel=yLabel, title=r'|$q.\psi$|', fpath=fpath)

        alg_types = ['SPBase', 'SPBest']
        search_types = [0, 1]
        type = None

        nws = [1, 3, 5, 8, 10]
        base_dir = 'D:\\nowMask\KnowledgeBase\\sample_result\\yago2s_single_date\\k_nw\\'
        for search_index in range(len(search_types)):
            for alg_index in range(len(alg_types)):
                if alg_index==0:
                    if search_index==0: type=r'$SPTD$'
                    else:   type=r'$SPTR$'
                else:
                    if search_index==0: type=r'$SPTD^*$'
                    else:   type=r'$SPTR^*$'
                runtimes = []
                for nw in nws:
                    data = Data.getData(fp=PathUtility.sample_res_path(base_dir, sp=alg_types[alg_index], nwlen=1000000, mds=1000, t=search_types[search_index], ns=200, r=2, k=5, nw=nw, wf=500, dr=7))
                    print(data)
                    runtimes.append(data.timeTotal)
                chart.draw_line(runtimes, type)
        chart.show()
示例#5
0
    def draw_n_words(search_type=0):
        # testSampleResultFile.t=0.ns=500.r=1.k=10.nw=1
        xs = [0.5, 1, 2, 3, 4, 5, 5.5]
        x_txts = [1.0, 3.0, 5.0, 8.0, 10.0]
        ys = [i*100 for i in range(15)]
        alg_type = ['SPBase', 'SPBest']
        ns = 200
        radius = 2
        k = 5
        nws = [1, 3, 5, 8, 10]

        base_dir = 'D:\\nowMask\KnowledgeBase\\sample_result\\yago2s_single_date\\k_nw\\'

        timeBar = Bar(xLabel=r'|$q.\psi$|', yLabel='Runtime (ms)', is_stack=True, title='n_wrods type=' + str(search_type), ys=ys, xs=xs, x_txts=x_txts, y_type='NW')
        for i in range(len(alg_type)):
            datas = []
            for nw in nws:
                data = Data.getData(fp=PathUtility.sample_res_path(base_dir, sp=alg_type[i], nwlen=1000000, mds=1000, t=search_type, ns=200, r=2, k=5, nw=nw, wf=500, dr=7))
                print(data)
                datas.append(data)
            timeOthers = []
            timeSemantics = []
            for data in datas:
                timeSemantics.append(data.timeSemantic)
                timeOthers.append(data.timeOther)
            timeBar.draw_bar(i, timeSemantics, hatch=Bar.hatchx, label=alg_type[i])
            timeBar.draw_bar(i, timeOthers, ys=timeSemantics, faceColor='white')
        timeBar.show()
示例#6
0
    def draw_radius(type=0, base_y=600, title='TEST', fpath='test.pdf'):
        ys = [base_y+i*50 for i in range(0, 11)]
        xs=[i for  i in  range(0, 4)]
        x_txts = [1.0, 2.0, 3.0, 5.0]
        chart = LineChart(xs, x_txts, ys=ys, yscale='liner', xLabel=r'$\alpha$-radius', yLabel='Runtime (ms)', title=title, fpath=fpath)
        # chart = LineChart(xs, x_txts, xLabel=r'$\alpha$-radius', yLabel='Runtime (ms)')

        radius = [1, 2, 3, 5]
        ks = [1, 3, 5, 8, 10, 15, 20]
        base_dir = 'D:\\nowMask\KnowledgeBase\\sample_result\\yago2s_single_date\\radius_k\\'
        for k in ks:
            runtimes = []
            for r in radius:
                data = Data.getData(fp=PathUtility.sample_res_path(base_dir, nwlen=1000000, mds=1000, t=type, ns=200, r=r, k=k, nw=5, wf=500, dr=7))
                print(data)
                runtimes.append(data.timeTotal)
            chart.draw_line(runtimes, 'k=' + str(k))
        chart.show()
示例#7
0
    def draw_k(show_type, base_y=None, fpath='test.pdf'):
        ys = None
        ys = [i*100 for i in range(17)]
        if base_y != None:
            ys = [base_y+i*100 for i in range(0, 17)]
        x_txts = [1.0, 3.0, 5.0, 8.0, 10.0, 15.0, 20.0]
        xs=[i for  i in  range(len(x_txts))]

        yLabel = None
        yscale = 'liner'
        if 0==show_type:
            yLabel = 'Runtime (ms)'
        elif 1==show_type:
            yLabel = '# of TQTSP Computations'
            yscale='log'
        elif 2==show_type: yLabel = '# of R-tree nodes accessed'

        chart = LineChart(xs, x_txts, ys=ys, yscale=yscale, xLabel=r'top-$k$', yLabel=yLabel, title=r'top-$k$', fpath=fpath)

        alg_types = ['SPBase', 'SPBest']
        search_types = [0, 1]
        type = None

        ks = [1, 3, 5, 8, 10, 15, 20]
        base_dir = 'D:\\nowMask\KnowledgeBase\\sample_result\\yago2s_single_date\\k_nw\\'
        for search_index in range(len(search_types)):
            for alg_index in range(len(alg_types)):
                if alg_index==0:
                    if search_index==0: type=r'$SPTD$'
                    else:   type=r'$SPTR$'
                else:
                    if search_index==0: type=r'$SPTD^*$'
                    else:   type=r'$SPTR^*$'
                runtimes = []
                for k in ks:
                    data = Data.getData(fp=PathUtility.sample_res_path(base_dir, sp=alg_types[alg_index], nwlen=1000000, mds=1000, t=search_types[search_index], ns=200, r=2, k=k, nw=5, wf=500, dr=7))
                    print(data)
                    if 0==show_type: runtimes.append(data.timeTotal)
                    elif 1==show_type: runtimes.append(data.numTQSP)
                    elif 2==show_type: runtimes.append(data.numAccessedRTreeNode)
                chart.draw_line(runtimes, type)
        chart.show()
示例#8
0
 def loadCsv(dir, rFanout=50, alpha=0.5, steepD=0.1, h=15, om=1, oe='1.0E-4', ns=50, t=1, k=5000, nw=2, mpts=5,
                 eps='0.001', xi='0.001', maxPNeiByte=2147483631):
     fp = PathUtility.sample_res_path(dir, rFanout, alpha, steepD, h, om, oe, ns, t, k, nw, mpts,eps, xi, maxPNeiByte)
     filename = fp[fp.rindex('res') + 4:]
     alldata = []
     reader = IterableReader(fp)
     index = 0
     for line in reader:
         if index == 0:
             index += 1
             continue
         strArr = line.split(',')
         data = Data(filename)
         data.numSample = 1
         data.numRangeRtree = int(strArr[7])
         data.numOpticFastRange = int(strArr[16])
         data.numOpticLuceneRange = int(strArr[18])
         data.timeTotal = int(strArr[24])
         data.numCluster = int(strArr[25])
         alldata.append(data)
     return alldata
示例#9
0
    def draw_word_frequency(title='WORD_FREQUENCY', base_y=None, rotation=0, fpath='test.pdf'):
        if base_y!=None: ys = [base_y+i*100 for i in range(0, 14)]
        xs=[i for  i in  range(0, 10)]
        x_txts = [0, r'$5\times10^1$', r'$1\times10^2$',
                     r'$5\times10^2$', r'$1\times10^3$',
                     r'$5\times10^3$', r'$1\times10^4$',
                     r'$5\times10^4$', r'$1\times10^5$',
                     r'$1\times10^6$'
                 ]
        if base_y!=None: chart = LineChart(xs, x_txts, ys=ys, yscale='liner', xLabel=title, yLabel='Runtime (ms)', title=title, xlabel_rotation=rotation, fpath = fpath)
        else: chart = LineChart(xs, x_txts, xLabel=title, yLabel='Runtime (ms)', title=title, xlabel_rotation=rotation, fpath = fpath)

        # chart.ax.grid('on')

        wfs = [0, 50, 100, 500, 1000, 5000, 10000, 50000, 100000, 1000000]

        base_dir = 'D:\\nowMask\KnowledgeBase\\sample_result\\yago2s_single_date\\word_fequency_test\\'
        runtimes = []
        for wf in wfs:
            data = Data.getData(fp=PathUtility.sample_res_path(base_dir, wf=wf))
            runtimes.append(data.timeTotal)
        chart.draw_line(runtimes, r'$SPTD^*$')
        chart.show()