ScipySparseAnchorSearcher
- class ScipySparseAnchorSearcher(max_iter=5)[source]
Bases:
pykeen.nn.node_piece.anchor_search.AnchorSearcher
Find closest anchors using
scipy.sparse
.Initialize the searcher.
- Parameters
max_iter (
int
) – the maximum number of hops to consider
Methods Summary
__call__
(edge_index, anchors, k)Find the \(k\) closest anchor nodes for each entity.
bfs
(anchors, adjacency, max_iter, k)Determine the candidate pool using breadth-first search.
create_adjacency
(edge_index)Create a sparse adjacency matrix from a given edge index.
Extra components for __repr__.
select
(pool, k)Select \(k\) anchors from the given pools.
Methods Documentation
- static bfs(anchors, adjacency, max_iter, k)[source]
Determine the candidate pool using breadth-first search.
- Parameters
- Return type
- Returns
shape: (n, a) a boolean array indicating whether anchor \(j\) is in the set of \(k\) closest anchors for node \(i\)
- static create_adjacency(edge_index)[source]
Create a sparse adjacency matrix from a given edge index.
- Parameters
edge_index (
ndarray
) – shape: (2, m) the edge index- Return type
spmatrix
- Returns
shape: (n, n) a square sparse adjacency matrix