def accuracyPlot(topo_types, task_types, trace_types, pair_seq=0):

    accuracys, errors, x = [], [], None
    cherns, chern_errors, chern_x = [], [], None
    acc_boxplot_data = []

    for trace_type in trace_types:
        topo_type = topo_types[1]
        task_type = task_types[0]
        if topo_type == topo_types[0]:
            pair_num = 4
        elif topo_type == topo_types[1]:
            pair_num = 8
        elif topo_type == topo_types[2]:
            pair_num = 14

        infile_name1, infile_name2 = init_files(trace_type,
                                                task_type,
                                                topo_type,
                                                x_var='PVALUE')

        group_fields = ['#flows', 'is_correlated', 'key']
        agg_fields = ['count_chern', 'byte_chern']
        chern_x, case_num, acc_dict = retieveData(infile_name2,
                                                  group_fields,
                                                  agg_fields,
                                                  accuracys,
                                                  errors,
                                                  div=False,
                                                  pair_num=pair_num)
        acc_boxplot_data.append(acc_dict.values())

    acc_legend = ['Database', 'Web', 'Hadoop']
    xlabel, ylabel = 'The threshold for p-value', 'Average accuracy'
    print accuracys, chern_x
    pl.plot(accuracys,
            x=chern_x,
            k=2,
            errors=errors,
            xlabel=xlabel,
            ylabel=ylabel,
            title=infile_name1,
            xlog=False,
            ylog=False,
            acc_legend=acc_legend,
            legend_y=0.85)
    print acc_boxplot_data

    pl.box_plot([acc_boxplot_data[0]],
                x=chern_x,
                k=2,
                errors=errors,
                xlabel=xlabel,
                ylabel=ylabel,
                title=infile_name1,
                xlog=False,
                ylog=False,
                acc_legend=acc_legend,
                legend_y=0.85,
                xticks=[str(i) for i in chern_x])
示例#2
0
def accuracyPlot(topo_types, task_types, trace_types, pair_seq=0):
    
    accuracys, errors, x = [], [], None
    cherns, chern_errors, chern_x = [], [], None
    acc_boxplot_data = []
    q_75ss, xss = [], []
    
    for topo_type in topo_types[0:3]:
        trace_type = trace_types[0]
        task_type = task_types[0]
        if topo_type == topo_types[0]:
            pair_num = 4
        elif topo_type == topo_types[1]:
            pair_num = 8
        elif topo_type == topo_types[2]:
            pair_num = 14
        
        infile_name1, infile_name2 = init_files(
                                    trace_type, task_type, topo_type,
                                    x_var = 'CHERNPVALUEBYTE' #CHERNPVALUE
        )
        
        infile_name3, infile_name4 = init_files(
                                    trace_type, task_type, topo_type,
                                    x_var = 'TTESTPVALUEBYTE'
        )
        key_field = 'epsilon'
        group_fields = [key_field,'is_correlated', 'key']
        agg_fields = ['count_chern', 'byte_chern']
        chern_x, case_num, acc_dict = retieveData(
                infile_name2, group_fields, agg_fields, 
                accuracys, errors, div=False, pair_num=pair_num, q_75ss=q_75ss,
                key_field=key_field, topo_type=topo_type, xss=xss
        )
        chern_x, case_num, acc_dict = retieveData(
                infile_name4, group_fields, agg_fields, 
                accuracys, errors, div=False, pair_num=pair_num, q_75ss=q_75ss,
                key_field=key_field, topo_type=topo_type, xss=xss
        )
        acc_boxplot_data.append(acc_dict.values())
    
    acc_legend = ['B4-Chernoff', 'B4-t-test','Tree-Chernoff', 'Tree-t-test', 'Jupiter-Chernoff', 'Jupiter-t-test']
    xlabel, ylabel = '$P_b$', 'Average accuracy' #'Relative elephant flow size'
    print 'accuracys, chern_x', len(accuracys[0]), len(chern_x)
    print accuracys, xss
    pl.plot(accuracys, x=xss, k=2, errors=[], 
        xlabel=xlabel, ylabel=ylabel, title=infile_name1.split('/outputs')[1].split('.csv')[0].replace('.', '_'), 
        xlog=True, ylog=False, acc_legend=acc_legend, legend_x=0.0,
        legend_y=0.3
    )
    print acc_boxplot_data
    
    pl.box_plot([acc_boxplot_data[0]], x=chern_x, k=2, errors=errors, 
        xlabel=xlabel, ylabel=ylabel, title=infile_name1.split('/outputs')[1].split('.csv')[0].replace('.', '_'), 
        xlog=False, ylog=False, acc_legend=acc_legend,
        legend_y=0.85, xticks=[str(i) for i in chern_x])
示例#3
0
def accuracyPlot(topo_types, task_types, trace_types, pair_seq=0):

    accuracys, errors, x = [], [], None
    cherns, chern_errors, chern_x = [], [], None
    acc_boxplot_data = []
    q_75ss, xss = [], []

    for topo_type in topo_types[2:3]:
        trace_type = 'ABC'
        task_type = task_types[2]
        if topo_type == topo_types[0]:
            pair_num = 4
        elif topo_type == topo_types[1]:
            pair_num = 8
        elif topo_type == topo_types[2]:
            pair_num = 16

        infile_name1, infile_name2 = init_files(
            trace_type,
            task_type,
            topo_type,
            x_var='TOPKBIASONEFIVE'  #CHERNPVALUE
        )
        infile_name3, infile_name4 = init_files(
            trace_type,
            task_type,
            topo_type,
            x_var='TOPKBIASSMALL'  #CHERNPVALUE
        )
        infile_name5, infile_name6 = init_files(
            trace_type,
            task_type,
            topo_type,
            x_var='TOPK'  #CHERNPVALUE
        )

        key_field = 'topk'
        group_fields = [key_field, 'is_correlated', 'key']
        agg_fields = ['count_chern', 'byte_chern']
        chern_x, case_num, acc_dict = retieveData(infile_name2,
                                                  group_fields,
                                                  agg_fields,
                                                  accuracys,
                                                  errors,
                                                  div=False,
                                                  pair_num=pair_num,
                                                  q_75ss=q_75ss,
                                                  key_field=key_field,
                                                  topo_type=topo_type,
                                                  xss=xss)
        acc_boxplot_data.append(acc_dict.values())
        agg_fields = ['count_chern', 'byte_chern']
        chern_x, case_num, acc_dict = retieveData(infile_name4,
                                                  group_fields,
                                                  agg_fields,
                                                  accuracys,
                                                  errors,
                                                  div=False,
                                                  pair_num=pair_num,
                                                  q_75ss=q_75ss,
                                                  key_field=key_field,
                                                  topo_type=topo_type,
                                                  xss=xss)
        acc_boxplot_data.append(acc_dict.values())
        agg_fields = ['count_chern', 'byte_chern']
        chern_x, case_num, acc_dict = retieveData(infile_name6,
                                                  group_fields,
                                                  agg_fields,
                                                  accuracys,
                                                  errors,
                                                  div=False,
                                                  pair_num=pair_num,
                                                  q_75ss=q_75ss,
                                                  key_field=key_field,
                                                  topo_type=topo_type,
                                                  xss=xss)
        acc_boxplot_data.append(acc_dict.values())

    acc_legend = [
        'dropping rate = 0.1', 'dropping rate = 0.15', 'dropping rate = 0.2'
    ]
    xlabel, ylabel = 'The number of links', 'Average accuracy'  #'Relative elephant flow size'
    print 'accuracys, chern_x', len(accuracys[0]), len(chern_x)
    print accuracys, xss
    pl.plot(accuracys,
            x=xss,
            k=2,
            errors=q_75ss,
            xlabel=xlabel,
            ylabel=ylabel,
            title=infile_name1.split('/outputs')[1].split('.csv')[0].replace(
                '.', '_'),
            xlog=False,
            ylog=False,
            acc_legend=acc_legend,
            legend_x=0.3,
            legend_y=0.2)
    print len(acc_boxplot_data)

    chern_x = [2 * x for x in chern_x]
    pl.box_plot(
        acc_boxplot_data,
        x=chern_x,
        k=2,
        errors=errors,
        xlabel=xlabel,
        ylabel=ylabel,
        title=infile_name1.split('/outputs')[1].split('.csv')[0].replace(
            '.', '_'),
        xlog=False,
        ylog=False,
        acc_legend=[],
        legend_y=0.85,
        xticks=[str(i) for i in chern_x])
def accuracyPlot(topo_types, task_types, c, pair_seq=0):

    accuracys, errors, times, x = [], [], [], None
    cherns, chern_errors, chern_x = [], [], None
    acc_boxplot_data = []
    q_75ss, xss = [], []

    for topo_type in topo_types[0:3]:
        trace_type = trace_types[0]
        task_type = task_types[0]
        if topo_type == topo_types[0]:
            pair_num = 4
        elif topo_type == topo_types[1]:
            pair_num = 8
        elif topo_type == topo_types[2]:
            pair_num = 14

        infile_name1, infile_name2 = init_files(trace_type,
                                                task_type,
                                                topo_type,
                                                x_var='XFLOWNUM')

        infile_name3, infile_name4 = init_files(trace_type,
                                                task_type,
                                                topo_type,
                                                x_var='TTESTFLOWNUM')

        infile_name5, infile_name6 = init_files(trace_type,
                                                task_type,
                                                topo_type,
                                                x_var='CHERNTTFLOWNUM')

        group_fields = ['#flows', 'is_correlated', 'key']
        agg_fields = ['count_chern', 'byte_chern']
        chern_x, case_num, acc_dict = retieveData(infile_name2,
                                                  group_fields,
                                                  agg_fields,
                                                  accuracys,
                                                  errors,
                                                  times,
                                                  div=False,
                                                  pair_num=pair_num,
                                                  q_75ss=q_75ss,
                                                  xss=xss)
        chern_x, case_num, acc_dict = retieveData(infile_name4,
                                                  group_fields,
                                                  agg_fields,
                                                  accuracys,
                                                  errors,
                                                  times,
                                                  div=False,
                                                  pair_num=pair_num,
                                                  q_75ss=q_75ss,
                                                  xss=xss)
        """chern_x, case_num, acc_dict = retieveData(
                infile_name6, group_fields, agg_fields, 
                accuracys, errors, times, div=False, pair_num=pair_num, q_75ss=q_75ss
        )"""
        acc_boxplot_data.append(acc_dict.values())

    acc_legend = [
        'B4-Chernoff', 'B4-t-test', 'Tree-Chernoff', 'Tree-t-test',
        'Jupiter-Chernoff', 'Jupiter-t-test'
    ]
    xlabel, ylabel = 'The number of flows', 'Average accuracy'
    len_x = min([len(acc) for acc in accuracys])
    #accuracys = [acc[:len_x] for acc in accuracys]
    #chern_x = chern_x[:len_x]
    plot_cut = 20
    accuracys = [acc[:plot_cut] for acc in accuracys]
    q_75ss = [[q_75[0][:plot_cut], q_75[1][:plot_cut]] for q_75 in q_75ss]
    print len(chern_x), len(accuracys[0]), q_75ss[0]
    print xss
    pl.plot(accuracys,
            x=xss,
            k=2,
            errors=[],
            xlabel=xlabel,
            ylabel=ylabel,
            title=infile_name1.split('/outputs')[1].split('.csv')[0].replace(
                '.', '_'),
            xlog=False,
            ylog=False,
            acc_legend=acc_legend,
            legend_y=0.3,
            legend_x=0.45)

    times = [time[:plot_cut] for time in times]
    pl.plot(times,
            x=xss,
            k=2,
            errors=[],
            xlabel=xlabel,
            ylabel='Execution time (seconds)',
            title=infile_name1.split('/outputs')[1].split('.csv')[0].replace(
                '.', '_') + '_time',
            xlog=False,
            ylog=False,
            acc_legend=acc_legend,
            legend_y=0.8,
            legend_x=0.0)

    pl.box_plot(
        [acc_boxplot_data[0]],
        x=chern_x,
        k=2,
        errors=errors,
        xlabel=xlabel,
        ylabel=ylabel,
        title=infile_name1.split('/outputs')[1].split('.csv')[0].replace(
            '.', '_'),
        xlog=False,
        ylog=False,
        acc_legend=acc_legend,
        legend_y=0.85,
        xticks=[str(i) for i in chern_x])
def accuracyPlot(topo_types, task_types, trace_types, pair_seq=0):

    accuracys, errors, x = [], [], None
    cherns, chern_errors, chern_x = [], [], None
    acc_boxplot_data = []
    q_75ss = []

    for topo_type in topo_types[0:2]:
        trace_type = trace_types[0]
        task_type = task_types[0]
        if topo_type == topo_types[0]:
            pair_num = 4
        elif topo_type == topo_types[1]:
            pair_num = 8
        elif topo_type == topo_types[2]:
            pair_num = 14

        infile_name1, infile_name2 = init_files(trace_type,
                                                task_type,
                                                topo_type,
                                                x_var='TTESTRTHRESHOLD')

        group_fields = ['r_threshold', 'is_correlated', 'key']
        agg_fields = ['count_chern', 'byte_chern']
        chern_x, case_num, acc_dict = retieveData(infile_name2,
                                                  group_fields,
                                                  agg_fields,
                                                  accuracys,
                                                  errors,
                                                  div=False,
                                                  pair_num=pair_num,
                                                  q_75ss=q_75ss)
        acc_boxplot_data.append(acc_dict.values())

    acc_legend = ['Database', 'Web', 'Hadoop']
    xlabel, ylabel = '$P_b$', 'Average accuracy'
    print 'accuracys, chern_x', len(accuracys[0]), len(chern_x)
    pl.plot(accuracys,
            x=chern_x,
            k=2,
            errors=q_75ss,
            xlabel=xlabel,
            ylabel=ylabel,
            title=infile_name1.split('/outputs')[1].split('.csv')[0].replace(
                '.', '_'),
            xlog=False,
            ylog=False,
            acc_legend=acc_legend,
            legend_x=0.2,
            legend_y=0.2)
    print acc_boxplot_data

    pl.box_plot(
        [acc_boxplot_data[0]],
        x=chern_x,
        k=2,
        errors=errors,
        xlabel=xlabel,
        ylabel=ylabel,
        title=infile_name1.split('/outputs')[1].split('.csv')[0].replace(
            '.', '_'),
        xlog=False,
        ylog=False,
        acc_legend=acc_legend,
        legend_y=0.85,
        xticks=[str(i) for i in chern_x])