View Source Scholar.Metrics.Neighbors (Scholar v0.3.1)

Metrics for evaluating the results of approximate k-nearest neighbor search algorithms.

Summary

Functions

Computes the recall of predicted k-nearest neighbors given the true k-nearest neighbors. Recall is defined as the average fraction of nearest neighbors the algorithm predicted correctly.

Functions

Link to this function

recall(neighbors_true, neighbors_pred)

View Source

Computes the recall of predicted k-nearest neighbors given the true k-nearest neighbors. Recall is defined as the average fraction of nearest neighbors the algorithm predicted correctly.

Examples

iex> neighbors_true = Nx.tensor([[0, 1], [1, 2], [2, 1]])
iex> Scholar.Metrics.Neighbors.recall(neighbors_true, neighbors_true)
#Nx.Tensor<
  f32
  1.0
>

iex> neighbors_true = Nx.tensor([[0, 1], [1, 2], [2, 1]])
iex> neighbors_pred = Nx.tensor([[0, 1], [1, 0], [2, 0]])
iex> Scholar.Metrics.Neighbors.recall(neighbors_true, neighbors_pred)
#Nx.Tensor<
  f32
  0.6666666865348816
>