def crime_comparisons(dataframe, crimes_obj):
	'''Handles the functionalities of different crime comparisons'''

	GUI4.start_user_interface()
	crime_1, crime_2 = GUI4.get_crimes()
	crimes_per_student_state = handlers.average_crimes_per_student_by_category(dataframe, 'State', crimes_obj, overall_average = True)
	crimes_per_student_sector = handlers.average_crimes_per_student_by_category(dataframe, 'Sector_desc', crimes_obj, overall_average = True)

	pltparam = plotting.pltParam()
	answers_obj = plots.Answers(crimes_obj, None, pltparam, None, None, crimes_per_student_state)
	answers_obj.visualize_answer4(crime_1, crime_2)

	answers_obj = plots.Answers(crimes_obj, None, pltparam, None, None, crimes_per_student_sector)
	answers_obj.visualize_answer4(crime_1, crime_2)
Beispiel #2
0
def university_crime_explorer(dataframe):
    '''Handles the features of first GUI'''

    GUI.start_user_interface(dataframe)
    university_name = GUI.get_uni()
    branch_name = GUI.get_branch()

    print "Details about %s (%s) is being generated. Please wait..." % (
        university_name, branch_name)

    college_instance = handlers.college_details(dataframe, university_name,
                                                branch_name)
    college_obj = coll.College(college_instance, crimes_obj)

    crime_per_student_without_average = handlers.all_crimes_per_student_over_years(
        college_obj, crimes_obj)  # Question 1
    crime_per_student_with_average = handlers.all_crimes_per_student_over_years(
        college_obj, crimes_obj, average=True)  # Question 2
    crimes_per_student_by_category = handlers.average_crimes_per_student_by_category(
        dataframe, 'State', crimes_obj)  # Question 3

    pltparam = plotting.pltParam()
    answers_obj = plots.Answers(crimes_obj, college_obj, pltparam,
                                crime_per_student_without_average,
                                crime_per_student_with_average,
                                crimes_per_student_by_category)

    answers_obj.visualize_answer1()
    answers_obj.pieChart(crime_per_student_with_average)
Beispiel #3
0
def crime_comparisons(dataframe, crimes_obj):
    '''Handles the functionalities of different crime comparisons'''

    GUI4.start_user_interface()
    crime_1, crime_2 = GUI4.get_crimes()
    crimes_per_student_state = handlers.average_crimes_per_student_by_category(
        dataframe, 'State', crimes_obj, overall_average=True)
    crimes_per_student_sector = handlers.average_crimes_per_student_by_category(
        dataframe, 'Sector_desc', crimes_obj, overall_average=True)

    pltparam = plotting.pltParam()
    answers_obj = plots.Answers(crimes_obj, None, pltparam, None, None,
                                crimes_per_student_state)
    answers_obj.visualize_answer4(crime_1, crime_2)

    answers_obj = plots.Answers(crimes_obj, None, pltparam, None, None,
                                crimes_per_student_sector)
    answers_obj.visualize_answer4(crime_1, crime_2)
def crime_comparisons(dataframe, crimes_obj):
	'''Handles the functionalities of different crime comparisons'''

	GUI4.start_user_interface()
	crime_1, crime_2 = GUI4.get_crimes()

	if len(crime_1) == 0:
		print "Thank you for using the software"
		exit()

	crimes_per_student_state = handlers.average_crimes_per_student_by_category(dataframe, 'State', crimes_obj, overall_average = True)
	crimes_per_student_sector = handlers.average_crimes_per_student_by_category(dataframe, 'Sector_desc', crimes_obj, overall_average = True)

	pltparam = plotting.pltParam()
	answers_obj_state = plots.Answers(crimes_obj, None, pltparam, None, None, crimes_per_student_state)
	state_wide_output = answers_obj_state.visualize_answer4(crime_1, crime_2, 'State')

	answers_obj_sector = plots.Answers(crimes_obj, None, pltparam, None, None, crimes_per_student_sector)
	sector_wide_output = answers_obj_sector.visualize_answer4(crime_1, crime_2, 'Sector')

	return crime_1, crime_2, state_wide_output, sector_wide_output
def category_wise_crime(dataframe, crimes_obj):
	'''Handles the functionalities of crimes by different categories'''

	GUI3.start_user_interface(dataframe)
	category, specific_choice = GUI3.get_choices()
	crimes_per_student_by_category = handlers.average_crimes_per_student_by_category(dataframe, category, crimes_obj, overall_average = True)

	pltparam = plotting.pltParam()
	answers_obj = plots.Answers(crimes_obj, None, pltparam, None, None, None)

	bar_chart = answers_obj.simpleBarChart(crimes_per_student_by_category, specific_choice)

	return bar_chart, specific_choice
def get_university_crime_details_and_plot(dataframe, college_obj, crimes_obj):
	'''Computes and generates the plots for the university'''

	crime_per_student_without_average = handlers.all_crimes_per_student_over_years(college_obj, crimes_obj)	# Question 1
	crime_per_student_with_average = handlers.all_crimes_per_student_over_years(college_obj, crimes_obj, average=True)	# Question 2
	crimes_per_student_by_category = handlers.average_crimes_per_student_by_category(dataframe, 'State', crimes_obj, overall_average = True)

	pltparam = plotting.pltParam()
	answers_obj = plots.Answers(crimes_obj, college_obj, pltparam, crime_per_student_without_average, crime_per_student_with_average, crimes_per_student_by_category)

	multibar_plot = answers_obj.visualize_answer1()
	pie_chart = answers_obj.pieChart(crime_per_student_with_average)	

	return multibar_plot, pie_chart
Beispiel #7
0
def category_wise_crime(dataframe, crimes_obj):
    '''Handles the functionalities of crimes by different categories'''

    GUI3.start_user_interface(dataframe)
    category, specific_choice = GUI3.get_choices()
    crimes_per_student_by_category = handlers.average_crimes_per_student_by_category(
        dataframe, category, crimes_obj, overall_average=True)

    pltparam = plotting.pltParam()
    answers_obj = plots.Answers(crimes_obj, None, pltparam, None, None, None)

    bar_chart = answers_obj.simpleBarChart(crimes_per_student_by_category,
                                           specific_choice)

    return bar_chart, specific_choice
Beispiel #8
0
def get_university_crime_details_and_plot(dataframe, college_obj, crimes_obj):
    '''Computes and generates the plots for the university'''

    crime_per_student_without_average = handlers.all_crimes_per_student_over_years(
        college_obj, crimes_obj)  # Question 1
    crime_per_student_with_average = handlers.all_crimes_per_student_over_years(
        college_obj, crimes_obj, average=True)  # Question 2
    crimes_per_student_by_category = handlers.average_crimes_per_student_by_category(
        dataframe, 'State', crimes_obj, overall_average=True)

    pltparam = plotting.pltParam()
    answers_obj = plots.Answers(crimes_obj, college_obj, pltparam,
                                crime_per_student_without_average,
                                crime_per_student_with_average,
                                crimes_per_student_by_category)

    multibar_plot = answers_obj.visualize_answer1()
    pie_chart = answers_obj.pieChart(crime_per_student_with_average)

    return multibar_plot, pie_chart
def university_crime_explorer(dataframe):
	'''Handles the features of first GUI'''

	GUI.start_user_interface(dataframe)
	university_name = GUI.get_uni()
	branch_name = GUI.get_branch()

	print "Details about %s (%s) is being generated. Please wait..." % (university_name, branch_name)
	
	college_instance = handlers.college_details(dataframe, university_name, branch_name)
	college_obj = coll.College(college_instance, crimes_obj)

	crime_per_student_without_average = handlers.all_crimes_per_student_over_years(college_obj, crimes_obj)	# Question 1
	crime_per_student_with_average = handlers.all_crimes_per_student_over_years(college_obj, crimes_obj, average=True)	# Question 2
	crimes_per_student_by_category = handlers.average_crimes_per_student_by_category(dataframe, 'State', crimes_obj)	# Question 3
	
	pltparam = plotting.pltParam()
	answers_obj = plots.Answers(crimes_obj, college_obj, pltparam, crime_per_student_without_average, crime_per_student_with_average, crimes_per_student_by_category)

	answers_obj.visualize_answer1()
	answers_obj.pieChart(crime_per_student_with_average)	
import numpy as np 
import pandas as pd 
import matplotlib.pyplot as plt 
import handlers
import college

if __name__ == '__main__':
	'''Handling the functionalities'''
	
	dataframe, crimes_obj = handlers.data_initialization("data/oncampuscrime101112_cleaned.csv")
	coll =college.College(pd.Series({"a":3},crimes_obj))
	university_name = "University of Alabama in Huntsville"
	branch_name = "Main_Campus"
	college_instance = handlers.college_details(dataframe, university_name, branch_name)
	college_obj = coll.College(college_instance, crimes_obj)
	crime_per_student = handlers.all_crimes_per_student_over_years("On Campus", "Crime", college_instance, crimes_obj)

	
	answers_obj = plots.Answers(crimes_obj, college_obj, pltparam, crime_per_student_without_average, crime_per_student_with_average, crimes_per_student_by_category)

	d = handlers.average_crimes_per_student_by_category(dataframe, 'State' ,crimes_obj, overall_average = True)
	
	
	answers_obj.simpleBarChart(d,"MA")
	
	
    p = pltParam()

    university_name = "Harvard University"

    branch_name = "Main Campus"
    dataframe, crimes_obj = handlers.data_initialization("data/oncampuscrime101112_cleaned.csv")
    college_instance = handlers.college_details(dataframe, university_name, branch_name)
    college_obj = coll.College(college_instance, crimes_obj)
    crime_per_student_without_average = handlers.all_crimes_per_student_over_years(
        college_obj, crimes_obj
    )  # Question 1
    crime_per_student_with_average = handlers.all_crimes_per_student_over_years(
        college_obj, crimes_obj, average=True
    )  # Question 2
    crimes_per_student_by_category = handlers.average_crimes_per_student_by_category(
        dataframe, "State", crimes_obj
    )  # Question 3
    pltparam = plotting.pltParam()
    answers_obj = plots.Answers(
        crimes_obj,
        college_obj,
        pltparam,
        crime_per_student_without_average,
        crime_per_student_with_average,
        crimes_per_student_by_category,
    )

    d = handlers.average_crimes_per_student_by_category(dataframe, "State", crimes_obj, overall_average=True)

    answers_obj.simpleBarChart(d, "MA")