From a63aafe88b55c1c500646f5c93e9ff16780d37ca Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Fri, 24 Oct 2014 02:12:51 +0200 Subject: Add some stats --- main.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 8187e1f..dff07f5 100644 --- a/main.py +++ b/main.py @@ -50,17 +50,16 @@ ban_list = map_bans(ban_dict_list) ########## HISTOGRAM ########## ban_durations = [ban.get_duration() for ban in ban_list] -(ban_durations, bins) = np.histogram(ban_durations, bins=[round(365/12*x) for x in range(1, 50+2)]) +(ban_durations_bars, bins) = np.histogram(ban_durations, bins=[round(365/12*x) for x in range(1, 50+2)]) print("[INFO]", "Generating histogram") bar_chart = pygal.Bar(legend_at_bottom=True) bar_chart.title = "Active Wikipedia bans by duration (%d samples)" % SAMPLES -bar_chart.x_labels = map(str, range(1, len(ban_durations)+1)) -bar_chart.add("Number of active bans", ban_durations) +bar_chart.x_labels = map(str, range(1, len(ban_durations_bars)+1)) +bar_chart.add("Number of active bans", ban_durations_bars) bar_chart.render_to_file(HIST_FILE) print("[INFO]", "Histogram generation complete") - ########## NB BAN MAP ########## def count_by_country(ban_list): @@ -116,4 +115,10 @@ print("[INFO]", "Ban duration map generation complete") print("\nTHIS WAS A TRIUMPH!") print("I'M MAKING A NOTE HERE:") -print("HUGE [SUCCESS]") +print("HUGE [SUCCESS]\n") + +print("Some additional stats about ban durations:") +print(" Mean: %.2f days" % np.mean(ban_durations)) +print(" Median: %.2f days" % np.median(ban_durations)) +print(" Deviation: %.2f" % np.std(ban_durations)) +print(" Variance: %.2f" % np.var(ban_durations)) -- cgit v1.2.3