def main(dirn, fname):
    (xs, ysPerSolver, ydevsPerSolver) = CommonViz.parseData(dirn, fname)

    CommonConf.setupMPPDefaults()
    fmts = CommonConf.getLineFormats()
    mrkrs = CommonConf.getLineMarkers()
    fig = pp.figure()
    ax = fig.add_subplot(111)
    ax.set_xscale("log", basex=2)
    #ax.set_yscale("symlog" )

    index = 0
    for (solver, ys), (solver, ydevs) in zip(ysPerSolver.iteritems(),
                                             ydevsPerSolver.iteritems()):
        ax.errorbar(xs,
                    ys,
                    yerr=ydevs,
                    label=solver,
                    marker=mrkrs[index],
                    linestyle=fmts[index])
        index = index + 1

    ax.set_xlabel(X_LABEL)
    ax.set_ylabel(Y_LABEL)
    ax.legend(loc='best', fancybox=True)

    pp.savefig(dirn + "/" + fname + ".pdf")
    pp.show()
Ejemplo n.º 2
0
def main(dirn, fname):
    (xs, ysPerSolver, ydevsPerSolver) = CommonViz.parseData(dirn, fname)

    CommonConf.setupMPPDefaults()
    fmts = CommonConf.getLineFormats()
    mrkrs = CommonConf.getLineMarkers()
    fig = pp.figure()
    ax = fig.add_subplot(111)
    # ax.set_xscale("log", basex=2)

    index = 0
    for (solver, ys), (solver, ydevs) in zip(ysPerSolver.iteritems(),
                                             ydevsPerSolver.iteritems()):
        ax.errorbar(xs,
                    ys,
                    yerr=ydevs,
                    label=solver,
                    marker=mrkrs[index],
                    linestyle=fmts[index])
        index = index + 1

    ax.set_xlabel(X_LABEL)
    ax.set_ylabel(Y_LABEL)
    ax.legend(loc='best', fancybox=True)

    # ax.get_yaxis().set_major_formatter(
    #   matplotlib.ticker.FuncFormatter(lambda x, p: format(int(x/1000000), ',')))

    ax.get_xaxis().set_major_formatter(
        matplotlib.ticker.FuncFormatter(
            lambda x, p: format(int(x * 100), ',')))

    pp.savefig(dirn + "/" + fname + ".pdf")
    pp.show()
def main(dirn, fname): 
  (xs, ysPerSolver, ydevsPerSolver) = CommonViz.parseData(dirn, fname)
     
  CommonConf.setupMPPDefaults()
  fmts = CommonConf.getLineFormats()
  mrkrs = CommonConf.getLineMarkers()
  fig = pp.figure()
  ax = fig.add_subplot(111)
  # ax.set_xscale("log", basex=2)

  index = 0
  for (solver, ys), (solver, ydevs) in zip(ysPerSolver.iteritems(),ydevsPerSolver.iteritems()) : 
    ax.errorbar(xs, ys, yerr=ydevs, label=solver, marker=mrkrs[index], linestyle=fmts[index])
    index = index + 1

  ax.set_xlabel(X_LABEL);
  ax.set_ylabel(Y_LABEL);
  ax.legend(loc='best', fancybox=True)

  ax.get_yaxis().set_major_formatter(
    matplotlib.ticker.FuncFormatter(lambda x, p: format(int(x/1000000), ',')))

  ax.get_xaxis().set_major_formatter(
    matplotlib.ticker.FuncFormatter(lambda x, p: format(int(x * 100), ',')))
  
  pp.savefig(dirn+"/"+fname+".pdf")
  pp.show()
Ejemplo n.º 4
0
def main(dirn, fname):
    blockSizes = []
    localitiesPerApproach = OrderedDict()

    with open(dirn + "/" + fname + ".dat") as fin:
        lines = fin.readlines()

        for line in lines:
            if line.startswith("#"):
                continue
            (blockSize, approach, locality, nline) = re.split("[\t]", line)
            blockSize = float(blockSize)
            locality = float(locality)
            if approach in localitiesPerApproach:
                localitiesPerApproach[approach].append(locality)
            else:
                localitiesPerApproach[approach] = [locality]
            if len(blockSizes) == 0 or blockSize > blockSizes[-1]:
                blockSizes.append(blockSize)

    CommonConf.setupMPPDefaults()
    fmts = CommonConf.getLineFormats()
    mrkrs = CommonConf.getLineMarkers()
    fig = pp.figure()
    ax = fig.add_subplot(111)
    #ax.set_xscale("log", basex=2)

    index = 0
    for approach, localities in localitiesPerApproach.iteritems():
        ax.plot(blockSizes,
                localities,
                label=approach,
                marker=mrkrs[index],
                linestyle=fmts[index])
        index = index + 1

    ax.set_xlabel('block size (bytes)')
    ax.set_ylabel('locality')
    # ax.set_xlim(0, 2100)
    ax.legend(loc='best', fancybox=True)

    pp.savefig(dirn + "/" + fname + ".pdf")
    pp.show()
Ejemplo n.º 5
0
def main(dirn, fname, solvers):
  (xs, ysPerSolver, ydevsPerSolver) = CommonViz.parseData(dirn, fname, solvers)

  CommonConf.setupMPPDefaults()
  fmts = CommonConf.getLineFormats()
  mrkrs = CommonConf.getLineMarkers()
  fig = pp.figure()
  ax = fig.add_subplot(111)
  # ax.set_xscale("log", basex=2)

  index = 0
  for (solver, ys), (solver, ydevs) in zip(ysPerSolver.iteritems(),ydevsPerSolver.iteritems()) :
    ax.errorbar(xs, ys, yerr=ydevs, label=solver, marker=mrkrs[index], linestyle=fmts[index])
    index = index + 1

  ax.set_xlabel(X_LABEL);
  ax.set_ylabel(Y_LABEL);
  ax.legend(loc='best', fancybox=True)

  pp.savefig(dirn+"/"+fname+"-".join(solvers)+".svg")
Ejemplo n.º 6
0
def main(dirn, fname):
  blockSizes = []
  localitiesPerApproach = OrderedDict()

  with open(dirn+"/"+fname+".dat") as fin:
    lines = fin.readlines()

    for line in lines:
      if line.startswith("#"):
        continue
      (blockSize, approach, locality, nline) = re.split("[\t]", line)
      blockSize = float(blockSize)
      locality = float(locality)
      if approach in localitiesPerApproach:
        localitiesPerApproach[approach].append(locality)
      else:
        localitiesPerApproach[approach] = [locality]
      if len(blockSizes) == 0 or blockSize > blockSizes[-1]:
        blockSizes.append(blockSize)

  CommonConf.setupMPPDefaults()
  fmts = CommonConf.getLineFormats()
  mrkrs = CommonConf.getLineMarkers()
  fig = pp.figure()
  ax = fig.add_subplot(111)
  #ax.set_xscale("log", basex=2)
    
  index = 0
  for approach, localities in localitiesPerApproach.iteritems():
    ax.plot(blockSizes, localities, label=approach, 
            marker=mrkrs[index], linestyle=fmts[index])
    index = index + 1

  ax.set_xlabel('block size (bytes)');
  ax.set_ylabel('locality');
  # ax.set_xlim(0, 2100)
  ax.legend(loc='best', fancybox=True)

  pp.savefig(dirn+"/"+fname+".pdf")
  pp.show()
Ejemplo n.º 7
0
def plotfigure(metric_name, dotfile, mode):
    curf = "expData"
    todofolder = [
        f for f in listdir(curf)
        if op.isdir(op.join(curf, f)) & ("burst_" + mode + "_" + dotfile in f)
    ]
    mydict = {}
    curname = 0
    totiter = 0
    xx = []
    for folder in todofolder:
        print(folder)
        xx.append(100 * float(folder[folder.rfind('_') + 1:]))
        curname += 1
        picked_file = [
            f for f in listdir(op.join(curf, folder))
            if op.isfile(op.join(curf, folder, f))
            & (metric_name + '.dat' in f) & (not 'swp' in f)
        ]
        if (len(picked_file) > 1):
            assert (False)
        picked_file = picked_file[0]
        f = open(op.join(curf, folder, picked_file))
        for line in f.readlines():
            if "solver" in line:
                continue
            words = line.split("\t")
            if (len(words) < 4):
                continue
            if (not words[0] in mydict):
                mydict[words[0]] = [[] for i in range(len(todofolder))]
            if (int(words[1]) > totiter):
                totiter = int(words[1])
            mydict[words[0]][curname - 1].append(float(words[2]))
    mean_list = {}
    var_list = {}
    for alg in mydict:
        mean_list[alg] = OrderedDict()
        var_list[alg] = OrderedDict()
        i = 0
        for all_num in mydict[alg]:
            #mean_list[alg][xx[i]]=numpy.mean(numpy.array(all_num), axis=0)
            #var_list [alg][xx[i]]=numpy.std(numpy.array(all_num), axis=0)
            mean_list[alg][xx[i]] = all_num[flash_time]
            var_list[alg][xx[i]] = 0
            i += 1

    totiter += 1
    fig = pp.figure(figsize=(18, 9))
    dotted = 0
    m = CommonConf.getLineMarkers()
    linest = CommonConf.getLineFormats()
    colors = CommonConf.getLineColors()

    for alg in sorted(mydict):
        print(alg, ':')
        for key in sorted(mean_list[alg]):
            print(key, mean_list[alg][key])
        ml = []
        kl = []
        vl = []
        for key in sorted(mean_list[alg]):
            kl.append(key)
            ml.append(mean_list[alg][key])
            vl.append(var_list[alg][key])
        xs = np.asarray(kl) + random.random() * 3
        pp.errorbar(xs,
                    ml,
                    vl,
                    label=alg,
                    linestyle=linest[dotted],
                    marker=m[dotted],
                    color=colors[dotted])
        dotted += 1
    x1, x2, y1, y2 = pp.axis()
    pp.axis((x1, x2 + 0.1, y1, y2 + 0.05))
    pp.legend(loc='best', prop={'size': 14}, bbox_to_anchor=(1.02, 1))
    pp.tight_layout(pad=20)
    pp.xlabel('Burst amount')
    pp.ylabel(metric_name)
    pp.savefig("expData/burst_" + dotfile + "_" + metric_name + ".svg")
    pp.close(fig)
Ejemplo n.º 8
0
def plotfigure(metric_name,dotfile):
    curf="expData";
    todofolder=[f for f in listdir(curf) if op.isdir(op.join(curf, f)) & ("prediction_"+dotfile in f) ]
    mydict={}
    curname=0;
    totiter=0
    xx=[]
    for folder in todofolder:
        xx.append(100*float(folder[len("prediction_"+dotfile):]))
        curname += 1
        picked_file=[f for f in listdir(op.join(curf,folder)) if op.isfile(op.join(curf,folder, f)) & (metric_name+'.dat' in f) & (not 'swp' in f)]
        if (len(picked_file)>1):
            assert(False)
        picked_file=picked_file[0]
        f=open(op.join(curf,folder,picked_file))
        for line in f.readlines():
            if "solver" in line:
                continue
            words=line.split("\t")
            if (len(words)<4):
                continue
            if (not words[0] in mydict):
                mydict[words[0]]=[[] for i in range(len(todofolder))]
            if (int(words[1])>totiter):
                totiter=int(words[1])
            mydict[words[0]][curname-1].append(float(words[2]))
    mean_list={}
    var_list={}
    for alg in mydict:
        mean_list[alg]=OrderedDict()
        var_list[alg]=OrderedDict()
        i=0
        for all_num in mydict[alg]:
            mean_list[alg][xx[i]]=numpy.mean(numpy.array(all_num), axis=0)
            var_list [alg][xx[i]]=numpy.std(numpy.array(all_num), axis=0)
            i+=1

    totiter+= 1
    fig=pp.figure(figsize=(18,9))
    dotted=0
    m=CommonConf.getLineMarkers()
    linest=CommonConf.getLineFormats()
    colors=CommonConf.getLineColors()


    for alg in sorted(mydict):
        print(alg,':')
        for key in sorted(mean_list[alg]):
            print(key,mean_list[alg][key])
        ml=[]
        kl=[]
        vl=[]
        for key in sorted(mean_list[alg]):
            kl.append(key)
            ml.append(mean_list[alg][key])
            vl.append(var_list[alg][key])
        xs=np.asarray(kl)+random.random()*5
        pp.errorbar(xs,ml,vl,label=alg, linestyle=linest[dotted], marker=m[dotted],color=colors[dotted])
        dotted+=1
    x1,x2,y1,y2 = pp.axis()
    pp.axis((x1,x2+0.1,y1,y2+0.05))
    pp.legend(loc='best',prop={'size':14},bbox_to_anchor=(1.02, 1))
    pp.tight_layout(pad=20)
    pp.xlabel('Random perturbation %')
    pp.ylabel(metric_name)
    pp.savefig("expData/prediction_"+dotfile+"_"+metric_name+".svg")
    #pp.show()
    pp.close(fig)