PersonalizedPageRankAnchorSearcher

class PersonalizedPageRankAnchorSearcher(batch_size=1, use_tqdm=False, page_rank_kwargs=None)[source]

Bases: AnchorSearcher

Select closest anchors as the nodes with the largest personalized page rank.

Initialize the searcher.

Parameters:
  • batch_size (int) – the batch size to use.

  • use_tqdm (bool) – whether to use tqdm

  • page_rank_kwargs (Optional[Mapping[str, Any]]) – keyword-based parameters used for page_rank(). Must not include edge_index, or x0.

Methods Summary

__call__(edge_index, anchors, k[, num_entities])

Find the \(k\) closest anchor nodes for each entity.

iter_extra_repr()

Iterate over the components of the extra_repr().

precalculate_anchor_ppr(edge_index, anchors)

Sort anchors nodes by PPR values from each node.

Methods Documentation

__call__(edge_index, anchors, k, num_entities=None)[source]

Find the \(k\) closest anchor nodes for each entity.

Parameters:
  • edge_index (ndarray) – shape: (2, m) the edge index

  • anchors (ndarray) – shape: (a,) the selected anchor entity Ids

  • k (int) – the number of closest anchors to return

  • num_entities (Optional[int]) – the number of entities

Return type:

ndarray

Returns:

shape: (n, k), -1 <= res < a the Ids of the closest anchors

iter_extra_repr()[source]

Iterate over the components of the extra_repr().

This method is typically overridden. A common pattern would be

def iter_extra_repr(self) -> Iterable[str]:
    yield from super().iter_extra_repr()
    yield "<key1>=<value1>"
    yield "<key2>=<value2>"
Return type:

Iterable[str]

Returns:

an iterable over individual components of the extra_repr()

precalculate_anchor_ppr(edge_index, anchors)[source]

Sort anchors nodes by PPR values from each node.

Parameters:
  • edge_index (ndarray) – shape: (2, m) the edge index.

  • anchors (ndarray) – shape: (num_anchors,) the anchor IDs.

Return type:

ndarray

Returns:

shape: (num_entities, num_anchors) the PPR values for each anchor