Adjacency features¶
-
adjacency_features.
create_poi_index
(poi_gdf, path)[source]¶ Creates spatial index containing the pois given.
- Parameters
poi_gdf (geopandas.GeoDataFrame) – Contains pois to be stored in the index
path (str) – Path to save the index
- Returns
None
-
adjacency_features.
get_classes_in_neighbors_bln
(poi_gdf, poi_index_path, nlabels, label_map, k)[source]¶ Creates a features array. For each poi p (each row) the array will contain 1 (True) in column c, if there is at least one poi of category c among the k nearest neighbors of p.
- Parameters
poi_gdf (geopandas.GeoDataFrame) – Contains pois for which the features will be created
poi_index_path (str) – Path to the stored index
nlabels (int) – Number of poi categories
label_map (list) – A list containing the labels of the train pois
k (int) – Number of nearest neighbors to take into account
- Returns
The features array of shape (n_samples, n_features), here (len(poi_gdf), nlabels)
- Return type
numpy.ndarray
-
adjacency_features.
get_classes_in_neighbors_cnt
(poi_gdf, poi_index_path, nlabels, label_map, k)[source]¶ Creates a features array. For each poi p (each row) the array will contain an integer in column c, representing the number of pois of category c among the k nearest neighbors of p.
- Parameters
poi_gdf (geopandas.GeoDataFrame) – Contains pois for which the features will be created
poi_index_path (str) – Path to the stored index
nlabels (int) – Number of poi categories
label_map (list) – A list containing the labels of the train pois
k (int) – Number of nearest neighbors to take into account
- Returns
The features array of shape (n_samples, n_features), here (len(poi_gdf), nlabels)
- Return type
numpy.ndarray
-
adjacency_features.
get_classes_in_radius_bln
(poi_gdf, poi_index_path, nlabels, label_map, thr)[source]¶ Creates a features array. For each poi p (each row) the array will contain 1 (True) in column c, if there is at least one poi of category c inside p’s defined radius.
- Parameters
poi_gdf (geopandas.GeoDataFrame) – Contains pois for which the features will be created
poi_index_path (str) – Path to the stored index
nlabels (int) – Number of poi categories
label_map (list) – A list containing the labels of the train pois
thr (float) – Radius to be searched (in meters)
- Returns
The features array of shape (n_samples, n_features), here (len(poi_gdf), nlabels)
- Return type
numpy.ndarray
-
adjacency_features.
get_classes_in_radius_cnt
(poi_gdf, poi_index_path, nlabels, label_map, thr)[source]¶ Creates a features array. For each poi p (each row) the array will contain an integer in column c, representing the number of pois of category c inside p’s defined radius.
- Parameters
poi_gdf (geopandas.GeoDataFrame) – Contains pois for which the features will be created
poi_index_path (str) – Path to the stored index
nlabels (int) – Number of poi categories
label_map (list) – A list containing the labels of the train pois
thr (float) – Radius to be searched (in meters)
- Returns
The features array of shape (n_samples, n_features), here (len(poi_gdf), nlabels)
- Return type
numpy.ndarray
-
adjacency_features.
get_classes_in_street_and_radius_bln
(poi_gdf, street_gdf, pois_by_street, nlabels, label_map, geometry_map, thr)[source]¶ Creates a features array. For each poi p, the nearest street to p is identified and the pois of this street are kept. These pois are then filtered and only those which are inside p’s defined radius are considered (e.g. a set of pois P). Finally, for each poi p (each row) the array will contain 1 (True) in column c, if there is at least one poi of category c among pois in P.
- Parameters
poi_gdf (geopandas.GeoDataFrame) – Contains pois for which the features will be created
street_gdf (geopandas.GeoDataFrame) – Contains all streets extracted from OSM, along with their geometries
pois_by_street (dict) – Has streets ids as keys and a list containing the pois which belong to each street as values
nlabels (int) – Number of poi categories
label_map (list) – A list containing the labels of the train pois
geometry_map (list) – A list containing the geometries of the train pois
thr (float) – Radius to be searched (in meters)
- Returns
The features array of shape (n_samples, n_features), here (len(poi_gdf), nlabels)
- Return type
numpy.ndarray
-
adjacency_features.
get_classes_in_street_and_radius_cnt
(poi_gdf, street_gdf, pois_by_street, nlabels, label_map, geometry_map, thr)[source]¶ Creates a features array. For each poi p, the nearest street to p is identified and the pois of this street are kept. These pois are then filtered and only those which are inside p’s defined radius are considered (e.g. a set of pois P). Finally, for each poi p (each row) the array will contain an integer in column c, representing the number of pois of category c among pois in P.
- Parameters
poi_gdf (geopandas.GeoDataFrame) – Contains pois for which the features will be created
street_gdf (geopandas.GeoDataFrame) – Contains all streets extracted from OSM, along with their geometries
pois_by_street (dict) – Has streets ids as keys and a list containing the pois which belong to each street as values
nlabels (int) – Number of poi categories
label_map (list) – A list containing the labels of the train pois
geometry_map (list) – A list containing the geometries of the train pois
thr (float) – Radius to be searched (in meters)
- Returns
The features array of shape (n_samples, n_features), here (len(poi_gdf), nlabels)
- Return type
numpy.ndarray