Download and process the Election dataset used in CorrelationGNN (https://arxiv.org/abs/2002.08274) Parameters: norm_x = logical; should features be normalized norm_y = logical; should outcome be normalized coords_as_feats = logical; should lat/lon coordinates be added as featu
(norm_x=True, norm_y=True, coords_as_feats=False)
| 12 | from functools import reduce |
| 13 | |
| 14 | def get_election_data(norm_x=True, norm_y=True, coords_as_feats=False): |
| 15 | ''' |
| 16 | Download and process the Election dataset used in CorrelationGNN (https://arxiv.org/abs/2002.08274) |
| 17 | |
| 18 | Parameters: |
| 19 | norm_x = logical; should features be normalized |
| 20 | norm_y = logical; should outcome be normalized |
| 21 | coords_as_feats = logical; should lat/lon coordinates be added as features |
| 22 | |
| 23 | Return: |
| 24 | coords = spatial coordinates (lon/lat) |
| 25 | x = features at location (excluding outcome variable) |
| 26 | y = outcome variable |
| 27 | ''' |
| 28 | path_to_data = './data/election' |
| 29 | |
| 30 | c = torch.load(path_to_data + '/c.pt') |
| 31 | x = torch.load(path_to_data + '/x.pt') |
| 32 | y = torch.load(path_to_data + '/y.pt') |
| 33 | |
| 34 | if norm_y==True: |
| 35 | y = ((y - y.min()) / (y.max() - y.min())) |
| 36 | if norm_x==True: |
| 37 | for i in range(x.shape[1]): |
| 38 | x[:,i] = ((x[:,i] - x[:,i].min()) / (x[:,i].max() - x[:,i].min())) |
| 39 | if coords_as_feats: |
| 40 | x = torch.cat((x,c),1) |
| 41 | |
| 42 | return c, x, y |
| 43 | |
| 44 | def get_cali_housing_data(norm_x=True, norm_y=True, coords_as_feats=False, add_coord_noise=True): |
| 45 | ''' |
nothing calls this directly
no outgoing calls
no test coverage detected