---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://catboost.ai/docs/en/concepts/loss-functions-ranking.md
  - href: en/concepts/loss-functions-ranking.md
    type: text/markdown
    title: Markdown version
  - href: ../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://catboost.ai/docs/en/llms.txt

# Ranking: objectives and metrics

## Pairwise metrics {#pairwise-metrics}

Pairwise metrics use special labeled information — pairs of dataset objects where one object is considered the <q>winner</q> and the other is considered the <q>loser</q>. This information might be not exhaustive (not all possible pairs of objects are labeled in such a way). It is also possible to specify the weight for each pair.

If GroupId is specified, then all pairs must have both members from the same group if this dataset is used in pairwise modes.

{% cut "Read more about GroupId" %}

The identifier of the object's group. An arbitrary string, possibly representing an integer.

{% endcut %}

If the labeled pairs data is not specified for the dataset, then pairs are generated automatically in each group using per-object label values (labels must be specified and must be numerical). The object with a greater label value in the pair is considered the <q>winner</q>.

The following variables are used in formulas of the described pairwise metrics:
- $p$ is the positive object in the pair.
- $n$ is the negative object in the pair.

See all common variables in [Variables used in formulas](https://catboost.ai/docs/en/concepts/loss-functions-variables-used.md).

### PairLogit {#PairLogit}

$\displaystyle\frac{-\sum\limits_{p, n \in Pairs} w_{pn} \left(\log(\displaystyle\frac{1}{1 + e^{- (a_{p} - a_{n})}})\right)}{\sum\limits_{p, n \in Pairs} w_{pn}}$

<!-- source: en/_includes/work_src/reusage-loss-functions/the-weights-of-objects-not-used-to-calculate-metrics.md -->
{% note info %}

The object weights are not used to calculate and optimize the value of this metric. The weights of object pairs are used instead.

{% endnote %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/the-weights-of-objects-not-used-to-calculate-metrics.md -->

**Usage information** See [more](#usage-information).

**User-defined parameters**

<!-- source: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->
{% cut "use_weights" %}

Use object/group weights to calculate metrics if the specified value is <q>true</q> and set all weights to <q>1</q> regardless of the input data if the specified value is <q>false</q>.

_Default:_ true

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->

{% cut "max_pairs" %}

The maximum number of generated pairs in each group. Takes effect if no pairs are given and therefore are generated without repetition.

_Default:_ All possible pairs are generated in each group

{% endcut %}

### PairLogitPairwise {#PairLogitPairwise}

$\displaystyle\frac{-\sum\limits_{p, n \in Pairs} w_{pn} \left(\log(\displaystyle\frac{1}{1 + e^{- (a_{p} - a_{n})}})\right)}{\sum\limits_{p, n \in Pairs} w_{pn}}$

This metric may give more accurate results on large datasets compared to PairLogit but it is calculated significantly slower.

This technique is described in the [Winning The Transfer Learning Track of Yahoo!’s Learning To Rank Challenge with YetiRank](http://proceedings.mlr.press/v14/gulin11a.html) paper.

**Usage information** See [more](#usage-information).

<!-- source: en/_includes/work_src/reusage-loss-functions/the-weights-of-objects-not-used-to-calculate-metrics.md -->
{% note info %}

The object weights are not used to calculate and optimize the value of this metric. The weights of object pairs are used instead.

{% endnote %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/the-weights-of-objects-not-used-to-calculate-metrics.md -->

<!-- source: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->
{% cut "use_weights" %}

Use object/group weights to calculate metrics if the specified value is <q>true</q> and set all weights to <q>1</q> regardless of the input data if the specified value is <q>false</q>.

_Default:_ true

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->

{% cut "max_pairs" %}

The maximum number of generated pairs in each group. Takes effect if no pairs are given and therefore are generated without repetition.

_Default:_  All possible pairs are generated in each group

{% endcut %}

### PairAccuracy {#PairAccuracy}

$\displaystyle\frac{\sum\limits_{p, n \in Pairs} w_{pn} [a_{p} > a_{n}] }{\sum\limits_{p, n \in Pairs} w_{pn} }$

<!-- source: en/_includes/work_src/reusage-loss-functions/the-weights-of-objects-not-used-to-calculate-metrics-not-optimize.md -->
{% note info %}

The object weights are not used to calculate the value of this metric. The weights of object pairs are used instead.

{% endnote %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/the-weights-of-objects-not-used-to-calculate-metrics-not-optimize.md -->

**Can't be used for optimization.**  See [more](#usage-information).

<!-- source: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->
{% cut "use_weights" %}

Use object/group weights to calculate metrics if the specified value is <q>true</q> and set all weights to <q>1</q> regardless of the input data if the specified value is <q>false</q>.

_Default:_ true

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->

## Groupwise metrics {#groupwise-metrics}

### YetiRank {#YetiRank}

The calculation of this metric is disabled by default for the training dataset to speed up the training. Use the `hints=skip_train~false` parameter to enable the calculation.

<!-- source: en/_includes/work_src/reusage-loss-functions/yetirank__desc__first.md -->
An approximation of ranking metrics (such as NDCG and PFound). Allows to use ranking metrics for optimization.
<!-- endsource: en/_includes/work_src/reusage-loss-functions/yetirank__desc__first.md -->

<!-- source: en/_includes/work_src/reusage-loss-functions/yetirank__desc__last.md -->
The value of this metric can not be calculated. The metric that is written to [output data](https://catboost.ai/docs/en/concepts/output-data.md) if YetiRank is optimized depends on the range of all _N_ target values ($i \in [1; N]$) of the dataset:
- $target_{i} \in [0; 1]$ — PFound
- $target_{i} \notin [0; 1]$ — NDCG
<!-- endsource: en/_includes/work_src/reusage-loss-functions/yetirank__desc__last.md -->

This metric gives less accurate results on big datasets compared to YetiRankPairwise but it is significantly faster.

<!-- source: en/_includes/work_src/reusage-loss-functions/the-weights-of-groups.md -->
{% note info %}

The object weights are not used to optimize this metric. The group weights are used instead.

This objective is used to optimize PairLogit. Automatically generated object pairs are used for this purpose. These pairs are generated independently for each object group. Use the [Group weights](https://catboost.ai/docs/en/concepts/input-data_group-weights.md) file or the GroupWeight column of the [Columns description](https://catboost.ai/docs/en/concepts/input-data_column-descfile.md) file to change the group importance. In this case, the weight of each generated pair is multiplied by the value of the corresponding group weight.

{% endnote %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/the-weights-of-groups.md -->

**Usage information** See [more](#usage-information).

Since CatBoost 1.2.1 YetiRank meaning has been expanded to allow for optimizing specific ranking loss functions by specifying `mode` loss function parameter. Default YetiRank can now also be referred as `mode=Classic`.

**User-defined parameters**

{% cut "mode" %}

The mode of operation. Either `Classic` - the traditional YetiRank as described in [Winning The Transfer Learning Track of Yahoo!’s Learning To Rank Challenge with YetiRank](http://proceedings.mlr.press/v14/gulin11a.html) or a specific ranking loss function to optimize as described in [Which Tricks are Important for Learning to Rank?](https://arxiv.org/abs/2204.01500) paper. Possible loss function values are `DCG`, `NDCG`, `MRR`, `ERR`, `MAP`. Non-Classic modes are supported only on CPU.

_Default:_  `Classic`

{% endcut %}

{% cut "permutations" %}

The number of permutations.

_Default:_ 10

{% endcut %}

{% cut "decay" %}

Used only in `Classic` mode.
The probability of search continuation after reaching the current object.

_Default:_  0.85

{% endcut %}

{% cut "top" %}

Used in all modes except `Classic`.

The number of top samples in a group that are used to calculate the ranking metric. Top samples are either the samples with the largest approx values or the ones with the lowest target values if approx values are the same.

Unlimited by default.

{% endcut %}

{% cut "dcg_type" %}

Used in modes `DCG` and `NDCG`.

Principle of calculation of \*DCG metrics.

_Default_: Base.
_Possible values_: `Base`, `Exp`.

{% endcut %}

{% cut "dcg_denominator" %}

Used in modes `DCG` and `NDCG`.

Principle of calculation of the denominator in \*DCG metrics.

_Default_: Position.
_Possible values_: `LogPosition`, `Position`.

{% endcut %}

{% cut "noise" %}

Type of noise to add to approxes.

_Default_: `Gumbel`.
_Possible values_: `Gumbel`, `Gauss`, `No`.

{% endcut %}

{% cut "noise_power" %}

Power of noise to add (multiplier). Used only for `Gauss` noise for now.

_Default_: 1.

{% endcut %}

{% cut "num_neighbors" %}

Used in all modes except `Classic`.

Number of neighbors used in the metric calculation.

_Default_: 1.

{% endcut %}

<!-- source: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->
{% cut "use_weights" %}

Use object/group weights to calculate metrics if the specified value is <q>true</q> and set all weights to <q>1</q> regardless of the input data if the specified value is <q>false</q>.

_Default:_ true

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->

### YetiRankPairwise {#YetiRankPairwise}

The calculation of this metric is disabled by default for the training dataset to speed up the training. Use the `hints=skip_train~false` parameter to enable the calculation.

<!-- source: en/_includes/work_src/reusage-loss-functions/yetirank__desc__first.md -->
An approximation of ranking metrics (such as NDCG and PFound). Allows to use ranking metrics for optimization.
<!-- endsource: en/_includes/work_src/reusage-loss-functions/yetirank__desc__first.md -->

<!-- source: en/_includes/work_src/reusage-loss-functions/yetirank__desc__last.md -->
The value of this metric can not be calculated. The metric that is written to [output data](https://catboost.ai/docs/en/concepts/output-data.md) if YetiRank is optimized depends on the range of all _N_ target values ($i \in [1; N]$) of the dataset:
- $target_{i} \in [0; 1]$ — PFound
- $target_{i} \notin [0; 1]$ — NDCG
<!-- endsource: en/_includes/work_src/reusage-loss-functions/yetirank__desc__last.md -->

This metric gives more accurate results on big datasets compared to YetiRank but it is significantly slower.

This technique is described in the [Winning The Transfer Learning Track of Yahoo!’s Learning To Rank Challenge with YetiRank](http://proceedings.mlr.press/v14/gulin11a.html) paper.

<!-- source: en/_includes/work_src/reusage-loss-functions/the-weights-of-groups.md -->
{% note info %}

The object weights are not used to optimize this metric. The group weights are used instead.

This objective is used to optimize PairLogit. Automatically generated object pairs are used for this purpose. These pairs are generated independently for each object group. Use the [Group weights](https://catboost.ai/docs/en/concepts/input-data_group-weights.md) file or the GroupWeight column of the [Columns description](https://catboost.ai/docs/en/concepts/input-data_column-descfile.md) file to change the group importance. In this case, the weight of each generated pair is multiplied by the value of the corresponding group weight.

{% endnote %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/the-weights-of-groups.md -->

**Usage information** See [more](#usage-information).

Since CatBoost 1.2.1 YetiRankPairwise meaning has been expanded to allow for optimizing specific ranking loss functions by specifying `mode` loss function parameter. Default YetiRankPairwise can now also be referred as `mode=Classic`.

**User-defined parameters**

{% cut "mode" %}

The mode of operation. Either `Classic` - the traditional YetiRankPairwise as described in [Winning The Transfer Learning Track of Yahoo!’s Learning To Rank Challenge with YetiRank](http://proceedings.mlr.press/v14/gulin11a.html) or a specific ranking loss function to optimize as described in [Which Tricks are Important for Learning to Rank?](https://arxiv.org/abs/2204.01500) paper. Possible loss function values are `DCG`, `NDCG`, `MRR`, `ERR`, `MAP`. Non-Classic modes are supported only on CPU.

_Default:_  `Classic`

{% endcut %}

{% cut "permutations" %}

The number of permutations.

_Default:_ 10

{% endcut %}

{% cut "decay" %}

Used only in `Classic` mode.
The probability of search continuation after reaching the current object.

_Default:_  0.85

{% endcut %}

{% cut "top" %}

Used in all modes except `Classic`.

The number of top samples in a group that are used to calculate the ranking metric. Top samples are either the samples with the largest approx values or the ones with the lowest target values if approx values are the same.

Unlimited by default.

{% endcut %}

{% cut "dcg_type" %}

Used in modes `DCG` and `NDCG`.

Principle of calculation of \*DCG metrics.

_Default_: Base.
_Possible values_: `Base`, `Exp`.

{% endcut %}

{% cut "dcg_denominator" %}

Used in modes `DCG` and `NDCG`.

Principle of calculation of the denominator in \*DCG metrics.

_Default_: Position.
_Possible values_: `LogPosition`, `Position`.

{% endcut %}

{% cut "noise" %}

Type of noise to add to approxes.

_Default_: `Gumbel`.
_Possible values_: `Gumbel`, `Gauss`, `No`.

{% endcut %}

{% cut "noise_power" %}

Power of noise to add (multiplier). Used only for `Gauss` noise for now.

_Default_: 1.

{% endcut %}

{% cut "num_neighbors" %}

Used in all modes except `Classic`.

Number of neighbors used in the metric calculation.

_Default_: 1.

{% endcut %}

<!-- source: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->
{% cut "use_weights" %}

Use object/group weights to calculate metrics if the specified value is <q>true</q> and set all weights to <q>1</q> regardless of the input data if the specified value is <q>false</q>.

_Default:_ true

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->


### LambdaMart {#LambdaMart}

Directly optimize the selected metric. The value of the selected metric is written to [output data](https://catboost.ai/docs/en/concepts/output-data.md)

Refer to the [From RankNet to LambdaRank to LambdaMART](https://www.microsoft.com/en-us/research/uploads/prod/2016/02/MSR-TR-2010-82.pdf) paper for details.

**Usage information** See [more](#usage-information).

**User-defined parameters**

{% cut "metric" %}

The metric that should be optimized.

_Default_: `NDCG`
_Supported values_: `DCG`, `NDCG`, `MRR`, `ERR`, `MAP`.

{% endcut %}

{% cut "sigma" %}

General sigmoid parameter. See [From RankNet to LambdaRank to LambdaMART](https://www.microsoft.com/en-us/research/uploads/prod/2016/02/MSR-TR-2010-82.pdf) paper for details.

_Default_: 1.0
_Supported values_: Real positive values.

{% endcut %}

{% cut "norm" %}

Derivatives should be normalized.

_Default_: True
_Supported values_: False, True.

{% endcut %}


### StochasticFilter {#StochasticFilter}

Directly optimize the FilteredDCG metric calculated for a pre-defined order of objects for filtration of objects under a fixed ranking. As a result, the FilteredDCG metric can be used for optimization.

$FilteredDCG = \sum\limits_{i=1}^{n}\displaystyle\frac{t_{i}}{i} { , where}$

$t_{i}$ is the relevance of an object in the group and the sum is computed over the documents with $a > 0$.

The filtration is defined via the raw formula value:

![](../images/formula__stohastic.png)

Zeros correspond to filtered instances and ones correspond to the remaining ones.

The ranking is defined by the order of objects in the dataset.

{% note warning %}

Sort objects by the column you are interested in before training with this loss function and use the `--has-time`for the Command-line version option to avoid further objects reordering.

{% endnote %}

For optimization, a distribution of filtrations is defined:

$\mathbb{P}(\text{filter}|x) = \sigma(a) { , where}$
- $\sigma(z) = \displaystyle\frac{1}{1 + \text{e}^{-z}}$
- The gradient is estimated via REINFORCE.

Refer to the [Learning to Select for a Predefined Ranking](http://proceedings.mlr.press/v97/vorobev19a/vorobev19a.pdf) paper for calculation details.

**Usage information** See [more](#usage-information).

**User-defined parameters**

{% cut "sigma" %}

The scale for multiplying predictions.

_Default:_ 1

{% endcut %}

{% cut "num_estimations" %}

The number of gradient samples.

_Default:_ 1

{% endcut %}


### StochasticRank {#StochasticRank}

Directly optimize the selected metric. The value of the selected metric is written to [output data](https://catboost.ai/docs/en/concepts/output-data.md)

Refer to the [StochasticRank: Global Optimization of Scale-Free Discrete Functions](https://arxiv.org/abs/2003.02122v1) paper for details.

**Usage information** See [more](#usage-information).

**User-defined parameters**

Common parameters:

{% cut "metric" %}

The metric that should be optimized.

_Default_: Obligatory parameter
_Supported values_: `DCG`, `NDCG`, `PFound`.

{% endcut %}

{% cut "num_estimations" %}

The number of gradient estimation iterations.

_Default_: 1

{% endcut %}

{% cut "mu" %}

Controls the penalty for coinciding predictions (aka _ties_).

_Default_: 0

{% endcut %}

Metric-specific parameters:

Available if the corresponding metric is set in the metric parameter.

**DCG**

<!-- source: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->
{% cut "top" %}

The number of top samples in a group that are used to calculate the ranking metric. Top samples are either the samples with the largest approx values or the ones with the lowest target values if approx values are the same.

_Default_: –1 (all label values are used).

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->

<!-- source: en/_includes/work_src/reusage-loss-functions/ndcg__type__desc__full.md -->
{% cut "type" %}

Metric calculation principles.

_Default_: Base.
_Possible values_: `Base`, `Exp`.

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/ndcg__type__desc__full.md -->

{% cut "denominator" %}

Metric denominator type.

_Default_: _Default_: LogPosition.
_Possible values_: `LogPosition`, `Position`.

{% endcut %}

**NDCG**

<!-- source: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->
{% cut "top" %}

The number of top samples in a group that are used to calculate the ranking metric. Top samples are either the samples with the largest approx values or the ones with the lowest target values if approx values are the same.

_Default_: –1 (all label values are used).

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->

<!-- source: en/_includes/work_src/reusage-loss-functions/ndcg__type__desc__full.md -->
{% cut "type" %}

Metric calculation principles.

_Default_: Base.
_Possible values_: `Base`, `Exp`.

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/ndcg__type__desc__full.md -->

{% cut "denominator" %}

Metric denominator type.

_Default_: LogPosition.
_Possible values_: `LogPosition`, `Position`.

{% endcut %}

**PFound**

<!-- source: en/_includes/work_src/reusage-loss-functions/decay__desc__full.md -->
{% cut "decay" %}

The probability of search continuation after reaching the current object.

_Default_: 0.85

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/decay__desc__full.md -->

<!-- source: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->
{% cut "top" %}

The number of top samples in a group that are used to calculate the ranking metric. Top samples are either the samples with the largest approx values or the ones with the lowest target values if approx values are the same.

_Default_: –1 (all label values are used).

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->

### QueryCrossEntropy {#QueryCrossEntropy}

$QueryCrossEntropy(\alpha) = (1 - \alpha) \cdot LogLoss + \alpha \cdot LogLoss_{group}$

See the [QueryCrossEntropy](https://catboost.ai/docs/en/references/querycrossentropy.md) section for more details.

**Usage information** See [more](#usage-information).

**User-defined parameters**

<!-- source: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->
{% cut "use_weights" %}

Use object/group weights to calculate metrics if the specified value is <q>true</q> and set all weights to <q>1</q> regardless of the input data if the specified value is <q>false</q>.

_Default:_ true

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->

{% cut "alpha" %}

The coefficient used in quantile-based losses.

_Default:_ 0.95

{% endcut %}

### QueryRMSE {#QueryRMSE}

$\displaystyle\sqrt{\displaystyle\frac{\sum\limits_{Group \in Groups} \sum\limits_{i \in Group} w_{i} \left( t_{i} - a_{i} - \displaystyle\frac{\sum\limits_{j \in Group} w_{j} (t_{j} - a_{j})}{\sum\limits_{j \in Group} w_{j}} \right)^{2}} {\sum\limits_{Group \in Groups} \sum\limits_{i \in Group} w_{i}}}$

**Usage information** See [more](#usage-information).

**User-defined parameters**

<!-- source: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->
{% cut "use_weights" %}

Use object/group weights to calculate metrics if the specified value is <q>true</q> and set all weights to <q>1</q> regardless of the input data if the specified value is <q>false</q>.

_Default:_ true

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->

### QuerySoftMax {#QuerySoftMax}

$- \displaystyle\frac{\sum\limits_{Group \in Groups} \sum\limits_{i \in Group}w_{i} t_{i} \log \left(\displaystyle\frac{w_{i} e^{\beta a_{i}}}{\sum\limits_{j\in Group} w_{j} e^{\beta a_{j}}}\right)} {\sum\limits_{Group \in Groups} \sum_{i\in Group} w_{i} t_{i}}$

**Usage information** See [more](#usage-information).

**User-defined parameters**

<!-- source: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->
{% cut "use_weights" %}

Use object/group weights to calculate metrics if the specified value is <q>true</q> and set all weights to <q>1</q> regardless of the input data if the specified value is <q>false</q>.

_Default:_ true

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->

{% cut "beta" %}

The input scale coefficient.

_Default:_ 1

{% endcut %}

### GroupQuantile {#GroupQuantile}

$\displaystyle\frac{\sum\limits_{Group \in Groups} \sum\limits_{i \in Group}w_{i}  (\alpha - I(t_{i} \leq a_{i} - g_{Group\ mean}  ))(t_{i} - a_{i} -  g_{Group\ mean}) } {\sum\limits_{Group \in Groups} \sum_{i\in Group} w_{i}}$,
where $g_{Group\ mean}=\displaystyle\frac{\sum\limits_{j \in Group} w_{j} (t_{j} - a_{j})}{\sum\limits_{j \in Group} w_{j}}$.

**Usage information** See [more](#usage-information).

**User-defined parameters**

<!-- source: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->
{% cut "use_weights" %}

Use object/group weights to calculate metrics if the specified value is <q>true</q> and set all weights to <q>1</q> regardless of the input data if the specified value is <q>false</q>.

_Default:_ true

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->


### PFound {#PFound}

The calculation of this metric is disabled by default for the training dataset to speed up the training. Use the `hints=skip_train~false` parameter to enable the calculation.

$PFound(top, decay) =$

$= \sum_{group \in groups} PFound(group, top, decay)$

See the [PFound](https://catboost.ai/docs/en/references/pfound.md) section for more details

**Can't be used for optimization.**  See [more](#usage-information).

**User-defined parameters**

<!-- source: en/_includes/work_src/reusage-loss-functions/decay__desc__full.md -->
{% cut "decay" %}

The probability of search continuation after reaching the current object.

_Default_: 0.85

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/decay__desc__full.md -->

<!-- source: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->
{% cut "top" %}

The number of top samples in a group that are used to calculate the ranking metric. Top samples are either the samples with the largest approx values or the ones with the lowest target values if approx values are the same.

_Default_: –1 (all label values are used).

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->

<!-- source: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->
{% cut "use_weights" %}

Use object/group weights to calculate metrics if the specified value is <q>true</q> and set all weights to <q>1</q> regardless of the input data if the specified value is <q>false</q>.

_Default:_ true

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->

### NDCG {#ndcg}

The calculation of this metric is disabled by default for the training dataset to speed up the training. Use the `hints=skip_train~false` parameter to enable the calculation.

$nDCG(top) = \frac{DCG(top)}{IDCG(top)}$

See the [NDCG](https://catboost.ai/docs/en/references/ndcg.md) section for more details.

**Can't be used for optimization.**  See [more](#usage-information).

**User-defined parameters**

<!-- source: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->
{% cut "top" %}

The number of top samples in a group that are used to calculate the ranking metric. Top samples are either the samples with the largest approx values or the ones with the lowest target values if approx values are the same.

_Default_: –1 (all label values are used).

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->

<!-- source: en/_includes/work_src/reusage-loss-functions/ndcg__type__desc__full.md -->
{% cut "type" %}

Metric calculation principles.

_Default_: Base.
_Possible values_: `Base`, `Exp`.

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/ndcg__type__desc__full.md -->

<!-- source: en/_includes/work_src/reusage-loss-functions/ndcg__denominator__desc__full.md -->
{% cut "denominator" %}

Metric denominator type.

_Default_: LogPosition.
_Possible values_: `LogPosition`, `Position`.

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/ndcg__denominator__desc__full.md -->

<!-- source: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->
{% cut "use_weights" %}

Use object/group weights to calculate metrics if the specified value is <q>true</q> and set all weights to <q>1</q> regardless of the input data if the specified value is <q>false</q>.

_Default:_ true

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->

### DCG {#dcg}

The calculation of this metric is disabled by default for the training dataset to speed up the training. Use the `hints=skip_train~false` parameter to enable the calculation.

$DCG(top)$

See the [NDCG](https://catboost.ai/docs/en/references/ndcg.md) section for more details.

**Can't be used for optimization.**  See [more](#usage-information).

**User-defined parameters**

<!-- source: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->
{% cut "top" %}

The number of top samples in a group that are used to calculate the ranking metric. Top samples are either the samples with the largest approx values or the ones with the lowest target values if approx values are the same.

_Default_: –1 (all label values are used).

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->

<!-- source: en/_includes/work_src/reusage-loss-functions/ndcg__type__desc__full.md -->
{% cut "type" %}

Metric calculation principles.

_Default_: Base.
_Possible values_: `Base`, `Exp`.

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/ndcg__type__desc__full.md -->

<!-- source: en/_includes/work_src/reusage-loss-functions/ndcg__denominator__desc__full.md -->
{% cut "denominator" %}

Metric denominator type.

_Default_: LogPosition.
_Possible values_: `LogPosition`, `Position`.

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/ndcg__denominator__desc__full.md -->

<!-- source: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->
{% cut "use_weights" %}

Use object/group weights to calculate metrics if the specified value is <q>true</q> and set all weights to <q>1</q> regardless of the input data if the specified value is <q>false</q>.

_Default:_ true

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->

### FilteredDCG {#FilteredDCG}

The calculation of this metric is disabled by default for the training dataset to speed up the training. Use the `hints=skip_train~false` parameter to enable the calculation.

See the [FilteredDCG](https://catboost.ai/docs/en/references/filtereddcg.md) section for more details.

**Can't be used for optimization.**  See [more](#usage-information).

**User-defined parameters**

<!-- source: en/_includes/work_src/reusage-loss-functions/ndcg__type__desc__full.md -->
{% cut "type" %}

Metric calculation principles.

_Default_: Base.
_Possible values_: `Base`, `Exp`.

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/ndcg__type__desc__full.md -->

<!-- source: en/_includes/work_src/reusage-loss-functions/ndcg__denominator__desc__full.md -->
{% cut "denominator" %}

Metric denominator type.

_Default_: LogPosition.
_Possible values_: `LogPosition`, `Position`.

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/ndcg__denominator__desc__full.md -->

### QueryAverage {#QueryAverage}

Represents the average value of the label values for objects with the defined top $M$ label values.

See the [QueryAverage](https://catboost.ai/docs/en/references/queryaverage.md) section for more details.

**Can't be used for optimization.**  See [more](#usage-information).

**User-defined parameters**

{% cut "top" %}

The number of top samples in a group that are used to calculate the ranking metric. Top samples are either the samples with the largest approx values or the ones with the lowest target values if approx values are the same.

_Default_: This parameter is obligatory (the default value is not defined).

{% endcut %}

<!-- source: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->
{% cut "use_weights" %}

Use object/group weights to calculate metrics if the specified value is <q>true</q> and set all weights to <q>1</q> regardless of the input data if the specified value is <q>false</q>.

_Default:_ true

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/use-weights__desc__with__default__value.md -->


### PrecisionAt {#PrecisionAtK}

<!-- source: en/_includes/work_src/reusage-common-phrases/function-calculation.md -->
The calculation of this function consists of the following steps:
<!-- endsource: en/_includes/work_src/reusage-common-phrases/function-calculation.md -->

1. The objects are sorted in descending order of predicted relevancies ($a_{i}$)

1. The metric is calculated as follows:

    $PrecisionAt(top, border) = \frac{\sum\limits_{i=1}^{top} Relevant_{i}}{top} { , where}$
    - $Relevant_{i} = \begin{cases} 1 { , } & t_{i} > {border} \\ 0 { , } & \text{in other cases} \end{cases}$

**Can't be used for optimization.**  See [more](#usage-information).

**User-defined parameters**

<!-- source: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->
{% cut "top" %}

The number of top samples in a group that are used to calculate the ranking metric. Top samples are either the samples with the largest approx values or the ones with the lowest target values if approx values are the same.

_Default_: –1 (all label values are used).

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->

<!-- source: en/_includes/work_src/reusage-loss-functions/ranking__border__desc__full.md -->
{% cut "border" %}

The label value border. If the value is strictly greater than this threshold, it is considered a positive class. Otherwise it is considered a negative class.

_Default_: 0

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/ranking__border__desc__full.md -->


### RecallAt {#RecallAtK}

<!-- source: en/_includes/work_src/reusage-common-phrases/function-calculation.md -->
The calculation of this function consists of the following steps:
<!-- endsource: en/_includes/work_src/reusage-common-phrases/function-calculation.md -->

1. The objects are sorted in descending order of predicted relevancies ($a_{i}$)

1. The metric is calculated as follows:
    $RecallAt(top, border) = \frac{\sum\limits_{i=1}^{top} Relevant_{i}}{\sum\limits_{i=1}^{N} Relevant_{i}}$
    - $Relevant_{i} = \begin{cases} 1 { , } & t_{i} > {border} \\ 0 { , } & \text{in other cases} \end{cases}$

**Can't be used for optimization.**  See [more](#usage-information).

**User-defined parameters**

<!-- source: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->
{% cut "top" %}

The number of top samples in a group that are used to calculate the ranking metric. Top samples are either the samples with the largest approx values or the ones with the lowest target values if approx values are the same.

_Default_: –1 (all label values are used).

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->

<!-- source: en/_includes/work_src/reusage-loss-functions/ranking__border__desc__full.md -->
{% cut "border" %}

The label value border. If the value is strictly greater than this threshold, it is considered a positive class. Otherwise it is considered a negative class.

_Default_: 0

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/ranking__border__desc__full.md -->


### MAP {#mapk}

1. The objectsare sorted in descending order of predicted relevancies ($a_{i}$)

1. The metric is calculated as follows:
    $MAP(top, border) = \frac{1}{N_{groups}} \sum\limits_{j = 1}^{N_{groups}} AveragePrecisionAt_{j}(top, border) { , where}$
    - $N_{groups}$ is the number of groups
    - $AveragePrecisionAt(top, border) = \frac{\sum\limits_{i=1}^{top} Relevant_{i} * PrecisionAt_{i}}{\sum\limits_{i=1}^{top} Relevant_{i} }$

    The value is calculated individually for each _j_-th group.

    - $Relevant_{i} = \begin{cases} 1 { , } & t_{i} > {border} \\ 0 { , } & {in other cases} \end{cases}$
    - $PrecisionAt_{i} = \frac{\sum\limits_{j=1}^{i} Relevant_{j}}{i}$

**Can't be used for optimization.**  See [more](#usage-information).

**User-defined parameters**

<!-- source: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->
{% cut "top" %}

The number of top samples in a group that are used to calculate the ranking metric. Top samples are either the samples with the largest approx values or the ones with the lowest target values if approx values are the same.

_Default_: –1 (all label values are used).

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->

<!-- source: en/_includes/work_src/reusage-loss-functions/ranking__border__desc__full.md -->
{% cut "border" %}

The label value border. If the value is strictly greater than this threshold, it is considered a positive class. Otherwise it is considered a negative class.

_Default_: 0

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/ranking__border__desc__full.md -->


### ERR {#err}

$ERR = \frac{1}{|Q|} \sum_{q=1}^{|Q|} ERR_q$

$ERR_q = \sum_{i=1}^{top} \frac{1}{i} t_{q,i} \prod_{j=1}^{i-1} (1 - t_{q,j})$

Targets should be from the range [0, 1].

$t_{q,i} \in [0, 1]$

**Can't be used for optimization.**  See [more](#usage-information).

**User-defined parameters**

<!-- source: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->
{% cut "top" %}

The number of top samples in a group that are used to calculate the ranking metric. Top samples are either the samples with the largest approx values or the ones with the lowest target values if approx values are the same.

_Default_: –1 (all label values are used).

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->


### MRR {#mrr}

$MRR = \frac{1}{|Q|} \sum_{q=1}^{|Q|} \frac{1}{rank_q}$, where $rank_q$ refers to the rank position of the first relevant document for the _q_-th query.

**Can't be used for optimization.**  See [more](#usage-information).

**User-defined parameters**

<!-- source: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->
{% cut "top" %}

The number of top samples in a group that are used to calculate the ranking metric. Top samples are either the samples with the largest approx values or the ones with the lowest target values if approx values are the same.

_Default_: –1 (all label values are used).

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/top__desc__full.md -->

<!-- source: en/_includes/work_src/reusage-loss-functions/ranking__border__desc__full.md -->
{% cut "border" %}

The label value border. If the value is strictly greater than this threshold, it is considered a positive class. Otherwise it is considered a negative class.

_Default_: 0

{% endcut %}
<!-- endsource: en/_includes/work_src/reusage-loss-functions/ranking__border__desc__full.md -->


### AUC {#AUC}

The calculation of this metric is disabled by default for the training dataset to speed up the training. Use the `hints=skip_train~false` parameter to enable the calculation.

<!-- source: en/_includes/work_src/reusage-loss-functions/type_of_auc__p.md -->
The type of AUC. Defines the metric calculation principles.
<!-- endsource: en/_includes/work_src/reusage-loss-functions/type_of_auc__p.md -->

<!-- source: en/_includes/work_src/reusage-popups/loss-functions-ranking__auc.md -->
#### Classic type

$\displaystyle\frac{\sum I(a_{i}, a_{j}) \cdot w_{i} \cdot w_{j}} {\sum w_{i} \cdot w_{j}}$
The sum is calculated on all pairs of objects $(i,j)$ such that:
- $t_{i} = 0$
- $t_{j} = 1$
- $I(x, y) = \begin{cases} 0 { , } & x < y \\ 0.5 { , } & x=y \\ 1 { , } & x>y \end{cases}$

Refer to the [Wikipedia article](https://en.wikipedia.org/wiki/Receiver_operating_characteristic#Area_under_the_curve) for details.

If the target type is not binary, then every object with target value $t$ and weight $w$ is replaced with two objects for the metric calculation:

- $o_{1}$ with weight $t \cdot w$ and target value 1
- $o_{2}$ with weight $(1 – t) \cdot w$ and target value 0.

Target values must be in the range [0; 1].

#### Ranking type

$\displaystyle\frac{\sum I(a_{i}, a_{j}) \cdot w_{i} \cdot w_{j}} {\sum w_{i} * w_{j}}$

The sum is calculated on all pairs of objects $(i,j)$ such that:
- $t_{i} < t_{j}$
- $I(x, y) = \begin{cases} 0 { , } & x < y \\ 0.5 { , } & x=y \\ 1 { , } & x>y \end{cases}$
<!-- endsource: en/_includes/work_src/reusage-popups/loss-functions-ranking__auc.md -->

**Can't be used for optimization.**  See [more](#usage-information).

**User-defined parameters**

{% cut "type" %}

The type of AUC. Defines the metrics calculation principles.

_Default_: `Classic`.
_Possible values_: `Classic`, `Ranking`.
_Examples_: `AUC:type=Classic`, `AUC:type=Ranking`.

{% endcut %}

{% cut "use_weights" %}

<!-- source: en/_includes/work_src/reusage-loss-functions/use-weights__desc__without__note.md -->
Use object/group weights to calculate metrics if the specified value is <q>true</q> and set all weights to <q>1</q> regardless of the input data if the specified value is <q>false</q>.
<!-- endsource: en/_includes/work_src/reusage-loss-functions/use-weights__desc__without__note.md -->

_Default_: `False` for Classic type, `True` for Ranking type.
_Examples_: `AUC:type=Ranking;use_weights=False`.

{% endcut %}

<!-- source: en/_includes/concepts/query-auc.md -->
### QueryAUC {#QueryAUC}

#### Classic type

$\displaystyle\frac{ \sum_q \sum_{i, j \in q}  \sum I(a_{i}, a_{j}) \cdot w_{i} \cdot w_{j}} { \sum_q \sum_{i, j \in q}
\sum w_{i} \cdot w_{j}}$
The sum is calculated on all pairs of objects $(i,j)$ such that:
- $t_{i} = 0$
- $t_{j} = 1$
- $I(x, y) = \begin{cases} 0 { , } & x < y \\ 0.5 { , } & x=y \\ 1 { , } & x>y \end{cases}$

Refer to the [Wikipedia article](https://en.wikipedia.org/wiki/Receiver_operating_characteristic#Area_under_the_curve) for details.

If the target type is not binary, then every object with target value $t$ and weight $w$ is replaced with two objects for the metric calculation:

- $o_{1}$ with weight $t \cdot w$ and target value 1
- $o_{2}$ with weight $(1 – t) \cdot w$ and target value 0.

Target values must be in the range [0; 1].

#### Ranking type

$\displaystyle\frac{ \sum_q \sum_{i, j \in q}  \sum I(a_{i}, a_{j}) \cdot w_{i} \cdot w_{j}} { \sum_q \sum_{i, j \in q} \sum w_{i} * w_{j}}$

The sum is calculated on all pairs of objects $(i,j)$ such that:
- $t_{i} < t_{j}$
- $I(x, y) = \begin{cases} 0 { , } & x < y \\ 0.5 { , } & x=y \\ 1 { , } & x>y \end{cases}$

**Can't be used for optimization.** See [more](#optimization).

**User-defined parameters**

{% cut "type" %}

The type of QueryAUC. Defines the metric calculation principles.

_Default_: `Ranking`.
_Possible values_: `Classic`, `Ranking`.
_Examples_: `QueryAUC:type=Classic`, `QueryAUC:type=Ranking`.

{% endcut %}

{% cut "use_weights" %}

<!-- source: en/_includes/work_src/reusage-loss-functions/use-weights__desc__without__note.md -->
Use object/group weights to calculate metrics if the specified value is <q>true</q> and set all weights to <q>1</q> regardless of the input data if the specified value is <q>false</q>.
<!-- endsource: en/_includes/work_src/reusage-loss-functions/use-weights__desc__without__note.md -->

_Default_: `False`.
_Examples_: `QueryAUC:type=Ranking;use_weights=False`.

{% endcut %}
<!-- endsource: en/_includes/concepts/query-auc.md -->

## Used for optimization {#usage-information}


| Name                                                        | Optimization            | GPU Support               |
--------------------------------------------------------------|-------------------------|---------------------------|
[PairLogit](#PairLogit)                 |     +                   | +                         |
[PairLogitPairwise](#PairLogitPairwise) |     +                   | +                         |
[PairAccuracy](#PairAccuracy)           |     -                   | -                         |
[YetiRank](#YetiRank)                   |     +                   | + (but only Classic mode) |
[YetiRankPairwise](#YetiRankPairwise)   |     +                   | + (but only Classic mode) |
[LambdaMart](#LambdaMart)               |     +                   | -                         |
[StochasticFilter](#StochasticFilter)   |     +                   | -                         |
[StochasticRank](#StochasticRank)       |     +                   | -                         |
[QueryCrossEntropy](#QueryCrossEntropy) |     +                   | +                         |
[QueryRMSE](#QueryRMSE)                 |     +                   | +                         |
[QuerySoftMax](#QuerySoftMax)           |     +                   | +                         |
[GroupQuantile](#GroupQuantile)         |     +                   | -                         |
[PFound](#PFound)                       |     -                   | -                         |
[NDCG](#ndcg)                           |     -                   | -                         |
[DCG](#dcg)                             |     -                   | -                         |
[FilteredDCG](#PFilteredDCG)            |     -                   | -                         |
[QueryAverage](#QueryAverage)           |     -                   | -                         |
[PrecisionAt](#PrecisionAtK)           |     -                   | -                         |
[RecallAt](#RecallAtK)                 |     -                   | -                         |
[MAP](#mapk)                           |     -                   | -                         |
[ERR](#err)                             |     -                   | -                         |
[MRR](#mrr)                             |     -                   | -                         |
[AUC](#AUC)                             |     -                   | -                         |
[QueryAUC](#QueryAUC)                   |     -                   | -                         |
