import crime_data.constants import crime_data.crime_data.fxns as crime_data_fxns import tensor_scan.tensor_scan.fxns as tensor_scan_fxns import python_utils.python_utils.utils as utils import itertools import numpy as np import pdb import functools """ scratch data_iterable """ data_id_iterable = crime_data_fxns.AllHouseBurglaryIterable() cat_fs = [\ utils.categorical_f(crime_data_fxns.house_break_f('location_of_entry'), [utils.equals_bin('Door: Front'), utils.equals_bin('Window: Ground'), utils.equals_bin('Door: Rear')]),\ utils.categorical_f(crime_data_fxns.house_break_f('categorization'), [utils.equals_bin('Professional'), utils.equals_bin('Unprofessional'), utils.equals_bin('Attempt')]),\ ] int_cat_fs = [utils.int_f_from_categorical_f(cat_f) for cat_f in cat_fs] int_cat_fs_set_iterable = utils.get_powerset_iterator(int_cat_fs) x_f_iterable = itertools.starmap(utils.series_f, int_cat_fs_set_iterable) location_f = crime_data_fxns.house_break_f('latlng') time_f = crime_data_fxns.house_break_f('date_num') in_pattern_f = crime_data_fxns.in_pattern_f() scratch_data_iterable = itertools.imap(lambda x_f: map(lambda id: tensor_scan_fxns.datum(id, time_f(id), location_f(id), x_f(id), in_pattern_f(id)), data_id_iterable), x_f_iterable) """ scratch pattern_finder_iterable """ num_lat_iterable = [5, 10, 15, 20, 30]
import crime_data.constants import pdb import tensor_scan.tensor_scan.fxns as tensor_scan_fxns import crime_data.crime_data.fxns as crime_data_fxns import python_utils.python_utils.utils as utils import itertools import numpy as np """ scratch data """ location_f = crime_data_fxns.house_break_f('latlng') year_f = crime_data_fxns.house_break_f('year') data_id_iterable = list(itertools.ifilter(lambda id: year_f(id) >= 2003 and year_f(id) <= 2005 and location_f(id) in utils.latlng_grid_region(crime_data.constants.cambridge_min_lat, crime_data.constants.cambridge_max_lat, crime_data.constants.cambridge_min_lng, crime_data.constants.cambridge_max_lng), crime_data_fxns.AllHouseBurglaryIterable())) #data_id_iterable = list(itertools.ifilter(lambda id: location_f(id) in utils.latlng_grid_region(crime_data.constants.cambridge_min_lat, crime_data.constants.cambridge_max_lat, crime_data.constants.cambridge_min_lng, crime_data.constants.cambridge_max_lng), crime_data_fxns.AllHouseBurglaryIterable())) cat_fs = [\ utils.categorical_f(crime_data_fxns.house_break_f('location_of_entry'), [utils.equals_bin('Door: Front'), utils.equals_bin('Window: Ground'), utils.equals_bin('Door: Rear')]),\ utils.categorical_f(crime_data_fxns.house_break_f('means_of_entry'), [utils.equals_bin('Pried'), utils.equals_bin('Unlocked'), utils.equals_bin('Shoved/Forced'), utils.equals_bin('Broke')]),\ # utils.categorical_f(crime_data_fxns.house_break_f('categorization'), [utils.equals_bin('Professional'), utils.equals_bin('Unprofessional'), utils.equals_bin('Attempt')]),\ ] int_cat_fs = [utils.int_f_from_categorical_f(cat_f) for cat_f in cat_fs] x_f = utils.series_f(*int_cat_fs) #x_f = utils.series_f(utils.hard_code_f(0)) time_f = crime_data_fxns.house_break_f('date_num') in_pattern_f = crime_data_fxns.in_pattern_f() pattern_f = crime_data_fxns.house_break_f('pattern') scratch_data = [tensor_scan_fxns.datum(id, time_f(id), location_f(id), x_f(id), in_pattern_f(id), pattern_f(id)) for id in data_id_iterable]