Machine Learning Pipelines

class graphdatascience.procedure_surface.api.pipeline.LinkPredictionModel

Represents a link prediction model in the model catalog.

Construct this using: func:gds.pipeline.link_prediction.train().

predict_estimate(G: Graph, *, source_node_label: str | None = None, target_node_label: str | None = None, top_n: int | None = None, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → EstimationResult
Parameters:
  • G (Graph)

  • source_node_label (str | None)

  • target_node_label (str | None)

  • top_n (int | None)

  • username (str | None)

  • log_progress (bool)

  • sudo (bool)

  • concurrency (int | None)

  • job_id (str | None)

Return type:

EstimationResult

predict_mutate(G: Graph, mutate_relationship_type: str, *, mutate_property: str = 'probability', relationship_types: list[str] | None = None, sample_rate: float = 1.0, source_node_label: str | None = None, target_node_label: str | None = None, threshold: float | None = None, top_k: int | None = None, top_n: int | None = None, initial_sampler: str | None = None, delta_threshold: float | None = None, max_iterations: int | None = None, random_joins: int | None = None, random_seed: int | None = None, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → LinkPredictionPipelinePredictMutateResult
Parameters:
  • G (Graph)

  • mutate_relationship_type (str)

  • mutate_property (str)

  • relationship_types (list[str] | None)

  • sample_rate (float)

  • source_node_label (str | None)

  • target_node_label (str | None)

  • threshold (float | None)

  • top_k (int | None)

  • top_n (int | None)

  • initial_sampler (str | None)

  • delta_threshold (float | None)

  • max_iterations (int | None)

  • random_joins (int | None)

  • random_seed (int | None)

  • username (str | None)

  • log_progress (bool)

  • sudo (bool)

  • concurrency (int | None)

  • job_id (str | None)

Return type:

LinkPredictionPipelinePredictMutateResult

predict_stream(G: Graph, *, relationship_types: list[str] | None = None, sample_rate: float = 1.0, source_node_label: str | None = None, target_node_label: str | None = None, threshold: float | None = None, top_k: int | None = None, top_n: int | None = None, initial_sampler: str | None = None, delta_threshold: float | None = None, max_iterations: int | None = None, random_joins: int | None = None, random_seed: int | None = None, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → DataFrame
Parameters:
  • G (Graph)

  • relationship_types (list[str] | None)

  • sample_rate (float)

  • source_node_label (str | None)

  • target_node_label (str | None)

  • threshold (float | None)

  • top_k (int | None)

  • top_n (int | None)

  • initial_sampler (str | None)

  • delta_threshold (float | None)

  • max_iterations (int | None)

  • random_joins (int | None)

  • random_seed (int | None)

  • username (str | None)

  • log_progress (bool)

  • sudo (bool)

  • concurrency (int | None)

  • job_id (str | None)

Return type:

DataFrame

class graphdatascience.procedure_surface.api.pipeline.LinkPredictionPipeline

Represents a link prediction training pipeline.

Construct this using gds.v2.pipeline.link_prediction.create().

add_feature(feature_type: str, *, node_properties: list[str]) → LinkPredictionPipelineInfoResult
Parameters:
Return type:

LinkPredictionPipelineInfoResult

add_logistic_regression(*, batch_size: int | tuple[int, int] = 100, class_weights: list[float] | None = None, focus_weight: float | tuple[float, float] = 0.0, learning_rate: float | tuple[float, float] = 0.001, max_epochs: int | tuple[int, int] = 100, min_epochs: int | tuple[int, int] = 1, patience: int | tuple[int, int] = 1, penalty: float | tuple[float, float] = 0.0, tolerance: float | tuple[float, float] = 0.001) → LinkPredictionPipelineInfoResult
Parameters:
Return type:

LinkPredictionPipelineInfoResult

add_mlp(*, batch_size: int | tuple[int, int] = 100, class_weights: list[float] | None = None, focus_weight: float | tuple[float, float] = 0.0, hidden_layer_sizes: list[int] = [100], learning_rate: float | tuple[float, float] = 0.001, max_epochs: int | tuple[int, int] = 100, min_epochs: int | tuple[int, int] = 1, patience: int | tuple[int, int] = 1, penalty: float | tuple[float, float] = 0.0, tolerance: float | tuple[float, float] = 0.001) → LinkPredictionPipelineInfoResult
Parameters:
Return type:

LinkPredictionPipelineInfoResult

add_node_property(task_name: str, **config: Any) → LinkPredictionPipelineInfoResult
Parameters:
  • task_name (str)

  • config (Any)

Return type:

LinkPredictionPipelineInfoResult

add_random_forest(*, criterion: str | None = 'GINI', max_depth: int | tuple[int, int] = 2147483647, max_features_ratio: float | tuple[float, float] | None = None, min_leaf_size: int | tuple[int, int] = 1, min_split_size: int | tuple[int, int] = 2, number_of_decision_trees: int | tuple[int, int] = 100, number_of_samples_ratio: float | tuple[float, float] = 1.0) → LinkPredictionPipelineInfoResult
Parameters:
Return type:

LinkPredictionPipelineInfoResult

configure_auto_tuning(*, max_trials: int = 10) → LinkPredictionPipelineInfoResult
Parameters:

max_trials (int)

Return type:

LinkPredictionPipelineInfoResult

configure_split(*, negative_relationship_type: str | None = None, negative_sampling_ratio: float = 1.0, test_fraction: float = 0.1, train_fraction: float = 0.1, validation_folds: int = 3) → LinkPredictionPipelineInfoResult
Parameters:
  • negative_relationship_type (str | None)

  • negative_sampling_ratio (float)

  • test_fraction (float)

  • train_fraction (float)

  • validation_folds (int)

Return type:

LinkPredictionPipelineInfoResult

details() → LinkPredictionPipelineInfoResult

Return the stored configuration of the pipeline (feature steps, split, parameter space).

Return type:

LinkPredictionPipelineInfoResult

drop(fail_if_missing: bool = False) → PipelineCatalogEntryProtocol | None
Parameters:

fail_if_missing (bool)

Return type:

PipelineCatalogEntryProtocol | None

exists() → bool
Return type:

bool

name() → str
Return type:

str

train(G: Graph, *, model_name: str, metrics: list[str] = ['AUCPR'], negative_class_weight: float = 1.0, source_node_label: str = '*', target_node_label: str = '*', target_relationship_type: str, store_model_to_disk: bool = False, random_seed: Any | None = None, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → tuple[LinkPredictionModel, LinkPredictionPipelineTrainResult]
Parameters:
  • G (Graph)

  • model_name (str)

  • metrics (list[str])

  • negative_class_weight (float)

  • source_node_label (str)

  • target_node_label (str)

  • target_relationship_type (str)

  • store_model_to_disk (bool)

  • random_seed (Any | None)

  • username (str | None)

  • log_progress (bool)

  • sudo (bool)

  • concurrency (int | None)

  • job_id (str | None)

Return type:

tuple[LinkPredictionModel, LinkPredictionPipelineTrainResult]

train_estimate(G: Graph, *, model_name: str, metrics: list[str] = ['AUCPR'], negative_class_weight: float = 1.0, source_node_label: str = '*', target_node_label: str = '*', target_relationship_type: str, store_model_to_disk: bool = False, random_seed: Any | None = None, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → EstimationResult
Parameters:
  • G (Graph)

  • model_name (str)

  • metrics (list[str])

  • negative_class_weight (float)

  • source_node_label (str)

  • target_node_label (str)

  • target_relationship_type (str)

  • store_model_to_disk (bool)

  • random_seed (Any | None)

  • username (str | None)

  • log_progress (bool)

  • sudo (bool)

  • concurrency (int | None)

  • job_id (str | None)

Return type:

EstimationResult

class graphdatascience.procedure_surface.api.pipeline.LinkPredictionPipelineEndpoints
abstractmethod add_feature(pipeline_name: str, feature_type: str, *, node_properties: list[str]) → LinkPredictionPipelineInfoResult

Add an relationship feature step to the pipeline.

Parameters:
  • pipeline_name (str) – Name of the pipeline.

  • feature_type (str) – Type of feature step to add.

  • node_properties (list[str]) – Node properties used to compute the feature.

Returns:

The updated pipeline state.

Return type:

LinkPredictionPipelineInfoResult

abstractmethod add_logistic_regression(pipeline_name: str, *, batch_size: int | tuple[int, int] = 100, class_weights: list[float] | None = None, focus_weight: float | tuple[float, float] = 0.0, learning_rate: float | tuple[float, float] = 0.001, max_epochs: int | tuple[int, int] = 100, min_epochs: int | tuple[int, int] = 1, patience: int | tuple[int, int] = 1, penalty: float | tuple[float, float] = 0.0, tolerance: float | tuple[float, float] = 0.001) → LinkPredictionPipelineInfoResult

Add a logistic regression model candidate to the pipeline.

Parameters:
  • pipeline_name (str) – Name of the pipeline.

  • batch_size (int | tuple[int, int]) – Batch size to use during training. Pass a two-value tuple to define a parameter range.

  • class_weights (list[float] | None) – Optional class weights to use during training.

  • focus_weight (float | tuple[float, float]) – Focus weight for optimization. Pass a two-value tuple to define a parameter range.

  • learning_rate (float | tuple[float, float]) – Learning rate for optimization. Pass a two-value tuple to define a parameter range.

  • max_epochs (int | tuple[int, int]) – Maximum number of training epochs. Pass a two-value tuple to define a parameter range.

  • min_epochs (int | tuple[int, int]) – Minimum number of training epochs. Pass a two-value tuple to define a parameter range.

  • patience (int | tuple[int, int]) – Early stopping patience. Pass a two-value tuple to define a parameter range.

  • penalty (float | tuple[float, float]) – Penalty term to use during training. Pass a two-value tuple to define a parameter range.

  • tolerance (float | tuple[float, float]) – Convergence tolerance. Pass a two-value tuple to define a parameter range.

Returns:

The updated pipeline state.

Return type:

LinkPredictionPipelineInfoResult

abstractmethod add_mlp(pipeline_name: str, *, batch_size: int | tuple[int, int] = 100, class_weights: list[float] | None = None, focus_weight: float | tuple[float, float] = 0.0, hidden_layer_sizes: list[int] = [100], learning_rate: float | tuple[float, float] = 0.001, max_epochs: int | tuple[int, int] = 100, min_epochs: int | tuple[int, int] = 1, patience: int | tuple[int, int] = 1, penalty: float | tuple[float, float] = 0.0, tolerance: float | tuple[float, float] = 0.001) → LinkPredictionPipelineInfoResult

Add a multi-layer perceptron model candidate to the pipeline.

Parameters:
  • pipeline_name (str) – Name of the pipeline.

  • batch_size (int | tuple[int, int]) – Batch size to use during training. Pass a two-value tuple to define a parameter range.

  • class_weights (list[float] | None) – Optional class weights to use during training.

  • focus_weight (float | tuple[float, float]) – Focus weight for optimization. Pass a two-value tuple to define a parameter range.

  • hidden_layer_sizes (list[int]) – Sizes of the hidden layers in the neural network.

  • learning_rate (float | tuple[float, float]) – Learning rate for optimization. Pass a two-value tuple to define a parameter range.

  • max_epochs (int | tuple[int, int]) – Maximum number of training epochs. Pass a two-value tuple to define a parameter range.

  • min_epochs (int | tuple[int, int]) – Minimum number of training epochs. Pass a two-value tuple to define a parameter range.

  • patience (int | tuple[int, int]) – Early stopping patience. Pass a two-value tuple to define a parameter range.

  • penalty (float | tuple[float, float]) – Penalty term to use during training. Pass a two-value tuple to define a parameter range.

  • tolerance (float | tuple[float, float]) – Convergence tolerance. Pass a two-value tuple to define a parameter range.

Returns:

The updated pipeline state.

Return type:

LinkPredictionPipelineInfoResult

abstractmethod add_node_property(pipeline_name: str, task_name: str, **config: Any) → LinkPredictionPipelineInfoResult

Add a node property step to the pipeline.

Parameters:
  • pipeline_name (str) – Name of the pipeline.

  • task_name (str) – The task name of the node property step to add.

  • config (Any) – Additional configuration for the node property step.

Returns:

The updated pipeline state.

Return type:

LinkPredictionPipelineInfoResult

abstractmethod add_random_forest(pipeline_name: str, *, criterion: str | None = 'GINI', max_depth: int | tuple[int, int] = 2147483647, max_features_ratio: float | tuple[float, float] | None = None, min_leaf_size: int | tuple[int, int] = 1, min_split_size: int | tuple[int, int] = 2, number_of_decision_trees: int | tuple[int, int] = 100, number_of_samples_ratio: float | tuple[float, float] = 1.0) → LinkPredictionPipelineInfoResult

Add a random forest model candidate to the pipeline.

Parameters:
  • pipeline_name (str) – Name of the pipeline.

  • criterion (str | None) – Split criterion to optimize.

  • max_depth (int | tuple[int, int]) – Maximum tree depth. Pass a two-value tuple to define a parameter range.

  • max_features_ratio (float | tuple[float, float] | None) – Fraction of features sampled per split. Pass a two-value tuple to define a parameter range.

  • min_leaf_size (int | tuple[int, int]) – Minimum number of samples in a leaf. Pass a two-value tuple to define a parameter range.

  • min_split_size (int | tuple[int, int]) – Minimum number of samples required to split a node. Pass a two-value tuple to define a parameter range.

  • number_of_decision_trees (int | tuple[int, int]) – Number of trees to train. Pass a two-value tuple to define a parameter range.

  • number_of_samples_ratio (float | tuple[float, float]) – Fraction of samples used per tree. Pass a two-value tuple to define a parameter range.

Returns:

The updated pipeline state.

Return type:

LinkPredictionPipelineInfoResult

abstractmethod configure_auto_tuning(pipeline_name: str, *, max_trials: int = 10) → LinkPredictionPipelineInfoResult

Configure auto-tuning for the pipeline.

Parameters:
  • pipeline_name (str) – Name of the pipeline.

  • max_trials (int) – Maximum number of trials to run during auto-tuning.

Returns:

The updated pipeline state.

Return type:

LinkPredictionPipelineInfoResult

abstractmethod configure_split(pipeline_name: str, *, negative_relationship_type: str | None = None, negative_sampling_ratio: float = 1.0, test_fraction: float = 0.1, train_fraction: float = 0.1, validation_folds: int = 3) → LinkPredictionPipelineInfoResult

Configure the train-test split used by the pipeline.

Parameters:
  • pipeline_name (str) – Name of the pipeline.

  • negative_relationship_type (str | None) – Relationship type to use for the negative samples.

  • negative_sampling_ratio (float) – Ratio of sampled negative relationships.

  • test_fraction (float) – Fraction of relationships reserved for testing.

  • train_fraction (float) – Fraction of relationships reserved for training.

  • validation_folds (int) – Number of validation folds to use.

Returns:

The updated pipeline state.

Return type:

LinkPredictionPipelineInfoResult

abstractmethod create(pipeline_name: str) → tuple[LinkPredictionPipeline, LinkPredictionPipelineInfoResult]

Create a new link prediction pipeline.

Parameters:

pipeline_name (str) – Name of the pipeline.

Returns:

The created pipeline and the corresponding result payload.

Return type:

tuple[LinkPredictionPipeline, LinkPredictionPipelineInfoResult]

abstractmethod get(pipeline_name: str) → LinkPredictionPipeline

Retrieve an existing link prediction pipeline by name.

Parameters:

pipeline_name (str) – Name of the pipeline.

Returns:

The reconstructed pipeline object.

Return type:

LinkPredictionPipeline

abstractmethod get_model(model_name: str) → LinkPredictionModel

Retrieve an existing link prediction model by name.

Returns the same model object as the train method of a link prediction pipeline.

Parameters:

model_name (str) – Name of the model.

Returns:

The reconstructed model object.

Return type:

LinkPredictionModel

abstract property predict: LinkPredictionPipelinePredictEndpoints

Access prediction endpoints for link prediction models trained from this surface.

abstract property train: LinkPredictionPipelineTrainEndpoints

Access training endpoints for link prediction pipelines.

class graphdatascience.procedure_surface.api.pipeline.LinkPredictionPipelineInfoResult
auto_tuning_config: dict[str, Any]
feature_steps: list[Any]
name: str
node_property_steps: list[Any]
parameter_space: dict[str, Any]
split_config: dict[str, Any]
class graphdatascience.procedure_surface.api.pipeline.LinkPredictionPipelinePredictEndpoints
abstractmethod estimate(G: Graph, model_name: str, *, source_node_label: str | None = None, target_node_label: str | None = None, top_n: int | None = None, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → EstimationResult

Estimate the memory required to run link prediction.

Parameters:
  • G (Graph) – Graph object to use

  • model_name (str) – Name of the model.

  • source_node_label (str | None) – Node label to consider as source nodes for candidate links.

  • target_node_label (str | None) – Node label to consider as target nodes for candidate links.

  • top_n (int | None) – Keep only the top_n predicted links with the highest probability.

  • 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.

Returns:

The estimated memory footprint for prediction.

Return type:

EstimationResult

abstractmethod mutate(G: Graph, model_name: str, mutate_relationship_type: str, *, mutate_property: str = 'probability', relationship_types: list[str] | None = None, sample_rate: float = 1.0, source_node_label: str | None = None, target_node_label: str | None = None, threshold: float | None = None, top_k: int | None = None, top_n: int | None = None, initial_sampler: str | None = None, delta_threshold: float | None = None, max_iterations: int | None = None, random_joins: int | None = None, random_seed: int | None = None, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → LinkPredictionPipelinePredictMutateResult

Run link prediction in mutate mode, writing the predicted links back to the in-memory graph.

Parameters:
  • G (Graph) – Graph object to use

  • model_name (str) – Name of the model.

  • mutate_relationship_type (str) – Name of the relationship type to store the results in.

  • mutate_property (str) – Name of the relationship property to store the predicted probability.

  • relationship_types (list[str] | None) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • sample_rate (float) – Sample rate used to limit the number of candidate node pairs considered.

  • source_node_label (str | None) – Node label to consider as source nodes for candidate links.

  • target_node_label (str | None) – Node label to consider as target nodes for candidate links.

  • threshold (float | None) – Only predicted links with a probability of at least this value are written.

  • top_k (int | None) – Number of predicted links to retain per node.

  • top_n (int | None) – Keep only the top_n predicted links with the highest probability.

  • initial_sampler (str | None) – The sampler used to generate the initial set of candidate node pairs (e.g. “UNIFORM” or “RANDOMWALK”).

  • delta_threshold (float | None) – Convergence threshold used by the approximate strategy.

  • max_iterations (int | None) – Maximum number of iterations for the approximate strategy.

  • random_joins (int | None) – Number of random join attempts per node used by the approximate strategy.

  • random_seed (int | None) – Seed for random number generation to ensure reproducible results.

  • 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.

Returns:

Metrics and statistics about the mutate operation.

Return type:

LinkPredictionPipelinePredictMutateResult

abstractmethod stream(G: Graph, model_name: str, *, relationship_types: list[str] | None = None, sample_rate: float = 1.0, source_node_label: str | None = None, target_node_label: str | None = None, threshold: float | None = None, top_k: int | None = None, top_n: int | None = None, initial_sampler: str | None = None, delta_threshold: float | None = None, max_iterations: int | None = None, random_joins: int | None = None, random_seed: int | None = None, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → DataFrame

Run link prediction in stream mode.

Parameters:
  • G (Graph) – Graph object to use

  • model_name (str) – Name of the model.

  • relationship_types (list[str] | None) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • sample_rate (float) – Sample rate used to limit the number of candidate node pairs considered.

  • source_node_label (str | None) – Node label to consider as source nodes for candidate links.

  • target_node_label (str | None) – Node label to consider as target nodes for candidate links.

  • threshold (float | None) – Only predicted links with a probability of at least this value are returned.

  • top_k (int | None) – Number of predicted links to retain per node.

  • top_n (int | None) – Keep only the top_n predicted links with the highest probability.

  • initial_sampler (str | None) – The sampler used to generate the initial set of candidate node pairs (e.g. “UNIFORM” or “RANDOMWALK”).

  • delta_threshold (float | None) – Convergence threshold used by the approximate strategy.

  • max_iterations (int | None) – Maximum number of iterations for the approximate strategy.

  • random_joins (int | None) – Number of random join attempts per node used by the approximate strategy.

  • random_seed (int | None) – Seed for random number generation to ensure reproducible results.

  • 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.

Returns:

The predicted links as a DataFrame.

Return type:

pandas.DataFrame

class graphdatascience.procedure_surface.api.pipeline.LinkPredictionPipelinePredictMutateResult
compute_millis: int | None
configuration: dict[str, Any] | None
mutate_millis: int | None
post_processing_millis: int | None
pre_processing_millis: int | None
probability_distribution: dict[str, Any] | None
relationships_written: int | None
sampling_stats: dict[str, Any] | None
class graphdatascience.procedure_surface.api.pipeline.LinkPredictionPipelineTrainResult
configuration: dict[str, Any]
model_info: LinkPredictionModelInfoResult
model_selection_stats: dict[str, Any]
train_millis: int
class graphdatascience.procedure_surface.api.pipeline.NodeClassificationPipeline

Represents a node classification training pipeline.

Construct this using gds.v2.pipeline.node_classification.create().

add_logistic_regression(*, batch_size: int | tuple[int, int] = 100, class_weights: list[float] | None = None, focus_weight: float | tuple[float, float] = 0.0, learning_rate: float | tuple[float, float] = 0.001, max_epochs: int | tuple[int, int] = 100, min_epochs: int | tuple[int, int] = 1, patience: int | tuple[int, int] = 1, penalty: float | tuple[float, float] = 0.0, tolerance: float | tuple[float, float] = 0.001) → NodeClassificationPipelineInfoResult

Add a logistic regression model candidate to the pipeline.

Parameters:
  • batch_size (int | tuple[int, int]) – Batch size to use during training. Pass a two-value tuple to define a parameter range.

  • class_weights (list[float] | None) – Optional class weights to use during training.

  • focus_weight (float | tuple[float, float]) – Focus weight for optimization. Pass a two-value tuple to define a parameter range.

  • learning_rate (float | tuple[float, float]) – Learning rate for optimization. Pass a two-value tuple to define a parameter range.

  • max_epochs (int | tuple[int, int]) – Maximum number of training epochs. Pass a two-value tuple to define a parameter range.

  • min_epochs (int | tuple[int, int]) – Minimum number of training epochs. Pass a two-value tuple to define a parameter range.

  • patience (int | tuple[int, int]) – Early stopping patience. Pass a two-value tuple to define a parameter range.

  • penalty (float | tuple[float, float]) – Penalty term to use during training. Pass a two-value tuple to define a parameter range.

  • tolerance (float | tuple[float, float]) – Convergence tolerance. Pass a two-value tuple to define a parameter range.

Returns:

The updated pipeline state.

Return type:

NodeClassificationPipelineInfoResult

add_mlp(*, batch_size: int | tuple[int, int] = 100, class_weights: list[float] | None = None, focus_weight: float | tuple[float, float] = 0.0, hidden_layer_sizes: list[int] = [100], learning_rate: float | tuple[float, float] = 0.001, max_epochs: int | tuple[int, int] = 100, min_epochs: int | tuple[int, int] = 1, patience: int | tuple[int, int] = 1, penalty: float | tuple[float, float] = 0.0, tolerance: float | tuple[float, float] = 0.001) → NodeClassificationPipelineInfoResult

Add a multi-layer perceptron model candidate to the pipeline.

Parameters:
  • batch_size (int | tuple[int, int]) – Batch size to use during training. Pass a two-value tuple to define a parameter range.

  • class_weights (list[float] | None) – Optional class weights to use during training.

  • focus_weight (float | tuple[float, float]) – Focus weight for optimization. Pass a two-value tuple to define a parameter range.

  • hidden_layer_sizes (list[int]) – Sizes of the hidden layers in the neural network.

  • learning_rate (float | tuple[float, float]) – Learning rate for optimization. Pass a two-value tuple to define a parameter range.

  • max_epochs (int | tuple[int, int]) – Maximum number of training epochs. Pass a two-value tuple to define a parameter range.

  • min_epochs (int | tuple[int, int]) – Minimum number of training epochs. Pass a two-value tuple to define a parameter range.

  • patience (int | tuple[int, int]) – Early stopping patience. Pass a two-value tuple to define a parameter range.

  • penalty (float | tuple[float, float]) – Penalty term to use during training. Pass a two-value tuple to define a parameter range.

  • tolerance (float | tuple[float, float]) – Convergence tolerance. Pass a two-value tuple to define a parameter range.

Returns:

The updated pipeline state.

Return type:

NodeClassificationPipelineInfoResult

add_node_property(task_name: str, **config: Any) → NodeClassificationPipelineInfoResult

Add a node property step to the pipeline.

Parameters:
  • task_name (str) – The task name of the node property step to add.

  • config (Any)

Returns:

The updated pipeline state.

Return type:

NodeClassificationPipelineInfoResult

add_random_forest(*, criterion: str | None = 'GINI', max_depth: int | tuple[int, int] = 2147483647, max_features_ratio: float | tuple[float, float] | None = None, min_leaf_size: int | tuple[int, int] = 1, min_split_size: int | tuple[int, int] = 2, number_of_decision_trees: int | tuple[int, int] = 100, number_of_samples_ratio: float | tuple[float, float] = 1.0) → NodeClassificationPipelineInfoResult

Add a random forest model candidate to the pipeline.

Parameters:
  • criterion (str | None) – Split criterion to optimize.

  • max_depth (int | tuple[int, int]) – Maximum tree depth. Pass a two-value tuple to define a parameter range.

  • max_features_ratio (float | tuple[float, float] | None) – Fraction of features sampled per split. Pass a two-value tuple to define a parameter range.

  • min_leaf_size (int | tuple[int, int]) – Minimum number of samples in a leaf. Pass a two-value tuple to define a parameter range.

  • min_split_size (int | tuple[int, int]) – Minimum number of samples required to split a node. Pass a two-value tuple to define a parameter range.

  • number_of_decision_trees (int | tuple[int, int]) – Number of trees to train. Pass a two-value tuple to define a parameter range.

  • number_of_samples_ratio (float | tuple[float, float]) – Fraction of samples used per tree. Pass a two-value tuple to define a parameter range.

Returns:

The updated pipeline state.

Return type:

NodeClassificationPipelineInfoResult

configure_auto_tuning(*, max_trials: int = 10) → NodeClassificationPipelineInfoResult

Configure auto-tuning for the pipeline.

Parameters:

max_trials (int) – Maximum number of trials to run during auto-tuning.

Returns:

The updated pipeline state.

Return type:

NodeClassificationPipelineInfoResult

configure_split(*, test_fraction: float = 0.3, validation_folds: int = 3) → NodeClassificationPipelineInfoResult

Configure the train-test split used by the pipeline.

Parameters:
  • test_fraction (float) – Fraction of nodes reserved for testing.

  • validation_folds (int) – Number of validation folds to use.

Returns:

The updated pipeline state.

Return type:

NodeClassificationPipelineInfoResult

details() → NodeClassificationPipelineInfoResult

Return the stored configuration of the pipeline (feature steps, split, parameter space).

Return type:

NodeClassificationPipelineInfoResult

drop(fail_if_missing: bool = False) → PipelineCatalogEntryProtocol | None

Drop the pipeline and return its catalog entry when available.

Parameters:

fail_if_missing (bool)

Return type:

PipelineCatalogEntryProtocol | None

exists() → bool

Return whether the pipeline exists.

Return type:

bool

name() → str

Return the pipeline name.

Return type:

str

select_features(node_properties: str | list[str]) → NodeClassificationPipelineInfoResult

Select the node properties used as input features.

Parameters:

node_properties (str | list[str]) – One or more node properties to use as features.

Returns:

The updated pipeline state.

Return type:

NodeClassificationPipelineInfoResult

train(G: Graph, *, metrics: list[str], model_name: str, target_property: str, relationship_types: list[str] = ['*'], target_node_labels: list[str] = ['*'], store_model_to_disk: bool = False, random_seed: Any | None = None, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → tuple[NodeClassificationModel, NodeClassificationPipelineTrainResult]

Train a node classification model from this pipeline.

Parameters:
  • G (Graph) – Graph object to use

  • metrics (list[str]) – Metrics to optimize for.

  • model_name (str) – Name of the trained model.

  • target_property (str) – The target node property to predict.

  • relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • target_node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.

  • store_model_to_disk (bool) – Whether to persist the trained model to disk.

  • random_seed (Any | None) – Seed for random number generation to ensure reproducible results.

  • 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.

Returns:

The trained model and the corresponding training result.

Return type:

tuple[NodeClassificationModel, NodeClassificationPipelineTrainResult]

train_estimate(G: Graph, *, metrics: list[str], model_name: str, target_property: str, relationship_types: list[str] = ['*'], target_node_labels: list[str] = ['*'], store_model_to_disk: bool = False, random_seed: Any | None = None, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → EstimationResult

Estimate the memory required to train a node classification model from this pipeline.

Parameters:
  • G (Graph) – Graph object to use

  • metrics (list[str]) – Metrics to optimize for.

  • model_name (str) – Name of the trained model.

  • target_property (str) – The target node property to predict.

  • relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • target_node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.

  • store_model_to_disk (bool) – Whether to persist the trained model to disk.

  • random_seed (Any | None) – Seed for random number generation to ensure reproducible results.

  • 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.

Returns:

The estimated memory footprint for training.

Return type:

EstimationResult

class graphdatascience.procedure_surface.api.pipeline.NodeClassificationPipelineEndpoints
abstractmethod add_logistic_regression(pipeline_name: str, *, batch_size: int | tuple[int, int] = 100, class_weights: list[float] | None = None, focus_weight: float | tuple[float, float] = 0.0, learning_rate: float | tuple[float, float] = 0.001, max_epochs: int | tuple[int, int] = 100, min_epochs: int | tuple[int, int] = 1, patience: int | tuple[int, int] = 1, penalty: float | tuple[float, float] = 0.0, tolerance: float | tuple[float, float] = 0.001) → NodeClassificationPipelineInfoResult

Add a logistic regression model candidate to the pipeline.

Parameters:
  • pipeline_name (str) – Name of the pipeline.

  • batch_size (int | tuple[int, int]) – Batch size to use during training. Pass a two-value tuple to define a parameter range.

  • class_weights (list[float] | None) – Optional class weights to use during training.

  • focus_weight (float | tuple[float, float]) – Focus weight for optimization. Pass a two-value tuple to define a parameter range.

  • learning_rate (float | tuple[float, float]) – Learning rate for optimization. Pass a two-value tuple to define a parameter range.

  • max_epochs (int | tuple[int, int]) – Maximum number of training epochs. Pass a two-value tuple to define a parameter range.

  • min_epochs (int | tuple[int, int]) – Minimum number of training epochs. Pass a two-value tuple to define a parameter range.

  • patience (int | tuple[int, int]) – Early stopping patience. Pass a two-value tuple to define a parameter range.

  • penalty (float | tuple[float, float]) – Penalty term to use during training. Pass a two-value tuple to define a parameter range.

  • tolerance (float | tuple[float, float]) – Convergence tolerance. Pass a two-value tuple to define a parameter range.

Returns:

The updated pipeline state.

Return type:

NodeClassificationPipelineInfoResult

abstractmethod add_mlp(pipeline_name: str, *, batch_size: int | tuple[int, int] = 100, class_weights: list[float] | None = None, focus_weight: float | tuple[float, float] = 0.0, hidden_layer_sizes: list[int] = [100], learning_rate: float | tuple[float, float] = 0.001, max_epochs: int | tuple[int, int] = 100, min_epochs: int | tuple[int, int] = 1, patience: int | tuple[int, int] = 1, penalty: float | tuple[float, float] = 0.0, tolerance: float | tuple[float, float] = 0.001) → NodeClassificationPipelineInfoResult

Add a multi-layer perceptron model candidate to the pipeline.

Parameters:
  • pipeline_name (str) – Name of the pipeline.

  • batch_size (int | tuple[int, int]) – Batch size to use during training. Pass a two-value tuple to define a parameter range.

  • class_weights (list[float] | None) – Optional class weights to use during training.

  • focus_weight (float | tuple[float, float]) – Focus weight for optimization. Pass a two-value tuple to define a parameter range.

  • hidden_layer_sizes (list[int]) – Sizes of the hidden layers in the neural network.

  • learning_rate (float | tuple[float, float]) – Learning rate for optimization. Pass a two-value tuple to define a parameter range.

  • max_epochs (int | tuple[int, int]) – Maximum number of training epochs. Pass a two-value tuple to define a parameter range.

  • min_epochs (int | tuple[int, int]) – Minimum number of training epochs. Pass a two-value tuple to define a parameter range.

  • patience (int | tuple[int, int]) – Early stopping patience. Pass a two-value tuple to define a parameter range.

  • penalty (float | tuple[float, float]) – Penalty term to use during training. Pass a two-value tuple to define a parameter range.

  • tolerance (float | tuple[float, float]) – Convergence tolerance. Pass a two-value tuple to define a parameter range.

Returns:

The updated pipeline state.

Return type:

NodeClassificationPipelineInfoResult

abstractmethod add_node_property(pipeline_name: str, task_name: str, **config: Any) → NodeClassificationPipelineInfoResult

Add a node property step to the pipeline.

Parameters:
  • pipeline_name (str) – Name of the pipeline.

  • task_name (str) – The task name of the node property step to add.

  • config (Any) – Additional configuration for the node property step.

Returns:

The updated pipeline state.

Return type:

NodeClassificationPipelineInfoResult

abstractmethod add_random_forest(pipeline_name: str, *, criterion: str | None = 'GINI', max_depth: int | tuple[int, int] = 2147483647, max_features_ratio: float | tuple[float, float] | None = None, min_leaf_size: int | tuple[int, int] = 1, min_split_size: int | tuple[int, int] = 2, number_of_decision_trees: int | tuple[int, int] = 100, number_of_samples_ratio: float | tuple[float, float] = 1.0) → NodeClassificationPipelineInfoResult

Add a random forest model candidate to the pipeline.

Parameters:
  • pipeline_name (str) – Name of the pipeline.

  • criterion (str | None) – Split criterion to optimize.

  • max_depth (int | tuple[int, int]) – Maximum tree depth. Pass a two-value tuple to define a parameter range.

  • max_features_ratio (float | tuple[float, float] | None) – Fraction of features sampled per split. Pass a two-value tuple to define a parameter range.

  • min_leaf_size (int | tuple[int, int]) – Minimum number of samples in a leaf. Pass a two-value tuple to define a parameter range.

  • min_split_size (int | tuple[int, int]) – Minimum number of samples required to split a node. Pass a two-value tuple to define a parameter range.

  • number_of_decision_trees (int | tuple[int, int]) – Number of trees to train. Pass a two-value tuple to define a parameter range.

  • number_of_samples_ratio (float | tuple[float, float]) – Fraction of samples used per tree. Pass a two-value tuple to define a parameter range.

Returns:

The updated pipeline state.

Return type:

NodeClassificationPipelineInfoResult

abstractmethod configure_auto_tuning(pipeline_name: str, *, max_trials: int = 10) → NodeClassificationPipelineInfoResult

Configure auto-tuning for the pipeline.

Parameters:
  • pipeline_name (str) – Name of the pipeline.

  • max_trials (int) – Maximum number of trials to run during auto-tuning.

Returns:

The updated pipeline state.

Return type:

NodeClassificationPipelineInfoResult

abstractmethod configure_split(pipeline_name: str, *, test_fraction: float = 0.3, validation_folds: int = 3) → NodeClassificationPipelineInfoResult

Configure the train-test split used by the pipeline.

Parameters:
  • pipeline_name (str) – Name of the pipeline.

  • test_fraction (float) – Fraction of nodes reserved for testing.

  • validation_folds (int) – Number of validation folds to use.

Returns:

The updated pipeline state.

Return type:

NodeClassificationPipelineInfoResult

abstractmethod create(pipeline_name: str) → tuple[NodeClassificationPipeline, NodeClassificationPipelineInfoResult]

Create a new node classification pipeline.

Parameters:

pipeline_name (str) – Name of the pipeline.

Returns:

The created pipeline and the corresponding result payload.

Return type:

tuple[NodeClassificationPipeline, NodeClassificationPipelineInfoResult]

abstractmethod get(pipeline_name: str) → NodeClassificationPipeline

Retrieve an existing node classification pipeline by name.

Parameters:

pipeline_name (str) – Name of the pipeline.

Returns:

The reconstructed pipeline object.

Return type:

NodeClassificationPipeline

abstractmethod get_model(model_name: str) → NodeClassificationModel

Retrieve an existing node classification model by name.

Returns the same model object as the train method of a node classification pipeline.

Parameters:

model_name (str) – Name of the model.

Returns:

The reconstructed model object.

Return type:

NodeClassificationModel

abstract property predict: NodeClassificationPipelinePredictEndpoints

Access prediction endpoints for node classification models trained from this surface.

abstractmethod select_features(pipeline_name: str, node_properties: str | list[str]) → NodeClassificationPipelineInfoResult

Select the node properties used as input features.

Parameters:
  • pipeline_name (str) – Name of the pipeline.

  • node_properties (str | list[str]) – One or more node properties to use as features.

Returns:

The updated pipeline state.

Return type:

NodeClassificationPipelineInfoResult

abstract property train: NodeClassificationPipelineTrainEndpoints

Access training endpoints for node classification pipelines.

class graphdatascience.procedure_surface.api.pipeline.NodeClassificationPipelineInfoResult
auto_tuning_config: dict[str, Any]
feature_properties: list[Any]
name: str
node_property_steps: list[Any]
parameter_space: dict[str, Any]
split_config: dict[str, Any]
class graphdatascience.procedure_surface.api.pipeline.NodeClassificationPipelinePredictEndpoints
abstractmethod estimate(G: Graph, model_name: str, *, relationship_types: list[str] | None = None, target_node_labels: list[str] | None = None, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → EstimationResult

Estimate the memory required to run node classification prediction.

Parameters:
  • G (Graph) – Graph object to use

  • model_name (str) – Name of the model.

  • relationship_types (list[str] | None) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • target_node_labels (list[str] | None) – Optional node label filter.

  • 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.

Returns:

The estimated memory footprint for prediction.

Return type:

EstimationResult

abstractmethod mutate(G: Graph, model_name: str, mutate_property: str, *, relationship_types: list[str] | None = None, target_node_labels: list[str] | None = None, predicted_probability_property: str | None = None, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → NodeClassificationPipelinePredictMutateResult

Run node classification prediction in mutate mode.

Parameters:
  • G (Graph) – Graph object to use

  • model_name (str) – Name of the model.

  • mutate_property (str) – Name of the node property to store the results in.

  • relationship_types (list[str] | None) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • target_node_labels (list[str] | None) – Optional node label filter.

  • predicted_probability_property (str | None) – Optional node property to store the predicted probability distribution in.

  • 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.

Returns:

The mutate result summary.

Return type:

NodeClassificationPipelinePredictMutateResult

abstractmethod stream(G: Graph, model_name: str, *, relationship_types: list[str] | None = None, target_node_labels: list[str] | None = None, include_predicted_probabilities: bool = False, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → DataFrame

Run node classification prediction in stream mode.

Parameters:
  • G (Graph) – Graph object to use

  • model_name (str) – Name of the model.

  • relationship_types (list[str] | None) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • target_node_labels (list[str] | None) – Optional node label filter.

  • include_predicted_probabilities (bool) – Whether to include the predicted probability distribution in the streamed results.

  • 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.

Returns:

The prediction results as a DataFrame.

Return type:

pandas.DataFrame

abstractmethod write(G: Graph, model_name: str, write_property: str, *, relationship_types: list[str] | None = None, target_node_labels: list[str] | None = None, predicted_probability_property: str | None = None, 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) → NodeClassificationPipelinePredictWriteResult

Run node classification prediction in write mode.

Parameters:
  • G (Graph) – Graph object to use

  • model_name (str) – Name of the model.

  • write_property (str) – Name of the node property to store the results in.

  • relationship_types (list[str] | None) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • target_node_labels (list[str] | None) – Optional node label filter.

  • predicted_probability_property (str | None) – Optional node property to store the predicted probability distribution in.

  • 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.

Returns:

The write result summary.

Return type:

NodeClassificationPipelinePredictWriteResult

class graphdatascience.procedure_surface.api.pipeline.NodeClassificationPipelinePredictMutateResult
compute_millis: int | None
configuration: dict[str, Any] | None
mutate_millis: int | None
node_properties_written: int | None
post_processing_millis: int | None
pre_processing_millis: int | None
class graphdatascience.procedure_surface.api.pipeline.NodeClassificationPipelinePredictWriteResult
compute_millis: int | None
configuration: dict[str, Any] | None
node_properties_written: int | None
post_processing_millis: int | None
pre_processing_millis: int | None
write_millis: int | None
class graphdatascience.procedure_surface.api.pipeline.NodeClassificationPipelineTrainResult
configuration: dict[str, Any]
model_info: NodeClassificationModelInfoResult
model_selection_stats: dict[str, Any]
train_millis: int
class graphdatascience.procedure_surface.api.pipeline.NodeRegressionMetric
MEAN_ABSOLUTE_ERROR = 'MEAN_ABSOLUTE_ERROR'
MEAN_SQUARED_ERROR = 'MEAN_SQUARED_ERROR'
ROOT_MEAN_SQUARED_ERROR = 'ROOT_MEAN_SQUARED_ERROR'
__new__(value)
class graphdatascience.procedure_surface.api.pipeline.NodeRegressionPipeline

Represents a node regression training pipeline.

Construct this using: func:gds.v2.pipeline.node_regression.create().

add_linear_regression(*, batch_size: int | tuple[int, int] = 100, learning_rate: float | tuple[float, float] = 0.001, max_epochs: int | tuple[int, int] = 100, min_epochs: int | tuple[int, int] = 1, patience: int | tuple[int, int] = 1, penalty: float | tuple[float, float] = 0.0, tolerance: float | tuple[float, float] = 0.001) → NodeRegressionPipelineInfoResult

Add a linear regression model candidate to the pipeline.

Parameters:
  • batch_size (int | tuple[int, int]) – Batch size to use during training. Pass a two-value tuple to define a parameter range.

  • learning_rate (float | tuple[float, float]) – Learning rate for optimization. Pass a two-value tuple to define a parameter range.

  • max_epochs (int | tuple[int, int]) – Maximum number of training epochs. Pass a two-value tuple to define a parameter range.

  • min_epochs (int | tuple[int, int]) – Minimum number of training epochs. Pass a two-value tuple to define a parameter range.

  • patience (int | tuple[int, int]) – Early stopping patience. Pass a two-value tuple to define a parameter range.

  • penalty (float | tuple[float, float]) – Penalty term to use during training. Pass a two-value tuple to define a parameter range.

  • tolerance (float | tuple[float, float]) – Convergence tolerance. Pass a two-value tuple to define a parameter range.

Returns:

The updated pipeline state.

Return type:

NodeRegressionPipelineInfoResult

add_node_property(task_name: str, **config: Any) → NodeRegressionPipelineInfoResult

Add a node property step to the pipeline.

Parameters:
  • task_name (str) – The name of the node property step to add.

  • config (Any)

Returns:

The updated pipeline state.

Return type:

NodeRegressionPipelineInfoResult

add_random_forest(*, max_depth: int | tuple[int, int] = 2147483647, max_features_ratio: float | tuple[float, float] | None = None, min_leaf_size: int | tuple[int, int] = 1, min_split_size: int | tuple[int, int] = 2, number_of_decision_trees: int | tuple[int, int] = 100, number_of_samples_ratio: float | tuple[float, float] = 1.0) → NodeRegressionPipelineInfoResult

Add a random forest model candidate to the pipeline.

Parameters:
  • max_depth (int | tuple[int, int]) – Maximum tree depth. Pass a two-value tuple to define a parameter range.

  • max_features_ratio (float | tuple[float, float] | None) – Fraction of features sampled per split. Pass a two-value tuple to define a parameter range.

  • min_leaf_size (int | tuple[int, int]) – Minimum number of samples in a leaf. Pass a two-value tuple to define a parameter range.

  • min_split_size (int | tuple[int, int]) – Minimum number of samples required to split a node. Pass a two-value tuple to define a parameter range.

  • number_of_decision_trees (int | tuple[int, int]) – Number of trees to train. Pass a two-value tuple to define a parameter range.

  • number_of_samples_ratio (float | tuple[float, float]) – Fraction of samples used per tree. Pass a two-value tuple to define a parameter range.

Returns:

The updated pipeline state.

Return type:

NodeRegressionPipelineInfoResult

configure_auto_tuning(*, max_trials: int = 10) → NodeRegressionPipelineInfoResult

Configure auto-tuning for the pipeline.

Parameters:

max_trials (int) – Maximum number of trials to run during auto-tuning.

Returns:

The updated pipeline state.

Return type:

NodeRegressionPipelineInfoResult

configure_split(*, test_fraction: float = 0.3, validation_folds: int = 3) → NodeRegressionPipelineInfoResult

Configure the train-test split used by the pipeline.

Parameters:
  • test_fraction (float) – Fraction of nodes reserved for testing.

  • validation_folds (int) – Number of validation folds to use.

Returns:

The updated pipeline state.

Return type:

NodeRegressionPipelineInfoResult

details() → NodeRegressionPipelineInfoResult

Return the stored configuration of the pipeline (feature steps, split, parameter space).

Return type:

NodeRegressionPipelineInfoResult

drop(fail_if_missing: bool = False) → PipelineCatalogEntryProtocol | None

Drop the pipeline and return its catalog entry when available.

Parameters:

fail_if_missing (bool)

Return type:

PipelineCatalogEntryProtocol | None

exists() → bool

Return whether the pipeline exists.

Return type:

bool

name() → str

Return the pipeline name.

Return type:

str

select_features(feature_properties: str | list[str]) → NodeRegressionPipelineInfoResult

Select the node properties used as input features.

Parameters:

feature_properties (str | list[str]) – One or more node properties to use as features.

Returns:

The updated pipeline state.

Return type:

NodeRegressionPipelineInfoResult

train(G: Graph, *, metrics: list[str | NodeRegressionMetric], model_name: str, target_property: str, relationship_types: list[str] = ['*'], target_node_labels: list[str] = ['*'], store_model_to_disk: bool = False, random_seed: Any | None = None, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → tuple[NodeRegressionModel, NodeRegressionPipelineTrainResult]

Train a node regression model from this pipeline.

Parameters:
  • G (Graph) – Graph object to use

  • metrics (list[str | NodeRegressionMetric]) – Metrics to optimize for.

  • model_name (str) – Name of the trained model.

  • target_property (str) – The target node property to predict.

  • relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • target_node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.

  • store_model_to_disk (bool) – Whether to persist the trained model to disk.

  • random_seed (Any | None) – Seed for random number generation to ensure reproducible results.

  • 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.

Returns:

The trained model and the corresponding training result.

Return type:

tuple[NodeRegressionModel, NodeRegressionPipelineTrainResult]

class graphdatascience.procedure_surface.api.pipeline.NodeRegressionPipelineEndpoints
abstractmethod add_linear_regression(pipeline_name: str, *, batch_size: int | tuple[int, int] = 100, learning_rate: float | tuple[float, float] = 0.001, max_epochs: int | tuple[int, int] = 100, min_epochs: int | tuple[int, int] = 1, patience: int | tuple[int, int] = 1, penalty: float | tuple[float, float] = 0.0, tolerance: float | tuple[float, float] = 0.001) → NodeRegressionPipelineInfoResult

Add a linear regression model candidate to the pipeline.

Parameters:
  • pipeline_name (str) – Name of the pipeline.

  • batch_size (int | tuple[int, int]) – Batch size to use during training. Pass a two-value tuple to define a parameter range.

  • learning_rate (float | tuple[float, float]) – Learning rate for optimization. Pass a two-value tuple to define a parameter range.

  • max_epochs (int | tuple[int, int]) – Maximum number of training epochs. Pass a two-value tuple to define a parameter range.

  • min_epochs (int | tuple[int, int]) – Minimum number of training epochs. Pass a two-value tuple to define a parameter range.

  • patience (int | tuple[int, int]) – Early stopping patience. Pass a two-value tuple to define a parameter range.

  • penalty (float | tuple[float, float]) – Penalty term to use during training. Pass a two-value tuple to define a parameter range.

  • tolerance (float | tuple[float, float]) – Convergence tolerance. Pass a two-value tuple to define a parameter range.

Returns:

The updated pipeline state.

Return type:

NodeRegressionPipelineInfoResult

abstractmethod add_node_property(pipeline_name: str, task_name: str, **config: Any) → NodeRegressionPipelineInfoResult

Add a node property step to the pipeline.

Parameters:
  • pipeline_name (str) – Name of the pipeline.

  • task_name (str) – The name of the node property step to add.

  • config (Any) – Additional configuration for the node property step.

Returns:

The updated pipeline state.

Return type:

NodeRegressionPipelineInfoResult

abstractmethod add_random_forest(pipeline_name: str, *, max_depth: int | tuple[int, int] = 2147483647, max_features_ratio: float | tuple[float, float] | None = None, min_leaf_size: int | tuple[int, int] = 1, min_split_size: int | tuple[int, int] = 2, number_of_decision_trees: int | tuple[int, int] = 100, number_of_samples_ratio: float | tuple[float, float] = 1.0) → NodeRegressionPipelineInfoResult

Add a random forest model candidate to the pipeline.

Parameters:
  • pipeline_name (str) – Name of the pipeline.

  • max_depth (int | tuple[int, int]) – Maximum tree depth. Pass a two-value tuple to define a parameter range.

  • max_features_ratio (float | tuple[float, float] | None) – Fraction of features sampled per split. Pass a two-value tuple to define a parameter range.

  • min_leaf_size (int | tuple[int, int]) – Minimum number of samples in a leaf. Pass a two-value tuple to define a parameter range.

  • min_split_size (int | tuple[int, int]) – Minimum number of samples required to split a node. Pass a two-value tuple to define a parameter range.

  • number_of_decision_trees (int | tuple[int, int]) – Number of trees to train. Pass a two-value tuple to define a parameter range.

  • number_of_samples_ratio (float | tuple[float, float]) – Fraction of samples used per tree. Pass a two-value tuple to define a parameter range.

Returns:

The updated pipeline state.

Return type:

NodeRegressionPipelineInfoResult

abstractmethod configure_auto_tuning(pipeline_name: str, *, max_trials: int = 10) → NodeRegressionPipelineInfoResult

Configure auto-tuning for the pipeline.

Parameters:
  • pipeline_name (str) – Name of the pipeline.

  • max_trials (int) – Maximum number of trials to run during auto-tuning.

Returns:

The updated pipeline state.

Return type:

NodeRegressionPipelineInfoResult

abstractmethod configure_split(pipeline_name: str, *, test_fraction: float = 0.3, validation_folds: int = 3) → NodeRegressionPipelineInfoResult

Configure the train-test split used by the pipeline.

Parameters:
  • pipeline_name (str) – Name of the pipeline.

  • test_fraction (float) – Fraction of nodes reserved for testing.

  • validation_folds (int) – Number of validation folds to use.

Returns:

The updated pipeline state.

Return type:

NodeRegressionPipelineInfoResult

abstractmethod create(pipeline_name: str) → tuple[NodeRegressionPipeline, NodeRegressionPipelineInfoResult]

Create a new node regression pipeline.

Parameters:

pipeline_name (str) – Name of the pipeline.

Returns:

The created pipeline and the corresponding result payload.

Return type:

tuple[NodeRegressionPipeline, NodeRegressionPipelineInfoResult]

abstractmethod get(pipeline_name: str) → NodeRegressionPipeline

Retrieve an existing node regression pipeline by name.

Parameters:

pipeline_name (str) – Name of the pipeline.

Returns:

The reconstructed pipeline object.

Return type:

NodeRegressionPipeline

abstractmethod get_model(model_name: str) → NodeRegressionModel

Retrieve an existing node regression model by name.

Returns the same model object as the train method of a node regression pipeline.

Parameters:

model_name (str) – Name of the model.

Returns:

The reconstructed model object.

Return type:

NodeRegressionModel

abstract property predict: NodeRegressionPipelinePredictEndpoints

Access prediction endpoints for node regression models trained from this surface.

abstractmethod select_features(pipeline_name: str, feature_properties: str | list[str]) → NodeRegressionPipelineInfoResult

Select the node properties used as input features.

Parameters:
  • pipeline_name (str) – Name of the pipeline.

  • feature_properties (str | list[str]) – One or more node properties to use as features.

Returns:

The updated pipeline state.

Return type:

NodeRegressionPipelineInfoResult

abstractmethod train(G: Graph, pipeline_name: str, *, metrics: list[str | NodeRegressionMetric], model_name: str, target_property: str, relationship_types: list[str] = ['*'], target_node_labels: list[str] = ['*'], store_model_to_disk: bool = False, random_seed: Any | None = None, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → tuple[NodeRegressionModel, NodeRegressionPipelineTrainResult]

Train a node regression model from the given pipeline.

Parameters:
  • G (Graph) – Graph object to use

  • pipeline_name (str) – Name of the pipeline.

  • metrics (list[str | NodeRegressionMetric]) – Metrics to optimize for.

  • model_name (str) – Name of the trained model.

  • target_property (str) – The target node property to predict.

  • relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • target_node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.

  • store_model_to_disk (bool) – Whether to persist the trained model to disk.

  • random_seed (Any | None) – Seed for random number generation to ensure reproducible results.

  • 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.

Returns:

The trained model and the corresponding training result.

Return type:

tuple[NodeRegressionModel, NodeRegressionPipelineTrainResult]

class graphdatascience.procedure_surface.api.pipeline.NodeRegressionPipelineInfoResult
auto_tuning_config: dict[str, Any]
feature_properties: list[Any]
name: str
node_property_steps: list[Any]
parameter_space: dict[str, Any]
split_config: dict[str, Any]
class graphdatascience.procedure_surface.api.pipeline.NodeRegressionPipelinePredictEndpoints
abstractmethod mutate(G: Graph, model_name: str, mutate_property: str, *, relationship_types: list[str] | None = None, target_node_labels: list[str] | None = None, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → NodeRegressionPipelinePredictMutateResult

Run node regression prediction in mutate mode.

Parameters:
  • G (Graph) – Graph object to use

  • model_name (str) – Name of the model.

  • mutate_property (str) – Name of the node property to store the results in.

  • relationship_types (list[str] | None) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • target_node_labels (list[str] | None) – Optional node label filter.

  • 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.

Returns:

The mutate result summary.

Return type:

NodeRegressionPipelinePredictMutateResult

abstractmethod stream(G: Graph, model_name: str, *, relationship_types: list[str] | None = None, target_node_labels: list[str] | None = None, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → DataFrame

Run node regression prediction in stream mode.

Parameters:
  • G (Graph) – Graph object to use

  • model_name (str) – Name of the model.

  • relationship_types (list[str] | None) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • target_node_labels (list[str] | None) – Optional node label filter.

  • 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.

Returns:

The prediction results as a DataFrame.

Return type:

pandas.DataFrame

class graphdatascience.procedure_surface.api.pipeline.NodeRegressionPipelinePredictMutateResult
compute_millis: int | None
configuration: dict[str, Any] | None
mutate_millis: int | None
node_properties_written: int | None
post_processing_millis: int | None
pre_processing_millis: int | None
class graphdatascience.procedure_surface.api.pipeline.NodeRegressionPipelineTrainResult
configuration: dict[str, Any]
model_info: NodeRegressionModelInfoResult
model_selection_stats: dict[str, Any]
train_millis: int
class graphdatascience.procedure_surface.api.pipeline.PipelineCatalogEntry
creation_time: datetime | None
pipeline_info: dict[str, Any] | None
pipeline_name: str
pipeline_type: str
class graphdatascience.procedure_surface.api.pipeline.PipelineEndpoints
abstractmethod drop(pipeline_name: str, *, fail_if_missing: bool = False) → PipelineCatalogEntry | None

Drop a pipeline from the catalog, optionally failing when missing.

Parameters:
  • pipeline_name (str)

  • fail_if_missing (bool)

Return type:

PipelineCatalogEntry | None

abstractmethod exists(pipeline_name: str) → PipelineExistsResult | None

Return pipeline existence details when present, otherwise None.

Parameters:

pipeline_name (str)

Return type:

PipelineExistsResult | None

abstractmethod get(pipeline_name: str) → PipelineCatalogEntry

Return the catalog entry for the given pipeline, raising if it does not exist.

Parameters:

pipeline_name (str)

Return type:

PipelineCatalogEntry

Access link prediction pipeline procedures.

abstractmethod list(pipeline_name: str | None = None) → list[PipelineCatalogEntry]

List pipeline catalog entries, optionally filtered by pipeline name.

Parameters:

pipeline_name (str | None)

Return type:

list[PipelineCatalogEntry]

abstract property node_classification: NodeClassificationPipelineEndpoints

Access node classification pipeline procedures.

abstract property node_regression: NodeRegressionPipelineEndpoints

Access node regression pipeline procedures.

class graphdatascience.procedure_surface.api.pipeline.PipelineExistsResult
exists: bool
pipeline_name: str
pipeline_type: str
class graphdatascience.procedure_surface.api.pipeline.node_classification_model.NodeClassificationModel

Represents a node classification model in the model catalog.

Construct this using: func:gds.pipeline.node_classification.train().

predict_estimate(G: Graph, *, relationship_types: list[str] | None = None, target_node_labels: list[str] | None = None, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → EstimationResult

Estimate the memory required to run prediction.

Parameters:
  • G (Graph) – Graph object to use

  • relationship_types (list[str] | None) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • target_node_labels (list[str] | None) – Optional node label filter.

  • 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.

Returns:

The estimated memory footprint for prediction.

Return type:

EstimationResult

predict_mutate(G: Graph, mutate_property: str, *, relationship_types: list[str] | None = None, target_node_labels: list[str] | None = None, predicted_probability_property: str | None = None, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → NodeClassificationPipelinePredictMutateResult

Run prediction and write the results back to the in-memory graph.

Parameters:
  • G (Graph) – Graph object to use

  • mutate_property (str) – Name of the node property to store the results in.

  • relationship_types (list[str] | None) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • target_node_labels (list[str] | None) – Optional node label filter.

  • predicted_probability_property (str | None) – Optional node property to store the predicted probability distribution in.

  • 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.

Returns:

The mutate result summary.

Return type:

NodeClassificationPipelinePredictMutateResult

predict_stream(G: Graph, *, relationship_types: list[str] | None = None, target_node_labels: list[str] | None = None, include_predicted_probabilities: bool = False, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → DataFrame

Run prediction and stream the results.

Parameters:
  • G (Graph) – Graph object to use

  • relationship_types (list[str] | None) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • target_node_labels (list[str] | None) – Optional node label filter.

  • include_predicted_probabilities (bool) – Whether to include the predicted probability distribution in the streamed results.

  • 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.

Returns:

The prediction results as a DataFrame.

Return type:

pandas.DataFrame

predict_write(G: Graph, write_property: str, *, relationship_types: list[str] | None = None, target_node_labels: list[str] | None = None, predicted_probability_property: str | None = None, 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) → NodeClassificationPipelinePredictWriteResult

Run prediction and write the results back to Neo4j.

Parameters:
  • G (Graph) – Graph object to use

  • write_property (str) – Name of the node property to store the results in.

  • relationship_types (list[str] | None) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • target_node_labels (list[str] | None) – Optional node label filter.

  • predicted_probability_property (str | None) – Optional node property to store the predicted probability distribution in.

  • 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.

Returns:

The write result summary.

Return type:

NodeClassificationPipelinePredictWriteResult

Represents a link prediction model in the model catalog.

Construct this using: func:gds.pipeline.link_prediction.train().

class graphdatascience.procedure_surface.api.pipeline.node_regression_model.NodeRegressionModel

Represents a node regression model in the model catalog.

Construct this using: func:gds.pipeline.node_regression.train().

predict_mutate(G: Graph, mutate_property: str, *, relationship_types: list[str] | None = None, target_node_labels: list[str] | None = None, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → NodeRegressionPipelinePredictMutateResult

Run prediction and write the results back to the in-memory graph.

Parameters:
  • G (Graph) – Graph object to use

  • mutate_property (str) – Name of the node property to store the results in.

  • relationship_types (list[str] | None) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • target_node_labels (list[str] | None) – Optional node label filter.

  • 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.

Returns:

The mutate result summary.

Return type:

NodeRegressionPipelinePredictMutateResult

predict_stream(G: Graph, *, relationship_types: list[str] | None = None, target_node_labels: list[str] | None = None, username: str | None = None, log_progress: bool = True, sudo: bool = False, concurrency: int | None = None, job_id: str | None = None) → DataFrame

Run prediction and stream the results.

Parameters:
  • G (Graph) – Graph object to use

  • relationship_types (list[str] | None) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • target_node_labels (list[str] | None) – Optional node label filter.

  • 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.

Returns:

The prediction results as a DataFrame.

Return type:

pandas.DataFrame

class graphdatascience.procedure_surface.api.pipeline.node_regression_pipeline_results.NodeRegressionModelInfoResult
classmethod __new__(*args, **kwargs)
class graphdatascience.procedure_surface.api.pipeline.node_classification_pipeline_results.NodeClassificationModelInfoResult
classmethod __new__(*args, **kwargs)
class graphdatascience.procedure_surface.api.pipeline.node_classification_train_endpoints.NodeClassificationPipelineTrainEndpoints
__init__()
classmethod __new__(*args, **kwargs)
class graphdatascience.procedure_surface.api.pipeline.pipeline_catalog_protocol.PipelineCatalogEntryProtocol

Represents a pipeline in the catalog.

__init__(*args, **kwargs)