Hex2VecEmbedder
¶
Bases: CountEmbedder
Hex2Vec Embedder.
PARAMETER | DESCRIPTION |
---|---|
encoder_sizes |
Sizes of the encoder layers. The input layer size shouldn't be included - it's inferred from the data. The last element is the embedding size. Defaults to [150, 75, 50].
TYPE:
|
Source code in srai/embedders/hex2vec/embedder.py
¶
Create region embeddings.
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 |
---|---|
pd.DataFrame
|
pd.DataFrame: Embedding and geometry index 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. |
Source code in srai/embedders/hex2vec/embedder.py
fit(
regions_gdf,
features_gdf,
joint_gdf,
neighbourhood,
negative_sample_k_distance=2,
batch_size=32,
learning_rate=0.001,
trainer_kwargs=None,
)
¶
fit(
regions_gdf,
features_gdf,
joint_gdf,
neighbourhood,
negative_sample_k_distance=2,
batch_size=32,
learning_rate=0.001,
trainer_kwargs=None,
)
Fit the model to the data.
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:
|
neighbourhood |
The neighbourhood to use. Should be intialized with the same regions.
TYPE:
|
negative_sample_k_distance |
When sampling negative samples, sample from a distance > k. Defaults to 2.
TYPE:
|
batch_size |
Batch size. Defaults to 32.
TYPE:
|
learning_rate |
Learning rate. Defaults to 0.001.
TYPE:
|
trainer_kwargs |
Trainer kwargs. Defaults to None.
TYPE:
|
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 negative_sample_k_distance < 2. |
Source code in srai/embedders/hex2vec/embedder.py
fit_transform(
regions_gdf,
features_gdf,
joint_gdf,
neighbourhood,
negative_sample_k_distance=2,
batch_size=32,
learning_rate=0.001,
trainer_kwargs=None,
)
¶
fit_transform(
regions_gdf,
features_gdf,
joint_gdf,
neighbourhood,
negative_sample_k_distance=2,
batch_size=32,
learning_rate=0.001,
trainer_kwargs=None,
)
Fit the model to the data and return the embeddings.
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:
|
neighbourhood |
The neighbourhood to use. Should be intialized with the same regions.
TYPE:
|
negative_sample_k_distance |
When sampling negative samples, sample from a distance > k. Defaults to 2.
TYPE:
|
batch_size |
Batch size. Defaults to 32.
TYPE:
|
learning_rate |
Learning rate. Defaults to 0.001.
TYPE:
|
trainer_kwargs |
Trainer kwargs. Defaults to None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
pd.DataFrame
|
pd.DataFrame: Region embeddings. |
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 negative_sample_k_distance < 2. |
Source code in srai/embedders/hex2vec/embedder.py
¶
Save the model to a directory.
PARAMETER | DESCRIPTION |
---|---|
path |
Path to the directory.
TYPE:
|
Source code in srai/embedders/hex2vec/embedder.py
¶
classmethod
Load the model from a directory.
PARAMETER | DESCRIPTION |
---|---|
path |
Path to the directory.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Hex2VecEmbedder
|
The loaded embedder.
TYPE:
|