QuickRank  v2.0
QuickRank: A C++ suite of Learning to Rank algorithms
Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Friends | List of all members
quickrank::metric::ir::Dcg Class Reference

This class implements the Discounted cumulative Gain DCG@K measure. More...

#include <dcg.h>

Inheritance diagram for quickrank::metric::ir::Dcg:
quickrank::metric::ir::Metric quickrank::metric::ir::Ndcg quickrank::metric::ir::Tndcg

Public Member Functions

 Dcg (size_t k=NO_CUTOFF)
 
virtual ~Dcg ()
 
virtual std::string name () const
 Returns the name of the metric. More...
 
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. More...
 
virtual std::unique_ptr< Jacobianjacobian (std::shared_ptr< data::RankedResults > ranked) const
 Computes the Jacobian matrix. More...
 
- Public Member Functions inherited from quickrank::metric::ir::Metric
 Metric (size_t k=NO_CUTOFF)
 Creates a new metric with the specified cut-off threshold. More...
 
virtual ~Metric ()
 
size_t cutoff () const
 Returns the current cut-off of the Metric. More...
 
void set_cutoff (size_t k)
 Updates the cut-off of the Metric. More...
 
virtual MetricScore evaluate_dataset (const std::shared_ptr< data::Dataset > dataset, const Score *scores) const
 
virtual MetricScore evaluate_dataset (const std::shared_ptr< data::VerticalDataset > dataset, const Score *scores) const
 

Static Public Attributes

static const std::string NAME_ = "DCG"
 
- Static Public Attributes inherited from quickrank::metric::ir::Metric
static const size_t NO_CUTOFF = SIZE_MAX
 This should be used when no cut-off on the results list is required. More...
 

Protected Member Functions

MetricScore compute_dcg (const Label *labels, size_t len) const
 Computes the DCG@K of a given array of labels. More...
 

Private Member Functions

virtual std::ostream & put (std::ostream &os) const
 Prints the short name of the Metric, e.g., "NDCG@K". More...
 

Friends

std::ostream & operator<< (std::ostream &os, const Dcg &ndcg)
 

Detailed Description

This class implements the Discounted cumulative Gain DCG@K measure.

DCG is measured as: \( DCG_k = \sum_{i=1}^k \frac{2^{l_i}-1}{\log_2 (i+1)}\), where \(l_i\) is the relevance label of the i-th document.

Constructor & Destructor Documentation

quickrank::metric::ir::Dcg::Dcg ( size_t  k = NO_CUTOFF)
inlineexplicit
virtual quickrank::metric::ir::Dcg::~Dcg ( )
inlinevirtual

Member Function Documentation

MetricScore quickrank::metric::ir::Dcg::compute_dcg ( const Label labels,
size_t  len 
) const
protected

Computes the DCG@K of a given array of labels.

Parameters
rlThe given array of labels.
Returns
DCG@K for computed on the given labels.
MetricScore quickrank::metric::ir::Dcg::evaluate_result_list ( const quickrank::data::QueryResults rl,
const Score scores 
) const
virtual

Measures the quality of the given results list according to the Metric.

Parameters
rlA results list.
scoresa list of scores
Returns
The quality score of the result list.

Implements quickrank::metric::ir::Metric.

Reimplemented in quickrank::metric::ir::Ndcg, and quickrank::metric::ir::Tndcg.

std::unique_ptr< Jacobian > quickrank::metric::ir::Dcg::jacobian ( std::shared_ptr< data::RankedResults ranked) const
virtual

Computes the Jacobian matrix.

This is a symmetric matrix storing the metric "decrease" when two documents scores are swapped.

Parameters
rlA results list.
Returns
A smart-pointer to the Jacobian Matrix.
Todo:
TODO: provide def implementation

Reimplemented from quickrank::metric::ir::Metric.

Reimplemented in quickrank::metric::ir::Ndcg, and quickrank::metric::ir::Tndcg.

virtual std::string quickrank::metric::ir::Dcg::name ( ) const
inlinevirtual

Returns the name of the metric.

Implements quickrank::metric::ir::Metric.

Reimplemented in quickrank::metric::ir::Ndcg, and quickrank::metric::ir::Tndcg.

std::ostream & quickrank::metric::ir::Dcg::put ( std::ostream &  os) const
privatevirtual

Prints the short name of the Metric, e.g., "NDCG@K".

Implements quickrank::metric::ir::Metric.

Reimplemented in quickrank::metric::ir::Tndcg, and quickrank::metric::ir::Ndcg.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const Dcg ndcg 
)
friend

Member Data Documentation

const std::string quickrank::metric::ir::Dcg::NAME_ = "DCG"
static

The documentation for this class was generated from the following files: