Exemplo n.º 1
0
def plot_without_first():

    plot_name = inp + "_without_first_plot.png"

    # Reading the results
    res_path = "../old_results/" + inp
    rej_path = res_path + "/rejected_results"
    res = rr.get_results(res_path, inp)
    rej_res = rr.get_results(rej_path, inp)

    # Make empty list of lists
    list_stack = []
    for i in range(count):
        tmp_list = []
        list_stack.append(tmp_list)

    # function to sort results into corresponding lists
    def sort_results(res, grade_order_list):
        for user in res:
            pair = []
            pair.append(user[0])
            pair.append(user[1])
            grade_order_list.append(pair)

    grade_order_list = []
    rej_grade_order_list = []

    sort_results(res, grade_order_list)
    sort_results(rej_res, rej_grade_order_list)

    # Generate grades without first in order list
    for pair in grade_order_list:
        for i in range(1, count):
            order = pair[1][i]
            grade = pair[0][order - 1]
            list_stack[order - 1].append(grade)
                
    means = []
    std_errs = []
    for grades in list_stack:
        mean = np.mean(grades)
        means.append(mean)
        std = np.std(grades)
        se = std / np.sqrt(len(grades))
        std_errs.append(se)

    # x axis configuration
    x = []
    x_label = ""

    # Plot Graph
    plt.figure()
    plt.style.use('ggplot')
    plt.xlabel(x_label)
    plt.ylabel('grade')
    plt.plot(x, means, "blue")
    plt.errorbar(x, means, yerr=std_errs, fmt="-o", ecolor="red", alpha=0.5)
    plt.legend(['mean','Standard Error'],
                loc='upper right',
                numpoints=1,
                fancybox=True)
    plt.savefig(plot_name)

    return [means, std_errs, list_stack]
Exemplo n.º 2
0
def count_network(net, arr):
    if net == "WiFi":
        arr[0] += 1
    elif net == "Cable network":
        arr[1] += 1
    elif net == "Cellular network":
        arr[2] += 1
    elif net == "Other":
        arr[3] += 1


# Reading the results
res_path = "../results"
rej_path = "../rejected_results"
res = rr.get_results(res_path, inp)
rej_res = rr.get_results(rej_path, inp)


# function to sort results into corresponding lists
def sort_results(res, grade_list, order_list, vid_time_list, grade_time_list,
                 user_reason_list, device_arr, age_arr, network_arr):
    for user in res:
        grade_list.append(user[0])
        order_list.append(user[1])
        vid_time_list.append(user[2])
        grade_time_list.append(user[3])
        count_device(user[5], device_arr)
        count_age(user[6], age_arr)
        count_network(user[7], network_arr)
        # make a pair of userID and reason
Exemplo n.º 3
0
def plot_by_before():

    plot_name = inp + "_by_before_plot.png"

    # Reading the results
    res_path = "../old_results/" + inp
    rej_path = res_path + "/rejected_results"
    res = rr.get_results(res_path, inp)
    rej_res = rr.get_results(rej_path, inp)

    # Make empty list of lists
    list_stack = [[], []]

    # function to sort results into corresponding lists
    def sort_results(res, grade_order_list):
        for user in res:
            pair = []
            pair.append(user[0])
            pair.append(user[1])
            grade_order_list.append(pair)

    grade_order_list = []
    rej_grade_order_list = []

    sort_results(res, grade_order_list)
    sort_results(rej_res, rej_grade_order_list)

    # Get grades based on if first video is unbuffered and grade given
    for pair in grade_order_list:
        for i in range(count):
            if i != 0 and pair[1][
                    i] == mid:  # find middle video and check not first
                before = pair[1][i - 1]
                grade = pair[0][mid - 1]
                if before < mid:
                    list_stack[0].append(grade)
                elif before > mid:
                    list_stack[1].append(grade)

    means = []
    std_errs = []

    for grades in list_stack:
        mean = np.mean(grades)
        means.append(mean)
        std = np.std(grades)
        se = std / np.sqrt(len(grades))
        std_errs.append(se)

    # x axis configuration
    x = ["better video", "worse video"]
    x_label = "Preceding Video Quality"

    # Plot Graph
    plt.figure()
    plt.style.use('ggplot')
    plt.xlabel(x_label)
    plt.ylabel('grade')

    plt.plot(x, means, "blue")
    plt.errorbar(x, means, yerr=std_errs, fmt="-o", ecolor="red", alpha=0.5)
    plt.legend(loc='upper right', numpoints=1, fancybox=True)
    plt.savefig(plot_name)

    return [means, std_errs, list_stack]
def single_order_plot(num_graph):

    # Check for correct inputs
    if (num_graph < 0) or (num_graph > count):
        print("Invalid video number")
        exit(0)

    elif num_graph == 0:
        plot_name = inp + "_order_plot_overall.png"

    else:
        plot_name = inp + "_order_plot_video_" + str(num_graph) + ".png"

    # Reading the results
    res_path = "../results"
    rej_path = "../rejected_results"
    res = rr.get_results(res_path, inp)
    rej_res = rr.get_results(rej_path, inp)

    # Make empty list of lists
    list_stack = []
    for i in range(count):
        tmp_list = []
        list_stack.append(tmp_list)

    # function to sort results into corresponding lists
    def sort_results(res, grade_order_list):
        for user in res:
            pair = []
            pair.append(user[0])
            pair.append(user[1])
            grade_order_list.append(pair)

    grade_order_list = []
    rej_grade_order_list = []

    sort_results(res, grade_order_list)
    sort_results(rej_res, rej_grade_order_list)

    # Plot overall
    if num_graph == 0:
        for pair in grade_order_list:
            i = 0
            for order in pair[1]:
                grade = pair[0][order - 1]
                list_stack[i].append(grade)
                i += 1

    #Plot given a certain video
    else:
        for pair in grade_order_list:
            i = 0
            for order in pair[1]:
                if num_graph == order:
                    grade = pair[0][num_graph - 1]
                    list_stack[i].append(grade)
                    break
                i += 1

    means = []
    std_errs = []
    for grades in list_stack:
        mean = np.mean(grades)
        means.append(mean)
        std = np.std(grades)
        se = std / np.sqrt(len(grades))
        std_errs.append(se)

    # x axis configuration
    x = range(1, count + 1)
    x_label = "Video Order"

    # Plot Graph
    plt.figure()
    plt.style.use('ggplot')
    plt.xlabel(x_label)
    plt.ylabel('grade')
    plt.plot(x, means, "blue")
    plt.errorbar(x, means, yerr=std_errs, fmt="-o", ecolor="red", alpha=0.5)
    plt.legend(['mean', 'Standard Error'],
               loc='upper right',
               numpoints=1,
               fancybox=True)
    plt.savefig(plot_name)

    return [means, std_errs]
Exemplo n.º 5
0
def plot_by_first_score():

    plot_name = inp + "_by_first_score_plot.png"

    # Reading the results
    res_path = "../old_results/" + inp
    rej_path = res_path + "/rejected_results"
    res = rr.get_results(res_path, inp)
    rej_res = rr.get_results(rej_path, inp)

    # Make empty list of lists
    list_stack = []
    for i in range(2):
        tmp_list = []
        for j in range(count - 1):
            tmp2_list = []
            tmp_list.append(tmp2_list)
        list_stack.append(tmp_list)

    # function to sort results into corresponding lists
    def sort_results(res, grade_order_list):
        for user in res:
            pair = []
            pair.append(user[0])
            pair.append(user[1])
            grade_order_list.append(pair)

    grade_order_list = []
    rej_grade_order_list = []

    sort_results(res, grade_order_list)
    sort_results(rej_res, rej_grade_order_list)

    # Get grades based on if first video is unbuffered and grade given
    for pair in grade_order_list:
        if pair[1][0] == 1:  # check if first video is unbuffered
            grade = pair[0][0]
            if grade == 1 or grade == 2 or grade == 3:  # low grade
                for i in range(count - 1):
                    const_vid_grade = pair[0][i + 1]
                    list_stack[0][i].append(const_vid_grade)
            else:
                for i in range(count - 1):
                    const_vid_grade = pair[0][i + 1]
                    list_stack[1][i].append(const_vid_grade)

    means = []
    std_errs = []
    for i in range(count - 1):
        means.append([0, 0])
        std_errs.append([0, 0])

    for i in range(count - 1):
        for j in range(2):
            mean = np.mean(list_stack[j][i])
            means[i][j] = mean
            std = np.std(list_stack[j][i])
            se = std / np.sqrt(len(list_stack[j][i]))
            std_errs[i][j] = se

    # x axis configuration
    x = ["low (1-3)", "high (4-5)"]
    x_label = "Unbuffered Video Score"

    # Plot Graph
    plt.figure()
    plt.style.use('ggplot')
    plt.xlabel(x_label)
    plt.ylabel('grade')
    for i in range(count - 1):
        plt.plot(x, means[i], label=str(i + 2))
#        plt.errorbar(x, means[i], yerr=std_errs[i], fmt="-o", ecolor="red", alpha=0.5)
    plt.legend(title="Constant Video",
               loc='upper right',
               numpoints=1,
               fancybox=True)
    plt.savefig(plot_name)

    return [means, std_errs, list_stack]