Node Embedding Algorithms¶
- pydantic model graphdatascience.procedure_surface.api.node_embedding.EmbeddingCreateResult¶
- class graphdatascience.procedure_surface.api.node_embedding.EmbeddingEndpoints¶
- abstract create(G: Graph, *, graph_encoder: str | FastRPConfig | None = None, embedding_dimension: int | None = None, random_seed: int | None = None, mutate_property: str = 'embedding', job_id: str | None = None, node_labels: list[str] = ['*'], relationship_types: list[str] = ['*'], input_properties: list[str] = []) EmbeddingCreateResult¶
- Parameters:
G (Graph) – Graph object to use
graph_encoder (str | FastRPConfig | None) – Encoder used to produce node embeddings: either the name of a previously trained encoder model, or an inline configuration for a non-trainable encoder (e.g. FastRP or Identity).
embedding_dimension (int | None) – Dimension of the node embeddings.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
mutate_property (str) – Name of the node property to store the results in.
job_id (str | None) – Identifier for the computation.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
input_properties (list[str]) – Names of the node properties to use as input features
- Return type:
- abstract train(G: Graph, *, graph_encoder: GraphSAGEConfig | None = None, decoder: MLPClassifierConfig | None = None, embedding_dimension: int | None = None, model_name: str, target_label: str, target_property: str, num_epochs: int | None = None, batch_size: int | None = None, random_seed: int | None = None, job_id: str | None = None, node_labels: list[str] = ['*'], relationship_types: list[str] = ['*'], input_properties: list[str]) EmbeddingTrainResult¶
embeddings.train is a preview feature and may change or be removed in future releases.
- Parameters:
G (Graph) – Graph object to use
graph_encoder (GraphSAGEConfig | None) – Configuration for the graph encoder to train (e.g. FastRP, GraphSAGE, or Identity).
decoder (MLPClassifierConfig | None) – Configuration for the decoder to train on top of the graph encoder’s embeddings.
embedding_dimension (int | None) – Dimension of the node embeddings.
model_name (str) – Name to save the trained graph encoder + decoder model under.
target_label (str) – Node label to train on.
target_property (str) – Node property to train on.
num_epochs (int | None) – Maximum number of training epochs.
batch_size (int | None) – Number of examples per training batch.
num_trials – Number of hyperparameter tuning trials to run.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
job_id (str | None) – Identifier for the computation.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
input_properties (list[str]) – Names of the node properties to use as input features
- Return type:
- pydantic model graphdatascience.procedure_surface.api.node_embedding.EmbeddingTrainResult¶
- class graphdatascience.procedure_surface.api.node_embedding.FastPathEndpoints¶
Endpoints for the FastPath node embedding algorithm.
FastPath is a lightweight path-embedding algorithm for temporal graphs: it computes embeddings for base nodes from their associated event sequences, aggregating event vectors by event type and elapsed time. It is only available on the Arrow (Aura Graph Analytics) surface.
See https://neo4j.com/docs/snowflake-graph-analytics/current/algorithms/fastpath/
- abstract mutate(G: Graph, base_node_label: str, event_node_label: str, mutate_property: str, embedding_dimension: int, lookback_horizon: int, num_time_anchors: int, *, event_node_categorical_properties: list[str] = [], relationship_types: list[str] = ['*'], context_node_label: str | None = None, decay_rate: float = 1.0, event_node_feature_vector_property: str | None = None, first_relationship_type: str | None = None, event_node_ignored_category: int = -1, next_relationship_type: str | None = None, observation_time: float | None = None, base_node_observation_time_property: str | None = None, random_seed: Any | None = None, smoothing_rate: float = 0.0, smoothing_window: int = 0, event_node_time_property: str | None = None, job_id: str | None = None) FastPathMutateResult¶
Executes the FastPath algorithm and writes the results back to the graph as a node property.
- Parameters:
G (Graph) – Graph object to use
base_node_label (str) – Node label identifying the nodes to compute embeddings for.
event_node_label (str) – Node label marking the event nodes linked to base nodes.
mutate_property (str) – Name of the node property to store the results in.
embedding_dimension (int) – Output dimensionality of the embeddings
lookback_horizon (int) – Maximum age of events (relative to the observation time) that are processed.
num_time_anchors (int) – Number of grid points used to discretize elapsed time.
event_node_categorical_properties (list[str]) – Event node properties holding categorical values.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
context_node_label (str | None) – Optional node label for context nodes describing events.
decay_rate (float) – Controls how quickly the influence of older events decays.
event_node_feature_vector_property (str | None) – Name of the vector property on event nodes holding numerical features.
first_relationship_type (str | None) – Relationship type connecting base nodes to the first event in a chain.
event_node_ignored_category (int) – Event category value treated as missing/ignored.
next_relationship_type (str | None) – Relationship type ordering sequential events in a chain.
observation_time (float | None) – Single fixed timestamp the embeddings are produced for.
base_node_observation_time_property (str | None) – Base node property giving a per-node output timestamp.
random_seed (Any | None) – Seed for reproducible random vector generation.
smoothing_rate (float) – Controls how event embedding similarity decays with time distance.
smoothing_window (int) – Window size for aggregating embeddings across nearby grid times.
event_node_time_property (str | None) – Numeric event node property holding the event timestamp.
job_id (str | None) – Identifier for the computation.
- Returns:
Algorithm metrics and statistics
- Return type:
- abstract stream(G: Graph, base_node_label: str, event_node_label: str, embedding_dimension: int, lookback_horizon: int, num_time_anchors: int, *, event_node_categorical_properties: list[str] = [], relationship_types: list[str] = ['*'], context_node_label: str | None = None, decay_rate: float = 1.0, event_node_feature_vector_property: str | None = None, first_relationship_type: str | None = None, event_node_ignored_category: int = -1, next_relationship_type: str | None = None, observation_time: float | None = None, base_node_observation_time_property: str | None = None, random_seed: Any | None = None, smoothing_rate: float = 0.0, smoothing_window: int = 0, event_node_time_property: str | None = None, job_id: str | None = None) DataFrame¶
Executes the FastPath algorithm and returns the results as a stream.
- Parameters:
G (Graph) – Graph object to use
base_node_label (str) – Node label identifying the nodes to compute embeddings for.
event_node_label (str) – Node label marking the event nodes linked to base nodes.
embedding_dimension (int) – Output dimensionality of the embeddings
lookback_horizon (int) – Maximum age of events (relative to the observation time) that are processed.
num_time_anchors (int) – Number of grid points used to discretize elapsed time.
event_node_categorical_properties (list[str]) – Event node properties holding categorical values.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
context_node_label (str | None) – Optional node label for context nodes describing events.
decay_rate (float) – Controls how quickly the influence of older events decays.
event_node_feature_vector_property (str | None) – Name of the vector property on event nodes holding numerical features.
first_relationship_type (str | None) – Relationship type connecting base nodes to the first event in a chain.
event_node_ignored_category (int) – Event category value treated as missing/ignored.
next_relationship_type (str | None) – Relationship type ordering sequential events in a chain.
observation_time (float | None) – Single fixed timestamp the embeddings are produced for.
base_node_observation_time_property (str | None) – Base node property giving a per-node output timestamp.
random_seed (Any | None) – Seed for reproducible random vector generation.
smoothing_rate (float) – Controls how event embedding similarity decays with time distance.
smoothing_window (int) – Window size for aggregating embeddings across nearby grid times.
event_node_time_property (str | None) – Numeric event node property holding the event timestamp.
job_id (str | None) – Identifier for the computation.
- Returns:
DataFrame with node IDs and their FastPath embeddings
- Return type:
- abstract write(G: Graph, base_node_label: str, event_node_label: str, write_property: str, embedding_dimension: int, lookback_horizon: int, num_time_anchors: int, *, event_node_categorical_properties: list[str] = [], relationship_types: list[str] = ['*'], context_node_label: str | None = None, decay_rate: float = 1.0, event_node_feature_vector_property: str | None = None, first_relationship_type: str | None = None, event_node_ignored_category: int = -1, next_relationship_type: str | None = None, observation_time: float | None = None, base_node_observation_time_property: str | None = None, random_seed: Any | None = None, smoothing_rate: float = 0.0, smoothing_window: int = 0, event_node_time_property: str | None = None, write_concurrency: int | None = None, job_id: str | None = None) FastPathWriteResult¶
Executes the FastPath algorithm and writes the results to Neo4j.
- Parameters:
G (Graph) – Graph object to use
base_node_label (str) – Node label identifying the nodes to compute embeddings for.
event_node_label (str) – Node label marking the event nodes linked to base nodes.
write_property (str) – Name of the node property to store the results in.
embedding_dimension (int) – Output dimensionality of the embeddings
lookback_horizon (int) – Maximum age of events (relative to the observation time) that are processed.
num_time_anchors (int) – Number of grid points used to discretize elapsed time.
event_node_categorical_properties (list[str]) – Event node properties holding categorical values.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
context_node_label (str | None) – Optional node label for context nodes describing events.
decay_rate (float) – Controls how quickly the influence of older events decays.
event_node_feature_vector_property (str | None) – Name of the vector property on event nodes holding numerical features.
first_relationship_type (str | None) – Relationship type connecting base nodes to the first event in a chain.
event_node_ignored_category (int) – Event category value treated as missing/ignored.
next_relationship_type (str | None) – Relationship type ordering sequential events in a chain.
observation_time (float | None) – Single fixed timestamp the embeddings are produced for.
base_node_observation_time_property (str | None) – Base node property giving a per-node output timestamp.
random_seed (Any | None) – Seed for reproducible random vector generation.
smoothing_rate (float) – Controls how event embedding similarity decays with time distance.
smoothing_window (int) – Window size for aggregating embeddings across nearby grid times.
event_node_time_property (str | None) – Numeric event node property holding the event timestamp.
write_concurrency (int | None) – Number of concurrent threads to use for writing.
job_id (str | None) – Identifier for the computation.
- Returns:
Algorithm metrics and statistics
- Return type:
- pydantic model graphdatascience.procedure_surface.api.node_embedding.FastPathMutateResult¶
- pydantic model graphdatascience.procedure_surface.api.node_embedding.FastPathWriteResult¶
- class graphdatascience.procedure_surface.api.node_embedding.FastRPEndpoints¶
- abstract estimate(G: Graph | dict[str, Any], embedding_dimension: int, iteration_weights: list[float] = [0.0, 1.0, 1.0], normalization_strength: float = 0.0, node_self_influence: float = 0.0, property_ratio: float = 0.0, feature_properties: list[str] | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], concurrency: int | None = None, relationship_weight_property: str | None = None, random_seed: int | None = None) EstimationResult¶
Returns an estimation of the memory consumption for that procedure.
- Parameters:
G (Graph | dict[str, Any]) – Graph object to use or a dictionary representing the graph dimensions.
embedding_dimension (int) – Output dimensionality of the embeddings
iteration_weights (list[float]) – Weights for each iteration. Controls the influence of each iteration on the final embedding.
normalization_strength (float) – The normalization strength parameter controls how much the embedding is normalized
node_self_influence (float) – The influence of the node’s own features on its embedding
property_ratio (float) – The ratio of node properties to use in the embedding
feature_properties (list[str] | None) – List of node properties to use as features in the embedding. Defaults to [] if not specified
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
concurrency (int | None) – Number of concurrent threads to use.
relationship_weight_property (str | None) – Name of the property to be used as weights.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
- Returns:
Memory estimation details
- Return type:
- abstract mutate(G: Graph, mutate_property: str, embedding_dimension: int, iteration_weights: list[float] = [0.0, 1.0, 1.0], normalization_strength: float = 0.0, node_self_influence: float = 0.0, property_ratio: float = 0.0, feature_properties: list[str] | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None, random_seed: int | None = None) FastRPMutateResult¶
Executes the FastRP algorithm and writes the results back to the graph as a node property.
- Parameters:
G (Graph) – Graph object to use
mutate_property (str) – Name of the node property to store the results in.
embedding_dimension (int) – Output dimensionality of the embeddings
iteration_weights (list[float]) – Weights for each iteration. Controls the influence of each iteration on the final embedding.
normalization_strength (float) – The normalization strength parameter controls how much the embedding is normalized
node_self_influence (float) – The influence of the node’s own features on its embedding
property_ratio (float) – The ratio of node properties to use in the embedding
feature_properties (list[str] | None) – List of node properties to use as features in the embedding. Defaults to [] if not specified
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
sudo (bool) – Disable the memory guard.
log_progress (bool) – Display progress logging.
username (str | None) – As an administrator, impersonate a different user for accessing their graphs.
concurrency (int | None) – Number of concurrent threads to use.
job_id (str | None) – Identifier for the computation.
relationship_weight_property (str | None) – Name of the property to be used as weights.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
- Returns:
Algorithm metrics and statistics
- Return type:
- abstract stats(G: Graph, embedding_dimension: int, iteration_weights: list[float] = [0.0, 1.0, 1.0], normalization_strength: float = 0.0, node_self_influence: float = 0.0, property_ratio: float = 0.0, feature_properties: list[str] | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None, random_seed: int | None = None) FastRPStatsResult¶
Executes the FastRP algorithm and returns result statistics without writing the result to Neo4j.
- Parameters:
G (Graph) – Graph object to use
embedding_dimension (int) – Output dimensionality of the embeddings
iteration_weights (list[float]) – Weights for each iteration. Controls the influence of each iteration on the final embedding.
normalization_strength (float) – The normalization strength parameter controls how much the embedding is normalized
node_self_influence (float) – The influence of the node’s own features on its embedding
property_ratio (float) – The ratio of node properties to use in the embedding
feature_properties (list[str] | None) – List of node properties to use as features in the embedding. Defaults to [] if not specified
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
sudo (bool) – Disable the memory guard.
log_progress (bool) – Display progress logging.
username (str | None) – As an administrator, impersonate a different user for accessing their graphs.
concurrency (int | None) – Number of concurrent threads to use.
job_id (str | None) – Identifier for the computation.
relationship_weight_property (str | None) – Name of the property to be used as weights.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
- Returns:
Algorithm statistics
- Return type:
- abstract stream(G: Graph, embedding_dimension: int, iteration_weights: list[float] = [0.0, 1.0, 1.0], normalization_strength: float = 0.0, node_self_influence: float = 0.0, property_ratio: float = 0.0, feature_properties: list[str] | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None, random_seed: int | None = None) DataFrame¶
Executes the FastRP algorithm and returns the results as a stream.
- Parameters:
G (Graph) – Graph object to use
embedding_dimension (int) – Output dimensionality of the embeddings
iteration_weights (list[float]) – Weights for each iteration. Controls the influence of each iteration on the final embedding.
normalization_strength (float) – The normalization strength parameter controls how much the embedding is normalized
node_self_influence (float) – The influence of the node’s own features on its embedding
property_ratio (float) – The ratio of node properties to use in the embedding
feature_properties (list[str] | None) – List of node properties to use as features in the embedding. Defaults to [] if not specified
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
sudo (bool) – Disable the memory guard.
log_progress (bool) – Display progress logging.
username (str | None) – As an administrator, impersonate a different user for accessing their graphs.
concurrency (int | None) – Number of concurrent threads to use.
job_id (str | None) – Identifier for the computation.
relationship_weight_property (str | None) – Name of the property to be used as weights.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
- Returns:
DataFrame with node IDs and their FastRP embeddings
- Return type:
- abstract write(G: Graph, write_property: str, embedding_dimension: int, iteration_weights: list[float] = [0.0, 1.0, 1.0], normalization_strength: float = 0.0, node_self_influence: float = 0.0, property_ratio: float = 0.0, feature_properties: list[str] | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None, random_seed: int | None = None, write_concurrency: int | None = None) FastRPWriteResult¶
Executes the FastRP algorithm and writes the results to Neo4j.
- Parameters:
G (Graph) – Graph object to use
write_property (str) – Name of the node property to store the results in.
embedding_dimension (int) – Output dimensionality of the embeddings
iteration_weights (list[float]) – Weights for each iteration. Controls the influence of each iteration on the final embedding.
normalization_strength (float) – The normalization strength parameter controls how much the embedding is normalized
node_self_influence (float) – The influence of the node’s own features on its embedding
property_ratio (float) – The ratio of node properties to use in the embedding
feature_properties (list[str] | None) – List of node properties to use as features in the embedding. Defaults to [] if not specified
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
sudo (bool) – Disable the memory guard.
log_progress (bool) – Display progress logging.
username (str | None) – As an administrator, impersonate a different user for accessing their graphs.
concurrency (int | None) – Number of concurrent threads to use.
job_id (str | None) – Identifier for the computation.
relationship_weight_property (str | None) – Name of the property to be used as weights.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
write_concurrency (int | None) – Number of concurrent threads to use for writing.Returns
-------
FastRPWriteResult – Algorithm metrics and statistics
- Return type:
- pydantic model graphdatascience.procedure_surface.api.node_embedding.FastRPMutateResult¶
- pydantic model graphdatascience.procedure_surface.api.node_embedding.FastRPStatsResult¶
- pydantic model graphdatascience.procedure_surface.api.node_embedding.FastRPWriteResult¶
- class graphdatascience.procedure_surface.api.node_embedding.GraphSageEndpoints¶
API for the GraphSage algorithm, combining both training and prediction functionalities.
- estimate(G: Graph | dict[str, Any], model_name: str, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], batch_size: int = 100, concurrency: int | None = None, log_progress: bool = True, username: str | None = None, sudo: bool = False, job_id: str | None = None) EstimationResult¶
Returns an estimation of the memory consumption for that procedure.
- Parameters:
G (Graph | dict[str, Any]) – Graph object to use or a dictionary representing the graph dimensions.
model_name (str) – Name under which the model will is stored
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
batch_size (int) – The batch size for prediction.
concurrency (int | None) – Number of concurrent threads to use.
log_progress (bool) – Display progress logging.
username (str | None) – As an administrator, impersonate a different user for accessing their graphs.
sudo (bool) – Disable the memory guard.
job_id (str | None) – Identifier for the computation.
- Returns:
The estimated cost of running the algorithm
- Return type:
- mutate(G: Graph, model_name: str, mutate_property: str, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None, batch_size: int = 100) GraphSageMutateResult¶
Uses a pre-trained GraphSage model to predict embeddings for a graph and writes the results back to the graph as a node property.
- Parameters:
G (Graph) – Graph object to use
model_name (str) – Name under which the model will is stored
mutate_property (str) – Name of the node property to store the results in.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
username (str | None) – As an administrator, impersonate a different user for accessing their graphs.
log_progress (bool) – Display progress logging.
sudo (bool) – Disable the memory guard.
concurrency (int | None) – Number of concurrent threads to use.
job_id (str | None) – Identifier for the computation.
batch_size (int) – Number of nodes to process in each batch.
- Returns:
Algorithm metrics and statistics
- Return type:
- stream(G: Graph, model_name: str, *, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None, batch_size: int = 100) DataFrame¶
Uses a pre-trained GraphSage model to predict embeddings for a graph and returns the results as a stream.
- Parameters:
G (Graph) – Graph object to use
model_name (str) – Name under which the model will is stored
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
username (str | None) – As an administrator, impersonate a different user for accessing their graphs.
log_progress (bool) – Display progress logging.
sudo (bool) – Disable the memory guard.
concurrency (int | None) – Number of concurrent threads to use.
job_id (str | None) – Identifier for the computation.
batch_size (int) – Number of nodes to process in each batch.
- Returns:
DataFrame with node IDs and their embeddings
- Return type:
- property train: GraphSageTrainEndpoints¶
Trains a GraphSage model on the given graph.
- Parameters:
G – Graph object to use
model_name – Name of the trained model.
feature_properties – Names of the node properties to use as input features
activation_function – The activation function to apply after each layer
negative_sample_weight – Weight of negative samples in the loss function
embedding_dimension – Output dimensionality of the embeddings
tolerance – Minimum change in loss between iterations for early stopping an epoch.
learning_rate – Learning rate for the training optimization
max_iterations – Maximum number of iterations to run.
sample_sizes – Number of neighbors to sample at each layer
aggregator – The aggregator function for neighborhood aggregation
penalty_l2 – L2 regularization penalty
search_depth – Maximum search depth for neighbor sampling
epochs – Number of training epochs
projected_feature_dimension – Dimension to project input features to before training
batch_sampling_ratio – Ratio of nodes to sample for each training batch
store_model_to_disk – Whether to persist the model to disk
relationship_types – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
username – As an administrator, impersonate a different user for accessing their graphs.
log_progress – Display progress logging.
sudo – Disable the memory guard.
concurrency – Number of concurrent threads to use.
job_id – Identifier for the computation.
batch_size – Number of nodes to process in each batch.
relationship_weight_property – Name of the property to be used as weights.
random_seed – Seed for random number generation to ensure reproducible results.
- Returns:
Trained model
- Return type:
- write(G: Graph, model_name: str, write_property: str, *, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, write_concurrency: int | None = None, job_id: str | None = None, batch_size: int = 100) GraphSageWriteResult¶
Uses a pre-trained GraphSage model to predict embeddings for a graph and writes the results back to the database.
- Parameters:
G (Graph) – Graph object to use
model_name (str) – Name under which the model will is stored
write_property (str) – Name of the node property to store the results in.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
username (str | None) – As an administrator, impersonate a different user for accessing their graphs.
log_progress (bool) – Display progress logging.
sudo (bool) – Disable the memory guard.
concurrency (int | None) – Number of concurrent threads to use.
write_concurrency (int | None) – Number of concurrent threads to use for writing.
job_id (str | None) – Identifier for the computation.
batch_size (int) – Number of nodes to process in each batch.
- Returns:
Algorithm metrics and statistics
- Return type:
- pydantic model graphdatascience.procedure_surface.api.node_embedding.GraphSageMutateResult¶
- class graphdatascience.procedure_surface.api.node_embedding.GraphSagePredictEndpoints¶
- abstract estimate(G: Graph | dict[str, Any], model_name: str, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], batch_size: int = 100, concurrency: int | None = None, log_progress: bool = True, username: str | None = None, sudo: bool = False, job_id: str | None = None) EstimationResult¶
Returns an estimation of the memory consumption for that procedure.
- Parameters:
G (Graph | dict[str, Any]) – Graph object to use or a dictionary representing the graph dimensions.
model_name (str) – Name under which the model will is stored
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
batch_size (int) – The batch size for prediction.
concurrency (int | None) – Number of concurrent threads to use.
log_progress (bool) – Display progress logging.
username (str | None) – As an administrator, impersonate a different user for accessing their graphs.
sudo (bool) – Disable the memory guard.
job_id (str | None) – Identifier for the computation.
- Returns:
The estimated cost of running the algorithm
- Return type:
- abstract mutate(G: Graph, model_name: str, mutate_property: str, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None, batch_size: int = 100) GraphSageMutateResult¶
Uses a pre-trained GraphSage model to predict embeddings for a graph and writes the results back to the graph as a node property.
- Parameters:
G (Graph) – Graph object to use
model_name (str) – Name under which the model will is stored
mutate_property (str) – Name of the node property to store the results in.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
username (str | None) – As an administrator, impersonate a different user for accessing their graphs.
log_progress (bool) – Display progress logging.
sudo (bool) – Disable the memory guard.
concurrency (int | None) – Number of concurrent threads to use.
job_id (str | None) – Identifier for the computation.
batch_size (int) – Number of nodes to process in each batch.
- Returns:
Algorithm metrics and statistics
- Return type:
- abstract stream(G: Graph, model_name: str, *, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None, batch_size: int = 100) DataFrame¶
Uses a pre-trained GraphSage model to predict embeddings for a graph and returns the results as a stream.
- Parameters:
G (Graph) – Graph object to use
model_name (str) – Name under which the model will is stored
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
username (str | None) – As an administrator, impersonate a different user for accessing their graphs.
log_progress (bool) – Display progress logging.
sudo (bool) – Disable the memory guard.
concurrency (int | None) – Number of concurrent threads to use.
job_id (str | None) – Identifier for the computation.
batch_size (int) – Number of nodes to process in each batch.
- Returns:
DataFrame with node IDs and their embeddings
- Return type:
- abstract write(G: Graph, model_name: str, write_property: str, *, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, write_concurrency: int | None = None, job_id: str | None = None, batch_size: int = 100) GraphSageWriteResult¶
Uses a pre-trained GraphSage model to predict embeddings for a graph and writes the results back to the database.
- Parameters:
G (Graph) – Graph object to use
model_name (str) – Name under which the model will is stored
write_property (str) – Name of the node property to store the results in.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
username (str | None) – As an administrator, impersonate a different user for accessing their graphs.
log_progress (bool) – Display progress logging.
sudo (bool) – Disable the memory guard.
concurrency (int | None) – Number of concurrent threads to use.
write_concurrency (int | None) – Number of concurrent threads to use for writing.
job_id (str | None) – Identifier for the computation.
batch_size (int) – Number of nodes to process in each batch.
- Returns:
Algorithm metrics and statistics
- Return type:
- class graphdatascience.procedure_surface.api.node_embedding.GraphSageSupervisedEndpoints¶
Endpoints for the supervised (node classification) GraphSage algorithm.
- abstract mutate(G: Graph, model_name: str, feature_properties: list[str], mutate_property: str, *, predicted_probability_property: str | None = None, batch_size: int | None = None, random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], job_id: str | None = None) GraphSageSupervisedMutateResult¶
Uses a pre-trained supervised (node classification) GraphSage model to predict classes for a graph and writes the results back to the graph as a node property.
- Parameters:
G (Graph) – Graph object to use
model_name (str) – Name of the model.
feature_properties (list[str]) – Names of the node properties to use as input features
mutate_property (str) – Name of the node property to store the results in.
predicted_probability_property (str | None) – Name of the node property to store the predicted class probabilities in.
batch_size (int | None) – Number of nodes to process in each batch.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
job_id (str | None) – Identifier for the computation.
- Returns:
Algorithm metrics and statistics
- Return type:
- abstract stream(G: Graph, model_name: str, feature_properties: list[str], *, batch_size: int | None = None, random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], job_id: str | None = None) DataFrame¶
Uses a pre-trained supervised (node classification) GraphSage model to predict classes for a graph and returns the results as a stream.
- Parameters:
G (Graph) – Graph object to use
model_name (str) – Name of the model.
feature_properties (list[str]) – Names of the node properties to use as input features
batch_size (int | None) – Number of nodes to process in each batch.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
job_id (str | None) – Identifier for the computation.
- Returns:
DataFrame with node IDs, their predicted classes and predicted class probabilities
- Return type:
- abstract train(G: Graph, model_name: str, feature_properties: list[str], *, target_label: str, target_property: str, epochs: int, activation_function: str = 'relu', aggregator: str = 'mean', batch_size: int | None = None, class_weights: bool = False, dropout: float = 0.1, embedding_dimension: int = 256, epochs_per_val: int = 0, layer_normalization: bool = True, learning_rate: float = 0.001, num_neighbors: list[int] = [20, 10], random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], split_ratios: dict[str, float] = {'TEST': 0.2, 'TRAIN': 0.6, 'VALID': 0.2}, job_id: str | None = None) tuple[GraphSageSupervisedModel, GraphSageSupervisedTrainResult]¶
Trains a supervised (node classification) GraphSage model on the given graph.
The resulting model can be used for prediction with gds.graph_sage.supervised.stream, .write and .mutate.
- Parameters:
G (Graph) – Graph object to use
model_name (str) – Name of the trained model.
feature_properties (list[str]) – Names of the node properties to use as input features
target_label (str) – Node label to train on.
target_property (str) – Node property to train on.
epochs (int) – Maximum number of training epochs.
activation_function (str) – The activation function to apply after each layer
aggregator (str) – The aggregator function for neighborhood aggregation
batch_size (int | None) – Number of nodes to process in each batch.
class_weights (bool) – Whether to weight the classes inversely proportional to their frequency
dropout (float) – Dropout probability applied during training.
embedding_dimension (int) – Output dimensionality of the embeddings
epochs_per_val (int) – Number of training epochs between validation runs
layer_normalization (bool) – Whether to apply layer normalization after each layer
learning_rate (float) – Learning rate for the training optimization
num_neighbors (list[int]) – Number of neighbors to sample at each layer
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
split_ratios (dict[str, float]) – Ratios for splitting the nodes into training, validation and test sets
job_id (str | None) – Identifier for the computation.
- Returns:
The trained model and training metrics
- Return type:
tuple[GraphSageSupervisedModel, GraphSageSupervisedTrainResult]
- abstract write(G: Graph, model_name: str, feature_properties: list[str], write_property: str, *, predicted_probability_property: str | None = None, batch_size: int | None = None, random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], job_id: str | None = None, write_concurrency: int | None = None) GraphSageSupervisedWriteResult¶
Uses a pre-trained supervised (node classification) GraphSage model to predict classes for a graph and writes the results back to the database.
- Parameters:
G (Graph) – Graph object to use
model_name (str) – Name of the model.
feature_properties (list[str]) – Names of the node properties to use as input features
write_property (str) – Name of the node property to store the results in.
predicted_probability_property (str | None) – Name of the node property to store the predicted class probabilities in.
batch_size (int | None) – Number of nodes to process in each batch.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
job_id (str | None) – Identifier for the computation.
write_concurrency (int | None) – Number of concurrent threads to use for writing.
- Returns:
Algorithm metrics and statistics
- Return type:
- class graphdatascience.procedure_surface.api.node_embedding.GraphSageSupervisedModel¶
Represents a supervised (node classification) GraphSage model in the model catalog. Construct this using gds.graph_sage.supervised.train.
- predict_mutate(G: Graph, feature_properties: list[str], mutate_property: str, *, predicted_probability_property: str | None = None, batch_size: int | None = None, random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], job_id: str | None = None) GraphSageSupervisedMutateResult¶
Predict classes for the given graph and mutate the graph with the results.
- Parameters:
G (Graph) – The graph to predict classes for.
feature_properties (list[str]) – Names of the node properties to use as input features
mutate_property (str) – The property to mutate with the predicted classes.
predicted_probability_property (str | None) – The property to mutate with the predicted class probabilities.
batch_size (int | None) – Number of nodes to process in each batch.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
job_id (str | None) – Identifier for the computation.
- Returns:
The result of the mutate operation.
- Return type:
- predict_stream(G: Graph, feature_properties: list[str], *, batch_size: int | None = None, random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], job_id: str | None = None) DataFrame¶
Predict classes for the given graph and stream the results.
- Parameters:
G (Graph) – The graph to predict classes for.
feature_properties (list[str]) – Names of the node properties to use as input features
batch_size (int | None) – Number of nodes to process in each batch.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
job_id (str | None) – Identifier for the computation.
- Returns:
The streaming results as a DataFrame with node IDs, predicted classes and predicted class probabilities.
- Return type:
- predict_write(G: Graph, feature_properties: list[str], write_property: str, *, predicted_probability_property: str | None = None, batch_size: int | None = None, random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], job_id: str | None = None, write_concurrency: int | None = None) GraphSageSupervisedWriteResult¶
Predict classes for the given graph and write the results to the database.
- Parameters:
G (Graph) – The graph to predict classes for.
feature_properties (list[str]) – Names of the node properties to use as input features
write_property (str) – The property to write the predicted classes to.
predicted_probability_property (str | None) – The property to write the predicted class probabilities to.
batch_size (int | None) – Number of nodes to process in each batch.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
job_id (str | None) – Identifier for the computation.
write_concurrency (int | None) – Number of concurrent threads to use for writing.
- Returns:
The result of the write operation.
- Return type:
- pydantic model graphdatascience.procedure_surface.api.node_embedding.GraphSageSupervisedMutateResult¶
- pydantic model graphdatascience.procedure_surface.api.node_embedding.GraphSageSupervisedTrainResult¶
- pydantic model graphdatascience.procedure_surface.api.node_embedding.GraphSageSupervisedWriteResult¶
- class graphdatascience.procedure_surface.api.node_embedding.GraphSageTrainEndpoints¶
- abstract estimate(G: Graph, model_name: str, feature_properties: list[str], *, activation_function: str = 'SIGMOID', negative_sample_weight: int = 20, embedding_dimension: int = 64, tolerance: float = 0.0001, learning_rate: float = 0.1, max_iterations: int = 10, sample_sizes: list[int] | None = None, aggregator: str = 'MEAN', penalty_l2: float = 0.0, search_depth: int = 5, epochs: int = 1, projected_feature_dimension: int | None = None, batch_sampling_ratio: float | None = None, store_model_to_disk: bool = False, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None, batch_size: int = 100, relationship_weight_property: str | None = None, random_seed: int | None = None) EstimationResult¶
Estimates memory requirements and other statistics for training a GraphSage model.
This method provides memory estimation for the GraphSage training algorithm without actually executing the training. It helps determine the computational requirements before running the actual training procedure.
- Parameters:
G (Graph) – Graph object to use
model_name (str) – Name of the trained model.
feature_properties (list[str]) – Names of the node properties to use as input features
activation_function (str) – The activation function to apply after each layer
negative_sample_weight (int) – Weight of negative samples in the loss function
embedding_dimension (int) – Output dimensionality of the embeddings
tolerance (float) – Minimum change in loss between iterations for early stopping an epoch.
learning_rate (float) – Learning rate for the training optimization
max_iterations (int) – Maximum number of iterations to run.
sample_sizes (list[int] | None) – Number of neighbors to sample at each layer. Defaults to [25, 10] if not specified
aggregator (str) – The aggregator function for neighborhood aggregation
penalty_l2 (float) – L2 regularization penalty
search_depth (int) – Maximum search depth for neighbor sampling
epochs (int) – Number of training epochs
projected_feature_dimension (int | None) – Dimension to project input features to before training
batch_sampling_ratio (float | None) – Ratio of nodes to sample for each training batch
store_model_to_disk (bool) – Whether to persist the model to disk
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
username (str | None) – As an administrator, impersonate a different user for accessing their graphs.
log_progress (bool) – Display progress logging.
sudo (bool) – Disable the memory guard.
concurrency (int | None) – Number of concurrent threads to use.
job_id (str | None) – Identifier for the computation.
batch_size (int) – Number of nodes to process in each batch.
relationship_weight_property (str | None) – Name of the property to be used as weights.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
- Returns:
The estimation result containing memory requirements and other statistics
- Return type:
- pydantic model graphdatascience.procedure_surface.api.node_embedding.GraphSageTrainResult¶
- class graphdatascience.procedure_surface.api.node_embedding.GraphSageUnsupervisedEndpoints¶
Endpoints for the unsupervised GraphSage algorithm.
This is the successor of the classic gds.graph_sage.train endpoint.
- abstract mutate(G: Graph, model_name: str, feature_properties: list[str], mutate_property: str, *, batch_size: int | None = None, random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], job_id: str | None = None) GraphSageUnsupervisedMutateResult¶
Uses a pre-trained unsupervised GraphSage model to predict embeddings for a graph and writes the results back to the graph as a node property.
- Parameters:
G (Graph) – Graph object to use
model_name (str) – Name of the model.
feature_properties (list[str]) – Names of the node properties to use as input features
mutate_property (str) – Name of the node property to store the results in.
batch_size (int | None) – Number of nodes to process in each batch.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
job_id (str | None) – Identifier for the computation.
- Returns:
Algorithm metrics and statistics
- Return type:
- abstract stream(G: Graph, model_name: str, feature_properties: list[str], *, batch_size: int | None = None, random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], job_id: str | None = None) DataFrame¶
Uses a pre-trained unsupervised GraphSage model to predict embeddings for a graph and returns the results as a stream.
- Parameters:
G (Graph) – Graph object to use
model_name (str) – Name of the model.
feature_properties (list[str]) – Names of the node properties to use as input features
batch_size (int | None) – Number of nodes to process in each batch.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
job_id (str | None) – Identifier for the computation.
- Returns:
DataFrame with node IDs and their embeddings
- Return type:
- abstract train(G: Graph, model_name: str, feature_properties: list[str], *, epochs: int, activation_function: str = 'relu', aggregator: str = 'mean', batch_size: int | None = None, dropout: float = 0.1, embedding_dimension: int = 256, layer_normalization: bool = True, learning_rate: float = 0.001, negative_sampling_ratio: float = 1.0, num_neighbors: list[int] = [20, 10], num_walks: int = 10, walk_depth: int = 3, random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], job_id: str | None = None) tuple[GraphSageUnsupervisedModel, GraphSageUnsupervisedTrainResult]¶
Trains an unsupervised GraphSage model on the given graph.
This is the successor of the classic gds.graph_sage.train endpoint. The resulting model can be used for prediction with gds.graph_sage.unsupervised.stream, .write and .mutate.
- Parameters:
G (Graph) – Graph object to use
model_name (str) – Name of the trained model.
feature_properties (list[str]) – Names of the node properties to use as input features
epochs (int) – Maximum number of training epochs.
activation_function (str) – The activation function to apply after each layer
aggregator (str) – The aggregator function for neighborhood aggregation
batch_size (int | None) – Number of nodes to process in each batch.
dropout (float) – Dropout probability applied during training.
embedding_dimension (int) – Output dimensionality of the embeddings
layer_normalization (bool) – Whether to apply layer normalization after each layer
learning_rate (float) – Learning rate for the training optimization
negative_sampling_ratio (float) – Ratio of negative to positive samples for training
num_neighbors (list[int]) – Number of neighbors to sample at each layer
num_walks (int) – Number of random walks to generate per node
walk_depth (int) – Depth of the random walks used for training
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
job_id (str | None) – Identifier for the computation.
- Returns:
The trained model and training metrics
- Return type:
tuple[GraphSageUnsupervisedModel, GraphSageUnsupervisedTrainResult]
- abstract write(G: Graph, model_name: str, feature_properties: list[str], write_property: str, *, batch_size: int | None = None, random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], job_id: str | None = None, write_concurrency: int | None = None) GraphSageUnsupervisedWriteResult¶
Uses a pre-trained unsupervised GraphSage model to predict embeddings for a graph and writes the results back to the database.
- Parameters:
G (Graph) – Graph object to use
model_name (str) – Name of the model.
feature_properties (list[str]) – Names of the node properties to use as input features
write_property (str) – Name of the node property to store the results in.
batch_size (int | None) – Number of nodes to process in each batch.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
job_id (str | None) – Identifier for the computation.
write_concurrency (int | None) – Number of concurrent threads to use for writing.
- Returns:
Algorithm metrics and statistics
- Return type:
- class graphdatascience.procedure_surface.api.node_embedding.GraphSageUnsupervisedModel¶
Represents an unsupervised GraphSage model in the model catalog. Construct this using gds.graph_sage.unsupervised.train.
- predict_mutate(G: Graph, feature_properties: list[str], mutate_property: str, *, batch_size: int | None = None, random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], job_id: str | None = None) GraphSageUnsupervisedMutateResult¶
Generate embeddings for the given graph and mutate the graph with the results.
- Parameters:
G (Graph) – The graph to generate embeddings for.
feature_properties (list[str]) – Names of the node properties to use as input features
mutate_property (str) – The property to mutate with the embeddings.
batch_size (int | None) – Number of nodes to process in each batch.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
job_id (str | None) – Identifier for the computation.
- Returns:
The result of the mutate operation.
- Return type:
- predict_stream(G: Graph, feature_properties: list[str], *, batch_size: int | None = None, random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], job_id: str | None = None) DataFrame¶
Generate embeddings for the given graph and stream the results.
- Parameters:
G (Graph) – The graph to generate embeddings for.
feature_properties (list[str]) – Names of the node properties to use as input features
batch_size (int | None) – Number of nodes to process in each batch.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
job_id (str | None) – Identifier for the computation.
- Returns:
The streaming results as a DataFrame.
- Return type:
- predict_write(G: Graph, feature_properties: list[str], write_property: str, *, batch_size: int | None = None, random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], job_id: str | None = None, write_concurrency: int | None = None) GraphSageUnsupervisedWriteResult¶
Generate embeddings for the given graph and write the results to the database.
- Parameters:
G (Graph) – The graph to generate embeddings for.
feature_properties (list[str]) – Names of the node properties to use as input features
write_property (str) – The property to write the embeddings to.
batch_size (int | None) – Number of nodes to process in each batch.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
job_id (str | None) – Identifier for the computation.
write_concurrency (int | None) – Number of concurrent threads to use for writing.
- Returns:
The result of the write operation.
- Return type:
- pydantic model graphdatascience.procedure_surface.api.node_embedding.GraphSageUnsupervisedMutateResult¶
- pydantic model graphdatascience.procedure_surface.api.node_embedding.GraphSageUnsupervisedTrainResult¶
- pydantic model graphdatascience.procedure_surface.api.node_embedding.GraphSageUnsupervisedWriteResult¶
- pydantic model graphdatascience.procedure_surface.api.node_embedding.GraphSageWriteResult¶
- class graphdatascience.procedure_surface.api.node_embedding.HashGNNEndpoints¶
- abstract estimate(G: Graph | dict[str, Any], iterations: int, embedding_density: int, output_dimension: int | None = None, neighbor_influence: float = 1.0, generate_features: dict[str, Any] | None = None, binarize_features: dict[str, Any] | None = None, heterogeneous: bool = False, feature_properties: list[str] | None = None, random_seed: int | None = None) EstimationResult¶
Returns an estimation of the memory consumption for that procedure.
- Parameters:
G (Graph | dict[str, Any]) – Graph object to use or a dictionary representing the graph dimensions.
iterations (int) – Number of iterations to run.
embedding_density (int) – The density of the generated embeddings (number of bits per embedding)
output_dimension (int | None) – The dimension of the output embeddings.
neighbor_influence (float) – The influence of neighboring nodes.
generate_features (dict[str, Any] | None) – Configuration for generating synthetic features from existing node properties
binarize_features (dict[str, Any] | None) – Configuration for binarizing continuous features
heterogeneous (bool) – Whether to use heterogeneous node processing for different node types
feature_properties (list[str] | None) – Names of the node properties to use as input features. Defaults to [] if not specified
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
- Returns:
The estimated cost of running the algorithm
- Return type:
- abstract mutate(G: Graph, iterations: int, embedding_density: int, mutate_property: str, output_dimension: int | None = None, neighbor_influence: float = 1.0, generate_features: dict[str, Any] | None = None, binarize_features: dict[str, Any] | None = None, heterogeneous: bool = False, feature_properties: list[str] | None = None, random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None) HashGNNMutateResult¶
Executes the HashGNN algorithm and writes the results back to the graph as a node property.
- Parameters:
G (Graph) – Graph object to use
iterations (int) – Number of iterations to run.
embedding_density (int) – The density of the generated embeddings (number of bits per embedding)
mutate_property (str) – Name of the node property to store the results in.
output_dimension (int | None) – The dimension of the output embeddings
neighbor_influence (float) – The influence of neighboring nodes
generate_features (dict[str, Any] | None) – Configuration for generating synthetic features from existing node properties
binarize_features (dict[str, Any] | None) – Configuration for binarizing continuous features
heterogeneous (bool) – Whether to use heterogeneous node processing for different node types
feature_properties (list[str] | None) – Names of the node properties to use as input features. Defaults to [] if not specified
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
sudo (bool)
log_progress (bool)
username (str | None)
concurrency (int | None)
job_id (str | None)
- Returns:
Algorithm metrics and statistics
- Return type:
- abstract stream(G: Graph, iterations: int, embedding_density: int, output_dimension: int | None = None, neighbor_influence: float = 1.0, generate_features: dict[str, Any] | None = None, binarize_features: dict[str, Any] | None = None, heterogeneous: bool = False, feature_properties: list[str] | None = None, random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None) DataFrame¶
Executes the HashGNN algorithm and returns the results as a stream.
- Parameters:
G (Graph) – Graph object to use
iterations (int) – Number of iterations to run.
embedding_density (int) – The density of the generated embeddings (number of bits per embedding)
output_dimension (int | None) – The dimension of the output embeddings
neighbor_influence (float) – The influence of neighboring nodes
generate_features (dict[str, Any] | None) – Configuration for generating synthetic features from existing node properties
binarize_features (dict[str, Any] | None) – Configuration for binarizing continuous features
heterogeneous (bool) – Whether to use heterogeneous node processing for different node types
feature_properties (list[str] | None) – Names of the node properties to use as input features. Defaults to [] if not specified
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
sudo (bool)
log_progress (bool)
username (str | None)
concurrency (int | None)
job_id (str | None)
- Returns:
DataFrame with node IDs and their embeddings
- Return type:
- abstract write(G: Graph, iterations: int, embedding_density: int, write_property: str, output_dimension: int | None = None, neighbor_influence: float = 1.0, generate_features: dict[str, Any] | None = None, binarize_features: dict[str, Any] | None = None, heterogeneous: bool = False, feature_properties: list[str] | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, write_concurrency: int | None = None, random_seed: int | None = None) HashGNNWriteResult¶
Executes the HashGNN algorithm and writes the results back to the database.
- Parameters:
G (Graph) – Graph object to use
iterations (int) – Number of iterations to run.
embedding_density (int) – The density of the generated embeddings (number of bits per embedding)
write_property (str) – Name of the node property to store the results in.
output_dimension (int | None) – The dimension of the output embeddings. If not specified, defaults to embedding_density / 64
neighbor_influence (float) – The influence of neighboring nodes (0.0 to 1.0)
generate_features (dict[str, Any] | None) – Configuration for generating synthetic features from existing node properties
binarize_features (dict[str, Any] | None) – Configuration for binarizing continuous features
heterogeneous (bool) – Whether to use heterogeneous node processing for different node types
feature_properties (list[str] | None) – Names of the node properties to use as input features. Defaults to [] if not specified
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
sudo (bool) – Disable the memory guard.
log_progress (bool) – Display progress logging.
username (str | None) – As an administrator, impersonate a different user for accessing their graphs.
concurrency (int | None) – Number of concurrent threads to use.
job_id (str | None) – Identifier for the computation.
write_concurrency (int | None) – Number of concurrent threads to use for writing.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
- Returns:
Algorithm metrics and statistics
- Return type:
- pydantic model graphdatascience.procedure_surface.api.node_embedding.HashGNNMutateResult¶
Result object representing the results of running a HashGNN algorithm in mutate mode.
- pydantic model graphdatascience.procedure_surface.api.node_embedding.HashGNNWriteResult¶
Result object representing the results of running a HashGNN algorithm in write mode.
- class graphdatascience.procedure_surface.api.node_embedding.Node2VecEndpoints¶
- abstract estimate(G: Graph | dict[str, Any], iterations: int = 1, negative_sampling_rate: int = 5, positive_sampling_factor: float = 0.001, embedding_dimension: int = 128, embedding_initializer: str = 'NORMALIZED', initial_learning_rate: float = 0.025, min_learning_rate: float = 0.0001, window_size: int = 10, negative_sampling_exponent: float = 0.75, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], concurrency: int | None = None, walk_length: int = 80, walks_per_node: int = 10, in_out_factor: float = 1.0, return_factor: float = 1.0, walk_buffer_size: int = 1000, relationship_weight_property: str | None = None, random_seed: int | None = None) EstimationResult¶
Returns an estimation of the memory consumption for that procedure.
- Parameters:
G (Graph | dict[str, Any]) – Graph object to use or a dictionary representing the graph dimensions.
iterations (int) – Number of iterations to run.
negative_sampling_rate (int) – Number of negative samples for each positive sample
positive_sampling_factor (float) – Factor to multiply positive sampling weights
embedding_dimension (int) – Output dimensionality of the embeddings
embedding_initializer (str) – Strategy for initializing node embeddings. Either “UNIFORM” or “NORMALIZED”
initial_learning_rate (float) – The initial learning rate
min_learning_rate (float) – The minimum learning rate
window_size (int) – Size of the context window
negative_sampling_exponent (float) – Exponent for negative sampling probability distribution
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
concurrency (int | None) – Number of concurrent threads to use.
walk_length (int) – The length of each random walk
walks_per_node (int) – Number of walks to sample for each node
in_out_factor (float) – Controls the likelihood of immediately revisiting a node in the walk
return_factor (float) – Controls the likelihood of visiting already visited nodes
walk_buffer_size (int) – Buffer size for walk sampling
relationship_weight_property (str | None) – Name of the property to be used as weights.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
- Returns:
Memory estimation details
- Return type:
- abstract mutate(G: Graph, mutate_property: str, iterations: int = 1, negative_sampling_rate: int = 5, positive_sampling_factor: float = 0.001, embedding_dimension: int = 128, embedding_initializer: str = 'NORMALIZED', initial_learning_rate: float = 0.025, min_learning_rate: float = 0.0001, window_size: int = 10, negative_sampling_exponent: float = 0.75, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None, walk_length: int = 80, walks_per_node: int = 10, in_out_factor: float = 1.0, return_factor: float = 1.0, walk_buffer_size: int = 1000, relationship_weight_property: str | None = None, random_seed: int | None = None) Node2VecMutateResult¶
Executes the Node2Vec algorithm and writes the results back to the graph as a node property.
- Parameters:
G (Graph) – Graph object to use
mutate_property (str) – Name of the node property to store the results in.
iterations (int) – Number of iterations to run.
negative_sampling_rate (int) – Number of negative samples for each positive sample
positive_sampling_factor (float) – Factor to multiply positive sampling weights
embedding_dimension (int) – Output dimensionality of the embeddings
embedding_initializer (str) – Strategy for initializing node embeddings. Either “UNIFORM” or “NORMALIZED”
initial_learning_rate (float) – The initial learning rate
min_learning_rate (float) – The minimum learning rate
window_size (int) – Size of the context window
negative_sampling_exponent (float) – Exponent for negative sampling probability distribution
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
username (str | None) – As an administrator, impersonate a different user for accessing their graphs.
log_progress (bool) – Display progress logging.
sudo (bool) – Disable the memory guard.
concurrency (int | None) – Number of concurrent threads to use.
job_id (str | None) – Identifier for the computation.
walk_length (int) – The length of each random walk
walks_per_node (int) – Number of walks to sample for each node
in_out_factor (float) – Controls the likelihood of immediately revisiting a node in the walk
return_factor (float) – Controls the likelihood of visiting already visited nodes
walk_buffer_size (int) – Buffer size for walk sampling
relationship_weight_property (str | None) – Name of the property to be used as weights.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
- Returns:
Algorithm metrics and statistics
- Return type:
- abstract stream(G: Graph, iterations: int = 1, negative_sampling_rate: int = 5, positive_sampling_factor: float = 0.001, embedding_dimension: int = 128, embedding_initializer: str = 'NORMALIZED', initial_learning_rate: float = 0.025, min_learning_rate: float = 0.0001, window_size: int = 10, negative_sampling_exponent: float = 0.75, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None, walk_length: int = 80, walks_per_node: int = 10, in_out_factor: float = 1.0, return_factor: float = 1.0, walk_buffer_size: int = 1000, relationship_weight_property: str | None = None, random_seed: int | None = None) DataFrame¶
Executes the Node2Vec algorithm and returns the results as a stream.
- Parameters:
G (Graph) – Graph object to use
iterations (int) – Number of iterations to run.
negative_sampling_rate (int) – Number of negative samples for each positive sample
positive_sampling_factor (float) – Factor to multiply positive sampling weights
embedding_dimension (int) – Output dimensionality of the embeddings
embedding_initializer (str) – Strategy for initializing node embeddings. Either “UNIFORM” or “NORMALIZED”
initial_learning_rate (float) – The initial learning rate
min_learning_rate (float) – The minimum learning rate
window_size (int) – Size of the context window
negative_sampling_exponent (float) – Exponent for negative sampling probability distribution
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
username (str | None) – As an administrator, impersonate a different user for accessing their graphs.
log_progress (bool) – Display progress logging.
sudo (bool) – Disable the memory guard.
concurrency (int | None) – Number of concurrent threads to use.
job_id (str | None) – Identifier for the computation.
walk_length (int) – The length of each random walk
walks_per_node (int) – Number of walks to sample for each node
in_out_factor (float) – Controls the likelihood of immediately revisiting a node in the walk
return_factor (float) – Controls the likelihood of visiting already visited nodes
walk_buffer_size (int) – Buffer size for walk sampling
relationship_weight_property (str | None) – Name of the property to be used as weights.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
- Returns:
Embeddings as a stream with columns nodeId and embedding
- Return type:
- abstract write(G: Graph, write_property: str, iterations: int = 1, negative_sampling_rate: int = 5, positive_sampling_factor: float = 0.001, embedding_dimension: int = 128, embedding_initializer: str = 'NORMALIZED', initial_learning_rate: float = 0.025, min_learning_rate: float = 0.0001, window_size: int = 10, negative_sampling_exponent: float = 0.75, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None, walk_length: int = 80, walks_per_node: int = 10, in_out_factor: float = 1.0, return_factor: float = 1.0, walk_buffer_size: int = 1000, relationship_weight_property: str | None = None, random_seed: int | None = None, write_concurrency: int | None = None) Node2VecWriteResult¶
Executes the Node2Vec algorithm and writes the results back to the database.
- Parameters:
G (Graph) – Graph object to use
write_property (str) – Name of the node property to store the results in.
iterations (int) – Number of iterations to run.
negative_sampling_rate (int) – Number of negative samples for each positive sample
positive_sampling_factor (float) – Factor to multiply positive sampling weights
embedding_dimension (int) – Output dimensionality of the embeddings
embedding_initializer (str) – Strategy for initializing node embeddings. Either “UNIFORM” or “NORMALIZED”
initial_learning_rate (float) – The initial learning rate
min_learning_rate (float) – The minimum learning rate
window_size (int) – Size of the context window
negative_sampling_exponent (float) – Exponent for negative sampling probability distribution
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
username (str | None) – As an administrator, impersonate a different user for accessing their graphs.
log_progress (bool) – Display progress logging.
sudo (bool) – Disable the memory guard.
concurrency (int | None) – Number of concurrent threads to use.
job_id (str | None) – Identifier for the computation.
walk_length (int) – The length of each random walk
walks_per_node (int) – Number of walks to sample for each node
in_out_factor (float) – Controls the likelihood of immediately revisiting a node in the walk
return_factor (float) – Controls the likelihood of visiting already visited nodes
walk_buffer_size (int) – Buffer size for walk sampling
relationship_weight_property (str | None) – Name of the property to be used as weights.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
write_concurrency (int | None) – Number of concurrent threads to use for writing.Returns
-------
Node2VecWriteResult – Algorithm metrics and statistics
- Return type:
- pydantic model graphdatascience.procedure_surface.api.node_embedding.Node2VecMutateResult¶
- pydantic model graphdatascience.procedure_surface.api.node_embedding.Node2VecWriteResult¶
- class graphdatascience.procedure_surface.arrow.node_embedding.graphsage_session_endpoints.GraphSageSessionEndpoints¶
API for the GraphSage algorithm in GDS Sessions, combining classic training and prediction with the unsupervised GraphSage endpoints (the successor of the classic gds.graph_sage.train) and the supervised (node classification) GraphSage endpoints.
- compute(G: Graph, model_name: str, *, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None, batch_size: int = 100) JobHandle¶
Start a classic GraphSage prediction and return a
JobHandle.The handle exposes
stream/mutate/writeso the caller can decide how to materialize the prediction after the computation is started.
- property supervised: GraphSageSupervisedEndpoints¶
Endpoints for the supervised (node classification) GraphSage.
- Return type:
- property unsupervised: GraphSageUnsupervisedEndpoints¶
Endpoints for the unsupervised GraphSage.
- Return type:
- class graphdatascience.procedure_surface.api.node_embedding.graphsage_model.GraphSageModel¶
Represents a GraphSAGE model in the model catalog. Construct this using gds.v2.graphSage.train().
- predict_estimate(G: Graph, *, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], batch_size: int = 100, concurrency: int | None = None, log_progress: bool = True, username: str | None = None, sudo: bool = False, job_id: str | None = None) EstimationResult¶
Estimate the memory needed to generate embeddings for the given graph and write the results to the database.
- Parameters:
G (Graph) – The graph to generate embeddings for.
relationship_types (list[str]) – The relationship types to consider.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
batch_size (int) – The batch size for prediction.
concurrency (int | None) – Number of concurrent threads to use.
log_progress (bool) – Display progress logging.
username (str | None) – As an administrator, impersonate a different user for accessing their graphs.
sudo (bool) – Disable the memory guard.
job_id (str | None) – Identifier for the computation.
- Returns:
The memory needed to generate embeddings for the given graph and write the results to the database.
- Return type:
- predict_mutate(G: Graph, mutate_property: str, *, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], batch_size: int = 100, concurrency: int | None = None, log_progress: bool = True, username: str | None = None, sudo: bool = False, job_id: str | None = None) GraphSageMutateResult¶
Generate embeddings for the given graph and mutate the graph with the results.
- Parameters:
G (Graph) – The graph to generate embeddings for.
mutate_property (str) – The property to mutate with the embeddings.
relationship_types (list[str]) – The relationship types to consider.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
batch_size (int) – The batch size for prediction.
concurrency (int | None) – Number of concurrent threads to use.
log_progress (bool) – Display progress logging.
username (str | None) – As an administrator, impersonate a different user for accessing their graphs.
sudo (bool) – Disable the memory guard.
job_id (str | None) – Identifier for the computation.
- Returns:
The result of the mutate operation.
- Return type:
- predict_stream(G: Graph, *, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], batch_size: int = 100, concurrency: int | None = None, log_progress: bool = True, username: str | None = None, sudo: bool = False, job_id: str | None = None) DataFrame¶
Generate embeddings for the given graph and stream the results.
- Parameters:
G (Graph) – The graph to generate embeddings for.
relationship_types (list[str]) – The relationship types to consider.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
batch_size (int) – The batch size for prediction.
concurrency (int | None) – Number of concurrent threads to use.
log_progress (bool) – Display progress logging.
username (str | None) – As an administrator, impersonate a different user for accessing their graphs.
sudo (bool) – Disable the memory guard.
job_id (str | None) – Identifier for the computation.
- Returns:
The streaming results as a DataFrame.
- Return type:
- predict_write(G: Graph, write_property: str, *, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], batch_size: int = 100, concurrency: int | None = None, write_concurrency: int | None = None, log_progress: bool = True, username: str | None = None, sudo: bool = False, job_id: str | None = None) GraphSageWriteResult¶
Generate embeddings for the given graph and write the results to the database.
- Parameters:
G (Graph) – The graph to generate embeddings for.
write_property (str) – The property to write the embeddings to.
relationship_types (list[str]) – The relationship types to consider.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
batch_size (int) – The batch size for prediction.
concurrency (int | None) – Number of concurrent threads to use.
write_concurrency (int | None) – The concurrency for writing.
log_progress (bool) – Display progress logging.
username (str | None) – As an administrator, impersonate a different user for accessing their graphs.
sudo (bool) – Disable the memory guard.
job_id (str | None) – Identifier for the computation.
- Returns:
The result of the write operation.
- Return type:
- class graphdatascience.procedure_surface.api.node_embedding.graphsage_unsupervised_model.GraphSageUnsupervisedModel¶
Represents an unsupervised GraphSage model in the model catalog. Construct this using gds.graph_sage.unsupervised.train.
- predict_mutate(G: Graph, feature_properties: list[str], mutate_property: str, *, batch_size: int | None = None, random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], job_id: str | None = None) GraphSageUnsupervisedMutateResult¶
Generate embeddings for the given graph and mutate the graph with the results.
- Parameters:
G (Graph) – The graph to generate embeddings for.
feature_properties (list[str]) – Names of the node properties to use as input features
mutate_property (str) – The property to mutate with the embeddings.
batch_size (int | None) – Number of nodes to process in each batch.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
job_id (str | None) – Identifier for the computation.
- Returns:
The result of the mutate operation.
- Return type:
- predict_stream(G: Graph, feature_properties: list[str], *, batch_size: int | None = None, random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], job_id: str | None = None) DataFrame¶
Generate embeddings for the given graph and stream the results.
- Parameters:
G (Graph) – The graph to generate embeddings for.
feature_properties (list[str]) – Names of the node properties to use as input features
batch_size (int | None) – Number of nodes to process in each batch.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
job_id (str | None) – Identifier for the computation.
- Returns:
The streaming results as a DataFrame.
- Return type:
- predict_write(G: Graph, feature_properties: list[str], write_property: str, *, batch_size: int | None = None, random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], job_id: str | None = None, write_concurrency: int | None = None) GraphSageUnsupervisedWriteResult¶
Generate embeddings for the given graph and write the results to the database.
- Parameters:
G (Graph) – The graph to generate embeddings for.
feature_properties (list[str]) – Names of the node properties to use as input features
write_property (str) – The property to write the embeddings to.
batch_size (int | None) – Number of nodes to process in each batch.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
job_id (str | None) – Identifier for the computation.
write_concurrency (int | None) – Number of concurrent threads to use for writing.
- Returns:
The result of the write operation.
- Return type:
- class graphdatascience.procedure_surface.api.node_embedding.graphsage_supervised_model.GraphSageSupervisedModel¶
Represents a supervised (node classification) GraphSage model in the model catalog. Construct this using gds.graph_sage.supervised.train.
- predict_mutate(G: Graph, feature_properties: list[str], mutate_property: str, *, predicted_probability_property: str | None = None, batch_size: int | None = None, random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], job_id: str | None = None) GraphSageSupervisedMutateResult¶
Predict classes for the given graph and mutate the graph with the results.
- Parameters:
G (Graph) – The graph to predict classes for.
feature_properties (list[str]) – Names of the node properties to use as input features
mutate_property (str) – The property to mutate with the predicted classes.
predicted_probability_property (str | None) – The property to mutate with the predicted class probabilities.
batch_size (int | None) – Number of nodes to process in each batch.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
job_id (str | None) – Identifier for the computation.
- Returns:
The result of the mutate operation.
- Return type:
- predict_stream(G: Graph, feature_properties: list[str], *, batch_size: int | None = None, random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], job_id: str | None = None) DataFrame¶
Predict classes for the given graph and stream the results.
- Parameters:
G (Graph) – The graph to predict classes for.
feature_properties (list[str]) – Names of the node properties to use as input features
batch_size (int | None) – Number of nodes to process in each batch.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
job_id (str | None) – Identifier for the computation.
- Returns:
The streaming results as a DataFrame with node IDs, predicted classes and predicted class probabilities.
- Return type:
- predict_write(G: Graph, feature_properties: list[str], write_property: str, *, predicted_probability_property: str | None = None, batch_size: int | None = None, random_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], job_id: str | None = None, write_concurrency: int | None = None) GraphSageSupervisedWriteResult¶
Predict classes for the given graph and write the results to the database.
- Parameters:
G (Graph) – The graph to predict classes for.
feature_properties (list[str]) – Names of the node properties to use as input features
write_property (str) – The property to write the predicted classes to.
predicted_probability_property (str | None) – The property to write the predicted class probabilities to.
batch_size (int | None) – Number of nodes to process in each batch.
random_seed (int | None) – Seed for random number generation to ensure reproducible results.
relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.
node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.
job_id (str | None) – Identifier for the computation.
write_concurrency (int | None) – Number of concurrent threads to use for writing.
- Returns:
The result of the write operation.
- Return type:
- pydantic model graphdatascience.embedding.FastRPConfig¶
Configuration for the FastRP graph encoder.
- field coefficients: list[float] | None¶
Weights for each iteration. Controls the influence of each iteration on the final embedding.
- pydantic model graphdatascience.embedding.GraphSAGEConfig¶
Configuration for the GraphSAGE graph encoder.
- field dropout: Annotated[float, FieldInfo(annotation=NoneType, required=True, metadata=[Ge(ge=0.0), Lt(lt=1.0)])] | None¶
Dropout probability applied during training.
- Validated by:
depth_validator
Sizes of the hidden layers. The depth of the GNN is inferred as len(hidden_dims) + 1.
- Validated by:
depth_validator
- pydantic model graphdatascience.embedding.MLPClassifierConfig¶
Configuration for the multi-layer perceptron classifier decoder.
- field dropout: Annotated[float, FieldInfo(annotation=NoneType, required=True, metadata=[Ge(ge=0.0), Lt(lt=1.0)])] | None¶
Dropout probability applied during training.
Sizes of the hidden layers of the network.