Exemplo n.º 1
0
    b_patch = mpatches.Patch(color="b",
                             label=a_description + " (total: " +
                             str(len(a_scores_a1)) + ", " +
                             str(len(a_scores)) + ")")
    g_patch = mpatches.Patch(color="g",
                             label=b_description + " (total: "  +
                             str(len(b_scores_a1)) + ", " +
                             str(len(b_scores)) + ")")
    plt.legend(handles=[b_patch, g_patch])

    filename = str(a_description) + " vs " + str(b_description) + ".png"
    plt.savefig(filename, bbox_inches="tight")
    print('Created chart "' + filename + '"')

# get all groups of users that we want to compare
everyone = corpus.users()
justices = corpus.users(lambda u: u.info["is-justice"])
lawyers = corpus.users(lambda u: not u.info["is-justice"])
fav_justices = corpus.users(lambda u: u.info["is-justice"] and
        u.info["justice-is-favorable"])
unfav_justices = corpus.users(lambda u: u.info["is-justice"] and
        not u.info["justice-is-favorable"])

# do lawyers coordinate more to justices than the other way around?
make_chart(
    coord.score(justices, lawyers, target_thresh=6),
    coord.score(lawyers, justices, target_thresh=6),
    "Justices to lawyers", "Lawyers to justices", "g", "b"
)
# do lawyers coordinate more to unfavorable or favorable justices?
make_chart(
Exemplo n.º 2
0
    a_scores_a1 = [s for s in a_scores if len(a_scores[s]) == 8]
    b_scores_a1 = [s for s in b_scores if len(b_scores[s]) == 8]
    b_patch = mpatches.Patch(color="b",
                             label=a_description + " (total: " +
                             str(len(a_scores_a1)) + ", " +
                             str(len(a_scores)) + ")")
    g_patch = mpatches.Patch(color="g",
                             label=b_description + " (total: " +
                             str(len(b_scores_a1)) + ", " +
                             str(len(b_scores)) + ")")
    plt.legend(handles=[b_patch, g_patch])

    filename = str(a_description) + " vs " + str(b_description) + ".png"
    plt.savefig(filename, bbox_inches="tight")
    print('Created chart "' + filename + '"')


# get all groups of users that we want to compare
everyone = corpus.users()
admins = corpus.users(lambda u: u.info["is-admin"])
nonadmins = everyone - admins

# do users on the whole coordinate more to admins or nonadmins?
make_chart(coord.score(everyone, admins, focus="targets", target_thresh=7),
           coord.score(everyone, nonadmins, focus="targets", target_thresh=7),
           "Target: admins", "Target: nonadmins")
# do admins coordinate to other people more than nonadmins do?
make_chart(coord.score(admins, everyone, speaker_thresh=7, target_thresh=7),
           coord.score(nonadmins, everyone, speaker_thresh=7, target_thresh=7),
           "Speaker: admins", "Speaker: nonadmins")