QuickRank  v2.0
QuickRank: A C++ suite of Learning to Rank algorithms
rankedresults.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 <memory>
25 
26 #include "types.h"
27 #include "queryresults.h"
28 
29 namespace quickrank {
30 namespace data {
31 
32 /// This class generates a ranked list of results.
33 ///
34 /// This class does not carry information about the actual features,
35 /// but only about the labels and the scores generated by a ranker
36 /// (this is why this is not (yet) a subclass of QueryResults).
38  public:
39 
40  /// Generates a Ranked Results list.
41  ///
42  /// This is actually used to sort QueryResults and to store
43  /// labels and scores in sorted order.
44  /// It generates a copy of original data and scores
45  /// which might be useful for caching.
46  /// It also provides an un-mapping function.
47  /// \param n_instances The number of training instances (lines) in the dataset.
48  /// \param n_features The number of features.
49  RankedResults(std::shared_ptr<QueryResults> results, Score *scores);
50  virtual ~RankedResults();
51 
52  // provide some kinf od unmap function ?
53 
54  Label *sorted_labels() const {
55  return labels_;
56  }
57 
58  Score *sorted_scores() const {
59  return scores_;
60  }
61 
62  const size_t pos_of_rank(const size_t rank) const {
63  return unmap_[rank];
64  }
65 
66  const size_t num_results() const {
67  return num_results_;
68  }
69 
70  private:
71  Label *labels_ = NULL;
72  Score *scores_ = NULL;
73  size_t num_results_;
74  size_t *unmap_ = NULL;
75 };
76 
77 } // namespace data
78 } // namespace quickrank
Definition: dataset.cc:28
const size_t pos_of_rank(const size_t rank) const
Definition: rankedresults.h:62
Label * sorted_labels() const
Definition: rankedresults.h:54
Label * labels_
Definition: rankedresults.h:71
Score * sorted_scores() const
Definition: rankedresults.h:58
This class generates a ranked list of results.
Definition: rankedresults.h:37
virtual ~RankedResults()
Definition: rankedresults.cc:42
RankedResults(std::shared_ptr< QueryResults > results, Score *scores)
Generates a Ranked Results list.
Definition: rankedresults.cc:27
double Score
data type for instance truth label
Definition: types.h:30
size_t * unmap_
Definition: rankedresults.h:74
const size_t num_results() const
Definition: rankedresults.h:66
size_t num_results_
Definition: rankedresults.h:73
float Label
Definition: types.h:29
Score * scores_
Definition: rankedresults.h:72