---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://catboost.ai/docs/en/references/queryaverage.md
  - href: en/references/queryaverage.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

# QueryAverage

- [Calculation principles](#calculation)
- [User-defined parameters](#user-defined-parameters)

## Calculation principles {#calculation}

<!-- 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. Model values are calculated for the objects from the input dataset.

1. Top $M$ model values are selected for each group. The quantity $M$ is user-defined.

    For example, let's assume that the number of top model values is limited to 2 and the following values are calculated for the input dataset:
    ```no-highlight
    Document ID    Model value
    1              10.4
    2              20.1
    3              1.1
    ```

    In this case, the objects with indices 2 and 1 are selected.

1. The average of the label values is calculated for the objects selected at step [2](#step-top-label-values).

    For example, if the dataset consists of one group and the documents match the ones mentioned in the description of step [2](#step-top-label-values), the QueryAverage metric is calculated as follows:

    $QueryAverage = \displaystyle\frac{LabelValue_{object2} + LabelValue_{object1}}{2}$



## User-defined parameters {#user-defined-parameters}

### top

#### Description


<!-- source: en/_includes/work_src/reusage-loss-functions/top__desc.md -->
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.
<!-- endsource: en/_includes/work_src/reusage-loss-functions/top__desc.md -->


–1 (all label values are used)


