SimpleRelEmbeddingModel

class graphdatascience.model.simple_rel_embedding_model.SimpleRelEmbeddingModel

A class whose instances represent a model for computing and ranking pairwise distance between nodes according to knowledge graph style metrics. It may also produce new relationships based on these rankings.

graph_name() str

Get the name of the graph the model is based on

Returns:

The name of the graph the model is based on

node_embedding_property() str

Get the name of the node property storing embeddings in the graph

Returns:

The name of the node property storing embeddings in the graph

predict_mutate(source_node_filter: int | list[int] | str, target_node_filter: int | list[int] | str, relationship_type: str, top_k: int, mutate_relationship_type: str, mutate_property: str, **general_config: Any) Series[Any]

Compute relationship embeddings and add them to graph projection under a new relationship type

Parameters:
  • source_node_filter – The specification of source nodes to consider

  • target_node_filter – The specification of target nodes to consider

  • relationship_type – The name of the relationship type whose embedding will be used in the computation

  • top_k – How many relationships to add for each source node

  • mutate_relationship_type – The name of the new relationship type for the predicted relationships

  • mutate_property – The name of the property on the new relationships which will store the model prediction score

  • general_config – General algorithm keyword parameters such as ‘concurrency’

Returns:

A pandas.Series object with metadata about the performed computation and mutation

predict_stream(source_node_filter: int | list[int] | str, target_node_filter: int | list[int] | str, relationship_type: str, top_k: int, **general_config: Any) DataFrame

Compute and stream relationship embeddings

Parameters:
  • source_node_filter – The specification of source nodes to consider

  • target_node_filter – The specification of target nodes to consider

  • relationship_type – The name of the relationship type whose embedding will be used in the computation

  • top_k – How many target nodes to return for each source node

  • general_config – General algorithm keyword parameters such as ‘concurrency’

Returns:

The top_k highest scoring target nodes for each source node, along with the score for the node pair

predict_write(source_node_filter: int | list[int] | str, target_node_filter: int | list[int] | str, relationship_type: str, top_k: int, write_relationship_type: str, write_property: str, **general_config: Any) Series[Any]

Compute relationship embeddings and write them back to the database under a new relationship type

Parameters:
  • source_node_filter – The specification of source nodes to consider

  • target_node_filter – The specification of target nodes to consider

  • relationship_type – The name of the relationship type whose embedding will be used in the computation

  • top_k – How many relationships to add for each source node

  • write_relationship_type – The name of the new relationship type for the predicted relationships

  • write_property – The name of the property on the new relationships which will store the model prediction score

  • general_config – General algorithm keyword parameters such as ‘concurrency’

Returns:

A pandas.Series object with metadata about the performed computation and write-back

relationship_type_embeddings() dict[str, list[float]]

Get the relationship type embeddings of the model

Returns:

The relationship type embeddings of the model

scoring_function() str

Get the name of the scoring function the model is using

Returns:

The name of the scoring function the model is using