Precision@K is computed as.
Inherits From: RetrievalMetric
, ABC
TFSimilarity.retrieval_metrics.PrecisionAtK(
name: str = precision, k: int = 5, **kwargs
) -> None
Where: K is the number of neighbors in the i_th query result set. rel is the relevance mask (indicator function) for the i_th query. i represents the i_th query. j represents the j_th ranked query result.
P@K is unordered and does not take into account the rank of the TP results.
This metric is useful when we are interested in evaluating the embedding within the context of a kNN classifier or as part of a clustering method.
name | Name associated with the metric object, e.g., precision@5 |
canonical_name | The canonical name associated with metric, e.g., precision@K |
k | The number of nearest neighbors over which the metric is computed. |
distance_threshold | The max distance below which a nearest neighbor is considered a valid match. |
average |
'micro', 'macro' Determines the type of averaging performed
on the data.
|
name |
compute(
*,
query_labels: <a href="../../TFSimilarity/callbacks/IntTensor.md">TFSimilarity.callbacks.IntTensor```
</a>,
match_mask: <a href="../../TFSimilarity/utils/BoolTensor.md">TFSimilarity.utils.BoolTensor```
</a>,
**kwargs
) -> <a href="../../TFSimilarity/callbacks/FloatTensor.md">TFSimilarity.callbacks.FloatTensor```
</a>
Compute the metric
Args | |
---|---|
query_labels | A 1D array of the labels associated with the embedding queries. |
match_mask | A 2D mask where a 1 indicates a match between the jth query and the kth neighbor and a 0 indicates a mismatch. |
**kwargs | Additional compute args. |
Returns | |
---|---|
A rank 0 tensor containing the metric. |
get_config()