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::Ndcg Class Reference

This class implements the Normalized Discounted cumulative Gain NDCG@k measure. More...

#include <ndcg.h>

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

Public Member Functions

 Ndcg (size_t k=NO_CUTOFF)
 
virtual ~Ndcg ()
 
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
 
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::Dcg
 Dcg (size_t k=NO_CUTOFF)
 
virtual ~Dcg ()
 
- 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_ = "NDCG"
 
- Static Public Attributes inherited from quickrank::metric::ir::Dcg
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_idcg (const quickrank::data::QueryResults *rl) const
 Computes the IDCG@K of a given list of labels. More...
 
- Protected Member Functions inherited from quickrank::metric::ir::Dcg
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 Ndcg &ndcg)
 

Detailed Description

This class implements the Normalized Discounted cumulative Gain NDCG@k measure.

NDCG is measured as: \( NDCG_k = \frac{1}{IDCG_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, and \(IDCG_k\) is the NDCG@K of a perfectly orderd result list.

Constructor & Destructor Documentation

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

Member Function Documentation

MetricScore quickrank::metric::ir::Ndcg::compute_idcg ( const quickrank::data::QueryResults rl) const
protected

Computes the IDCG@K of a given list of labels.

Parameters
rlThe given results list. Only labels are actually used.
Returns
IDCG@K for computed on the given labels.
MetricScore quickrank::metric::ir::Ndcg::evaluate_result_list ( const quickrank::data::QueryResults rl,
const Score scores 
) const
virtual
Todo:
TODO: for only zero result slist Yahoo! LTR returns 0.5 instead of 0.0.

Make this choice available.

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

Reimplemented from quickrank::metric::ir::Dcg.

Reimplemented in quickrank::metric::ir::Tndcg.

std::unique_ptr< Jacobian > quickrank::metric::ir::Ndcg::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::Dcg.

Reimplemented in quickrank::metric::ir::Tndcg.

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

Returns the name of the metric.

Reimplemented from quickrank::metric::ir::Dcg.

Reimplemented in quickrank::metric::ir::Tndcg.

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

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

Reimplemented from quickrank::metric::ir::Dcg.

Reimplemented in quickrank::metric::ir::Tndcg.

Friends And Related Function Documentation

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

Member Data Documentation

const std::string quickrank::metric::ir::Ndcg::NAME_ = "NDCG"
static

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