Documentation
¶
Overview ¶
Package ranking evaluates ranked outputs against graded relevance judgments.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidSample = errors.New("eval/ranking: invalid sample")
ErrInvalidSample identifies a ranking or judgment set that cannot define one deterministic relevance calculation.
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config configures one deterministic ranking evaluator. Cutoff is required and positive. A nil Threshold produces a score without a pass/fail verdict.
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
Evaluator measures one standard ranking metric at a fixed cutoff.
func NewEvaluator ¶
NewEvaluator freezes the metric, cutoff, and optional decision threshold.
type Judgment ¶
Judgment assigns a non-negative relevance grade to one ranked identity. A positive grade is relevant for binary metrics; NDCG uses the full grade.
type Metric ¶
type Metric string
Metric selects a ranking-quality calculation evaluated at a configured cutoff.
const ( // MetricPrecision measures relevant results among the admitted ranking. MetricPrecision Metric = "precision" // MetricRecall measures admitted relevant results among all relevant items. MetricRecall Metric = "recall" // MetricReciprocalRank rewards the rank of the first relevant result. MetricReciprocalRank Metric = "reciprocal_rank" // MetricAveragePrecision averages precision at every relevant result. MetricAveragePrecision Metric = "average_precision" // MetricNDCG preserves graded relevance while discounting later ranks. MetricNDCG Metric = "ndcg" )
type Sample ¶
type Sample struct {
Ranking []string `json:"ranking,omitzero"`
Judgments []Judgment `json:"judgments"`
}
Sample contains one observed ranking and its relevance judgments. Ranking identities without a judgment are treated as having zero relevance.