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

Return type:

str

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

Return type:

str

predict_mutate(source_node_filter: NodeFilter, target_node_filter: NodeFilter, 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 (NodeFilter) – The specification of source nodes to consider

  • target_node_filter (NodeFilter) – The specification of target nodes to consider

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

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

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

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

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

Returns:

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

Return type:

Series[Any]

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 (int | list[int] | str) – The specification of source nodes to consider

  • target_node_filter (int | list[int] | str) – The specification of target nodes to consider

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

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

  • general_config (Any) – 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

Return type:

DataFrame

predict_write(source_node_filter: NodeFilter, target_node_filter: NodeFilter, 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 (NodeFilter) – The specification of source nodes to consider

  • target_node_filter (NodeFilter) – The specification of target nodes to consider

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

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

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

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

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

Returns:

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

Return type:

Series[Any]

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

Get the relationship type embeddings of the model

Returns:

The relationship type embeddings of the model

Return type:

dict[str, list[float]]

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

Return type:

str