Esempio n. 1
0
def join_cities(cities):
    """Concatenate matrix for all `cities` but keep track from which city each
    point come from."""
    features = None
    for idx, city in enumerate(cities):
        mat = load_matrix(city)['v']
        coming_from = idx * np.ones((1, mat.shape[0])).ravel()
        if features is not None:
            features = np.vstack([features, mat])
            origin = np.hstack([origin, coming_from]).ravel()
        else:
            features = mat
            origin = coming_from
    return features, origin
Esempio n. 2
0
def join_cities(cities):
    """Concatenate matrix for all `cities` but keep track from which city each
    point come from."""
    features = None
    for idx, city in enumerate(cities):
        mat = load_matrix(city)['v']
        coming_from = idx*np.ones((1, mat.shape[0])).ravel()
        if features is not None:
            features = np.vstack([features, mat])
            origin = np.hstack([origin, coming_from]).ravel()
        else:
            features = mat
            origin = coming_from
    return features, origin
Esempio n. 3
0
    cities = [
        'amsterdam', 'atlanta', 'barcelona', 'berlin', 'chicago', 'helsinki',
        'houston', 'indianapolis', 'london', 'losangeles', 'moscow', 'newyork',
        'paris', 'prague', 'rome', 'sanfrancisco', 'seattle', 'stlouis',
        'stockholm', 'washington'
    ]
    cities = [
        'paris', 'barcelona', 'rome', 'berlin', 'barcelona', 'sanfrancisco',
        'washington', 'newyork'
    ]

    # cities = ['helsinki']
    if len(cities) > 1:
        features, origin = join_cities(cities)
    else:
        features = load_matrix(city)['v']
        origin = features.shape[0] * [
            0,
        ]
    # sio.savemat('tmp', {'A': features}, do_compression=True)
    # sys.exit()
    features[:, 5] = features[:, 5] / 8e5
    # to_keep = set(range(6, 15))
    # to_keep = set(range(18, 24)+range(25, 31))
    # to_keep = set(range(0, 5))
    cats = (8 * features[:, 5]).astype(int)
    features[:, 5] = 0
    # to_delete = set(range(features.shape[1])).difference(to_keep)
    # features = np.delete(features, list(to_delete), axis=1)
    # print(features.shape)
    # features[:, 5] *= 0.0
Esempio n. 4
0
    features = None
    origin = None
    cities = ['stockholm', 'prague', 'paris', 'barcelona', 'rome', 'berlin',
              'london', 'helsinki', 'amsterdam', 'moscow']
    cities = ['amsterdam', 'atlanta', 'barcelona', 'berlin', 'chicago',
              'helsinki', 'houston', 'indianapolis', 'london', 'losangeles',
              'moscow', 'newyork', 'paris', 'prague', 'rome', 'sanfrancisco',
              'seattle', 'stlouis', 'stockholm', 'washington']
    cities = ['paris', 'barcelona', 'rome', 'berlin', 'barcelona',
              'sanfrancisco', 'washington', 'newyork']

    # cities = ['helsinki']
    if len(cities) > 1:
        features, origin = join_cities(cities)
    else:
        features = load_matrix(city)['v']
        origin = features.shape[0] * [0, ]
    # sio.savemat('tmp', {'A': features}, do_compression=True)
    # sys.exit()
    features[:, 5] = features[:, 5] / 8e5
    # to_keep = set(range(6, 15))
    # to_keep = set(range(18, 24)+range(25, 31))
    # to_keep = set(range(0, 5))
    cats = (8*features[:, 5]).astype(int)
    features[:, 5] = 0
    # to_delete = set(range(features.shape[1])).difference(to_keep)
    # features = np.delete(features, list(to_delete), axis=1)
    # print(features.shape)
    # features[:, 5] *= 0.0
    # print(np.sum(features[:, 5]))
    Axes3D