public override IEnumerable <TestResult> ComputeTests(double[] scores) { double fastNdcg = 0; switch (NdcgTruncation) { case 1: fastNdcg = DcgCalculator.Ndcg1(Dataset, Labels, scores); break; case 3: fastNdcg = DcgCalculator.Ndcg3(Dataset, Labels, scores); break; default: Contracts.Assert(false); throw Contracts.Except(); } List <TestResult> result = new List <TestResult>() { new TestResult("NDCG@" + NdcgTruncation.ToString(), fastNdcg * Dataset.NumQueries, Dataset.NumQueries, false, TestResult.ValueOperator.Average), }; return(result); }
public override IEnumerable <TestResult> ComputeTests(double[] scores) { short[][] trainQueriesTopLabels = _rankingObjectiveFunction.TrainQueriesTopLabels; double fastNdcg = 0; switch (NdcgTruncation) { case 1: fastNdcg = DcgCalculator.Ndcg1(Dataset, trainQueriesTopLabels); break; case 3: fastNdcg = DcgCalculator.Ndcg3(Dataset, trainQueriesTopLabels); break; default: throw Contracts.Except("FastNDCGTest only supports NDCG1 & NDCG3"); } List <TestResult> result = new List <TestResult>() { new TestResult("NDCG@" + NdcgTruncation.ToString(), fastNdcg * Dataset.NumQueries, Dataset.NumQueries, false, TestResult.ValueOperator.Average), }; return(result); }
internal NdcgTest(ScoreTracker scoreTracker, short[] labels, string sortingAlgorithm) : base(scoreTracker) { Labels = labels; Contracts.Check(scoreTracker.Dataset.NumDocs == labels.Length, "Mismatch between dataset and labels"); _sortingAlgorithm = sortingAlgorithm; DcgCalculator = new DcgCalculator(Dataset.MaxDocsPerQuery, _sortingAlgorithm); }