QuickRank  v2.0
QuickRank: A C++ suite of Learning to Rank algorithms
map.h
Go to the documentation of this file.
1 /*
2  * QuickRank - A C++ suite of Learning to Rank algorithms
3  * Webpage: http://quickrank.isti.cnr.it/
4  * Contact: quickrank@isti.cnr.it
5  *
6  * Unless explicitly acquired and licensed from Licensor under another
7  * license, the contents of this file are subject to the Reciprocal Public
8  * License ("RPL") Version 1.5, or subsequent versions as allowed by the RPL,
9  * and You may not copy or use this file in either source code or executable
10  * form, except in compliance with the terms and conditions of the RPL.
11  *
12  * All software distributed under the RPL is provided strictly on an "AS
13  * IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, AND
14  * LICENSOR HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
15  * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16  * PURPOSE, QUIET ENJOYMENT, OR NON-INFRINGEMENT. See the RPL for specific
17  * language governing rights and limitations under the RPL.
18  *
19  * Contributor:
20  * HPC. Laboratory - ISTI - CNR - http://hpc.isti.cnr.it/
21  */
22 #pragma once
23 
24 #include "types.h"
25 #include "metric.h"
26 
27 namespace quickrank {
28 namespace metric {
29 namespace ir {
30 
31 /**
32  * This class implements the average precision AP\@k measure.
33  *
34  * \todo TODO: test correctness
35  */
36 class Map: public Metric {
37  public:
38  explicit Map(size_t k = NO_CUTOFF)
39  : Metric(k) {
40  }
41  virtual ~Map() {
42  }
43 
44  /// Returns the name of the metric.
45  virtual std::string name() const {
46  return NAME_;
47  }
48 
49  static const std::string NAME_;
50 
52  const quickrank::data::QueryResults *rl, const Score *scores) const;
53 
54  virtual std::unique_ptr<Jacobian> jacobian(
55  std::shared_ptr<data::RankedResults> ranked) const;
56 
57  protected:
58 
59  private:
60  friend std::ostream &operator<<(std::ostream &os, const Map &map) {
61  return map.put(os);
62  }
63 
64  virtual std::ostream &put(std::ostream &os) const;
65 
66 };
67 
68 } // namespace ir
69 } // namespace metric
70 } // namespace quickrank
Definition: dataset.cc:28
virtual ~Map()
Definition: map.h:41
virtual std::string name() const
Returns the name of the metric.
Definition: map.h:45
This class implements the basic functionalities of an IR evaluation metric.
Definition: metric.h:43
virtual MetricScore evaluate_result_list(const quickrank::data::QueryResults *rl, const Score *scores) const
Measures the quality of the given results list according to the Metric.
Definition: map.cc:33
This class implements the average precision AP@k measure.
Definition: map.h:36
double Score
data type for instance truth label
Definition: types.h:30
static const size_t NO_CUTOFF
This should be used when no cut-off on the results list is required.
Definition: metric.h:46
virtual std::ostream & put(std::ostream &os) const
Prints the short name of the Metric, e.g., "NDCG@K".
Definition: map.cc:83
friend std::ostream & operator<<(std::ostream &os, const Map &map)
Definition: map.h:60
static const std::string NAME_
Definition: map.h:49
This class wraps a set of results for a given query.
Definition: queryresults.h:36
virtual std::unique_ptr< Jacobian > jacobian(std::shared_ptr< data::RankedResults > ranked) const
Computes the Jacobian matrix.
Definition: map.cc:47
Map(size_t k=NO_CUTOFF)
Definition: map.h:38
double MetricScore
data type for QueryID in L-t-R datasets
Definition: types.h:33