---
metadata:
  - name: generator
    content: Diplodoc Platform v5.54.5
alternate:
  - https://catboost.ai/docs/en/concepts/python-reference_catboostranker_score.md
  - href: en/concepts/python-reference_catboostranker_score.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

# score

Calculate the NDCG@top [metric](https://catboost.ai/docs/en/concepts/loss-functions.md) for the objects in the given dataset.


## Method call format {#call-format}

```
score(X,
      y=None,
      group_id=None,
      top=None,
      type=None,
      denominator=None,
      group_weight=None,
      thread_count=-1)
```

## Parameters {#parameters}

### X

#### Description

The description is different for each group of possible types.

**Possible types**

{% cut "catboost.Pool" %}

The input training dataset.

{% note info %}

If a nontrivial value of the `cat_features` parameter is specified in the constructor of this class, CatBoost checks the equivalence of categorical features indices specification from the constructor parameters and in this Pool class.

{% endnote %}

{% endcut %}

{% cut "list, numpy.ndarray, pandas.DataFrame, pandas.Series, polars.DataFrame" %}

The input training dataset in the form of a two-dimensional feature matrix.

{% endcut %}

{% cut "pandas.SparseDataFrame, scipy.sparse.spmatrix (all subclasses except dia_matrix)" %}

<!-- source: en/_includes/work_src/reusage-formats/libsvm__desc.md -->
The input training dataset in the form of a two-dimensional sparse feature matrix.
<!-- endsource: en/_includes/work_src/reusage-formats/libsvm__desc.md -->

{% endcut %}

**Default value**

Required parameter


### y

#### Description

<!-- source: en/_includes/work_src/reusage/label--short-desc-evaluation.md -->
The target variables (in other words, the objects' label values) for the evaluation dataset.
<!-- endsource: en/_includes/work_src/reusage/label--short-desc-evaluation.md -->

<!-- source: en/_includes/work_src/reusage/label--detailed-desc-ranking.md -->
Must be in the form of a one-dimensional array of numeric values.
<!-- endsource: en/_includes/work_src/reusage/label--detailed-desc-ranking.md -->

{% note info %}

Do not use this parameter if the input training dataset (specified in the `X` parameter) type is catboost.Pool.

{% endnote %}

<!-- source: en/_includes/work_src/reusage/label--possible-types-1d-default-supported-processing-units.md -->
**Possible types**

- list
- numpy.ndarray
- pandas.Series
- [polars.Series](https://docs.pola.rs/api/python/stable/reference/series/index.html)

**Default value**

None

**Supported processing units**

CPU and GPU
<!-- endsource: en/_includes/work_src/reusage/label--possible-types-1d-default-supported-processing-units.md -->

### group_id

#### Description

A ranking group.

{% note info %}

Do not use this parameter if the input training dataset (specified in the `X` parameter) type is catboost.Pool.

{% endnote %}

**Possible types**

- numpy.ndarray
- pandas.DataFrame
- pandas.Series
- [polars.Series](https://docs.pola.rs/api/python/stable/reference/series/index.html)

**Default value**

None

### top

#### Description

 NDCG, Number of top-ranked objects to calculate NDCG

**Possible types**

- unsigned integer, up to `pow(2, 32) / 2 - 1`

**Default value**

None

### type

#### Description

Metric type: Base or Exp.

**Possible types**

- str

**Default value**

None

### denominator

#### Description

Denominator type.

**Possible types**

- str

**Default value**

None

### group_weight

#### Description

The weights of all objects within the defined groups from the input data in the form of one-dimensional array-like data.
Used for calculating the final values of trees. By default, it is set to one for all objects in all groups.
Only a `weight` or `group_weight` parameter can be used at the time.

**Possible types**

- list
- numpy.ndarray
- pandas.DataFrame
- pandas.Series
- [polars.Series](https://docs.pola.rs/api/python/stable/reference/series/index.html)

**Default value**

None

### thread_count

#### Description

The number of threads to use.

Optimizes the speed of execution. This parameter doesn't affect results.

**Possible types**

- int

**Default value**

-1 (the number of threads is equal to the number of processor cores)

## Type of return value {#output-format}
float
