CountEmbedder
srai.embedders.CountEmbedder ¶
CountEmbedder(
expected_output_features: Optional[
Union[list[str], OsmTagsFilter, GroupedOsmTagsFilter]
] = None,
count_subcategories: bool = True,
)
Bases: Embedder
Simple Embedder that counts occurences of feature values.
PARAMETER | DESCRIPTION |
---|---|
count_subcategories
|
Whether to count all subcategories individually or count features only on the highest level based on features column name. Defaults to True.
TYPE:
|
Source code in srai/embedders/count_embedder.py
transform ¶
transform(
regions_gdf: gpd.GeoDataFrame,
features_gdf: gpd.GeoDataFrame,
joint_gdf: gpd.GeoDataFrame,
) -> pd.DataFrame
Embed a given GeoDataFrame.
Creates region embeddings by counting the frequencies of each feature value. Expects features_gdf to be in wide format with each column being a separate type of feature (e.g. amenity, leisure) and rows to hold values of these features for each object. The resulting DataFrame will have columns made by combining the feature name (column) and value (row) e.g. amenity_fuel or type_0. The rows will hold numbers of this type of feature in each region.
PARAMETER | DESCRIPTION |
---|---|
regions_gdf
|
Region indexes and geometries.
TYPE:
|
features_gdf
|
Feature indexes, geometries and feature values.
TYPE:
|
joint_gdf
|
Joiner result with region-feature multi-index.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DataFrame
|
pd.DataFrame: Embedding for each region in regions_gdf. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If features_gdf is empty and self.expected_output_features is not set. |
ValueError
|
If any of the gdfs index names is None. |
ValueError
|
If joint_gdf.index is not of type pd.MultiIndex or doesn't have 2 levels. |
ValueError
|
If index levels in gdfs don't overlap correctly. |
ValueError
|
If features_gdf contains boolean columns and count_subcategories is True. |
Source code in srai/embedders/count_embedder.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|