ā¹ļø Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0.1 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://catboost.ai/docs/en/concepts/python-reference_utils_eval_metric |
| Last Crawled | 2026-04-03 09:41:20 (4 days ago) |
| First Indexed | 2024-11-20 02:59:03 (1 year ago) |
| HTTP Status Code | 200 |
| Meta Title | eval_metric | CatBoost |
| Meta Description | Calculate the specified metric on raw approximated values of the formula and label values. Method call format. |
| Meta Canonical | null |
| Boilerpipe Text | Calculate the specified metric on raw approximated values of the formula and label values.
Method call format
eval_metric(label,
approx,
metric,
weight=
None
,
group_id=
None
,
subgroup_id=
None
,
pairs=
None
,
thread_count=-
1
)
Parameters
label
Description
A list of target variables (in other words, the label values of the objects).
Possible types
list
numpy.ndarray
pandas.DataFrame
pandas.Series
polars.Series
polars.DataFrame
Default value
Required parameter
approx
Description
A list of approximate values for all input objects.
Possible types
list
numpy.ndarray
pandas.DataFrame
pandas.Series
polars.Series
polars.DataFrame
Default value
Required parameter
metric
Description
The evaluation metric to calculate.
Supported metrics
RMSE
Logloss
MAE
CrossEntropy
Quantile
LogLinQuantile
Lq
MultiRMSE
MultiClass
MultiClassOneVsAll
MultiLogloss
MultiCrossEntropy
MAPE
Poisson
PairLogit
PairLogitPairwise
QueryRMSE
QuerySoftMax
GroupQuantile
Tweedie
SMAPE
Recall
Precision
F
F1
TotalF1
Accuracy
BalancedAccuracy
BalancedErrorRate
Kappa
WKappa
LogLikelihoodOfPrediction
AUC
QueryAUC
R2
FairLoss
NumErrors
MCC
BrierScore
HingeLoss
HammingLoss
ZeroOneLoss
MSLE
MedianAbsoluteError
Cox
Huber
Expectile
MultiRMSE
PairAccuracy
QueryAverage
PFound
NDCG
DCG
FilteredDCG
NormalizedGini
PrecisionAt
RecallAt
MAP
CtrFactor
YetiRank
YetiRankPairwise
StochasticFilter
StochasticRank
LambdaMart
Possible types
string
Default value
Required parameter
weight
Description
The weights of objects.
Possible types
list
numpy.ndarray
pandas.DataFrame
pandas.Series
polars.Series
Default value
None
group_id
Description
Group identifiers for all input objects. Supported identifier types are:
int
string types (string or unicode for Python 2 and bytes or string for Python 3).
Possible types
list
numpy.ndarray
pandas.DataFrame
pandas.Series
polars.Series
Default value
None
subgroup_id
Description
Subgroup identifiers for all input objects.
Possible types
list
numpy.ndarray
polars.Series
Default value
None
pairs
Description
The description is different for each group of possible types.
Possible types
list, numpy.ndarray, pandas.DataFrame, polars.DataFrame
TheĀ pairs description in the form of a two-dimensional matrix of shape
N
by 2:
N
is the number of pairs.
The first element of the pair is the zero-based index of the winner object from the input dataset for pairwise comparison.
The second element of the pairĀ is the zero-based index of the loser object from the input dataset for pairwise comparison.
This information is used for calculation and optimization ofĀ
Pairwise metrics
.
string
The path to the input file that contains theĀ
pairs description
.
This information is used for calculation and optimization ofĀ
Pairwise metrics
.
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
list with metric values.
Usage examples
The following is an example of usage with a
regression metric
:
from
catboost.utils
import
eval_metric
labels = [
0.2
, -
1
,
0.4
]
predictions = [
0.4
,
0.1
,
0.9
]
rmse = eval_metric(labels, predictions,
'RMSE'
)
The following is an example of usage with a
classification metric
:
from
catboost.utils
import
eval_metric
from
math
import
log
labels = [
1
,
0
,
1
]
probabilities = [
0.4
,
0.1
,
0.9
]
# In binary classification it is necessary to apply the logit function
# to the probabilities to get approxes.
logit =
lambda
x: log(x / (
1
- x))
approxes =
list
(
map
(logit, probabilities))
accuracy = eval_metric(labels, approxes,
'Accuracy'
)
The following is an example of usage with a
ranking metric
:
from
catboost.utils
import
eval_metric
# The dataset consists of five objects. The first two belong to one group
# and the other three to another.
group_ids = [
1
,
1
,
2
,
2
,
2
]
labels = [
0.9
,
0.1
,
0.5
,
0.4
,
0.8
]
# In ranking tasks it is not necessary to predict the same labels.
# It is important to predict the right order of objects.
good_predictions = [
0.5
,
0.4
,
0.2
,
0.1
,
0.3
]
bad_predictions = [
0.4
,
0.5
,
0.2
,
0.3
,
0.1
]
good_ndcg = eval_metric(labels, good_predictions,
'NDCG'
, group_id=group_ids)
bad_ndcg = eval_metric(labels, bad_predictions,
'NDCG'
, group_id=group_ids) |
| Markdown | [](https://catboost.ai/ "CatBoost")
- Installation
- [Overview](https://catboost.ai/docs/en/concepts/en/concepts/installation)
- Python package installation
- CatBoost for Apache Spark installation
- R package installation
- Command-line version binary
- Build from source
- Key Features
- Training parameters
- Python package
- [Quick start](https://catboost.ai/docs/en/concepts/en/concepts/python-quickstart)
- CatBoost
- CatBoostClassifier
- CatBoostRanker
- CatBoostRegressor
- [cv](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_cv)
- datasets
- FeaturesData
- MetricVisualizer
- Pool
- [sample\_gaussian\_process](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_sample_gaussian_process)
- [sum\_models](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_sum_models)
- [to\_classifier](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_to_classifier)
- [to\_regressor](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_to_regressor)
- [train](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_train)
- Text processing
- utils
- [Overview](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils)
- [create\_cd](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_create_cd)
- [eval\_metric](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric)
- [get\_confusion\_matrix](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_get_confusion_matrix)
- [get\_gpu\_device\_count](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_get_gpu_device_count)
- [get\_fnr\_curve](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_get_fnr_curve)
- [get\_fpr\_curve](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_get_fpr_curve)
- [get\_roc\_curve](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_get_roc_curve)
- [quantize](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_quantize)
- [select\_threshold](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_select_threshold)
- [Usage examples](https://catboost.ai/docs/en/concepts/en/concepts/python-usages-examples)
- CatBoost for Apache Spark
- R package
- Command-line version
- Applying models
- Objectives and metrics
- Model analysis
- Data format description
- [Parameter tuning](https://catboost.ai/docs/en/concepts/en/concepts/parameter-tuning)
- [Speeding up the training](https://catboost.ai/docs/en/concepts/en/concepts/speed-up-training)
- Data visualization
- Algorithm details
- [FAQ](https://catboost.ai/docs/en/concepts/en/concepts/faq)
- Educational materials
- [Development and contributions](https://catboost.ai/docs/en/concepts/en/concepts/development-and-contributions)
- [Contacts](https://catboost.ai/docs/en/concepts/en/concepts/contacts)
eval\_metric
## In this article:
- [Method call format](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#call-format)
- [Parameters](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#parameters)
- [label](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#label)
- [approx](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#approx)
- [metric](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#metric)
- [weight](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#weight)
- [group\_id](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#group_id)
- [subgroup\_id](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#subgroup_id)
- [pairs](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#pairs)
- [thread\_count](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#thread_count)
- [Type of return value](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#output-format)
- [Usage examples](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#usage-examples)
1. Python package
2. [utils](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils)
3. eval\_metric
# eval\_metric
- [Method call format](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#call-format)
- [Parameters](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#parameters)
- [label](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#label)
- [approx](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#approx)
- [metric](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#metric)
- [weight](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#weight)
- [group\_id](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#group_id)
- [subgroup\_id](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#subgroup_id)
- [pairs](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#pairs)
- [thread\_count](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#thread_count)
- [Type of return value](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#output-format)
- [Usage examples](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_eval_metric#usage-examples)
Calculate the specified metric on raw approximated values of the formula and label values.
## Method call format
```
eval_metric(label,
approx,
metric,
weight=None,
group_id=None,
subgroup_id=None,
pairs=None,
thread_count=-1)
```
## Parameters
### label
#### Description
A list of target variables (in other words, the label values of the objects).
**Possible types**
- list
- numpy.ndarray
- pandas.DataFrame
- pandas.Series
- [polars.Series](https://docs.pola.rs/api/python/stable/reference/series/index.html)
- [polars.DataFrame](https://docs.pola.rs/api/python/stable/reference/dataframe/index.html)
**Default value**
Required parameter
### approx
#### Description
A list of approximate values for all input objects.
**Possible types**
- list
- numpy.ndarray
- pandas.DataFrame
- pandas.Series
- [polars.Series](https://docs.pola.rs/api/python/stable/reference/series/index.html)
- [polars.DataFrame](https://docs.pola.rs/api/python/stable/reference/dataframe/index.html)
**Default value**
Required parameter
### metric
#### Description
The evaluation metric to calculate.
Supported metrics
- RMSE
- Logloss
- MAE
- CrossEntropy
- Quantile
- LogLinQuantile
- Lq
- MultiRMSE
- MultiClass
- MultiClassOneVsAll
- MultiLogloss
- MultiCrossEntropy
- MAPE
- Poisson
- PairLogit
- PairLogitPairwise
- QueryRMSE
- QuerySoftMax
- GroupQuantile
- Tweedie
- SMAPE
- Recall
- Precision
- F
- F1
- TotalF1
- Accuracy
- BalancedAccuracy
- BalancedErrorRate
- Kappa
- WKappa
- LogLikelihoodOfPrediction
- AUC
- QueryAUC
- R2
- FairLoss
- NumErrors
- MCC
- BrierScore
- HingeLoss
- HammingLoss
- ZeroOneLoss
- MSLE
- MedianAbsoluteError
- Cox
- Huber
- Expectile
- MultiRMSE
- PairAccuracy
- QueryAverage
- PFound
- NDCG
- DCG
- FilteredDCG
- NormalizedGini
- PrecisionAt
- RecallAt
- MAP
- CtrFactor
- YetiRank
- YetiRankPairwise
- StochasticFilter
- StochasticRank
- LambdaMart
**Possible types**
string
**Default value**
Required parameter
### weight
#### Description
The weights of objects.
**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
### group\_id
#### Description
Group identifiers for all input objects. Supported identifier types are:
- int
- string types (string or unicode for Python 2 and bytes or string for Python 3).
**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
### subgroup\_id
#### Description
Subgroup identifiers for all input objects.
**Possible types**
- list
- numpy.ndarray
- [polars.Series](https://docs.pola.rs/api/python/stable/reference/series/index.html)
**Default value**
None
### pairs
#### Description
The description is different for each group of possible types.
**Possible types**
list, numpy.ndarray, pandas.DataFrame, polars.DataFrame
The pairs description in the form of a two-dimensional matrix of shape `N` by 2:
- `N` is the number of pairs.
- The first element of the pair is the zero-based index of the winner object from the input dataset for pairwise comparison.
- The second element of the pair is the zero-based index of the loser object from the input dataset for pairwise comparison.
This information is used for calculation and optimization of [Pairwise metrics](https://catboost.ai/docs/en/concepts/en/concepts/loss-functions-ranking).
string
The path to the input file that contains the [pairs description](https://catboost.ai/docs/en/concepts/en/concepts/input-data_pairs-description).
This information is used for calculation and optimization of [Pairwise metrics](https://catboost.ai/docs/en/concepts/en/concepts/loss-functions-ranking).
**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
list with metric values.
## Usage examples
The following is an example of usage with a [regression metric](https://catboost.ai/docs/en/concepts/en/concepts/loss-functions-regression):
```
from catboost.utils import eval_metric
labels = [0.2, -1, 0.4]
predictions = [0.4, 0.1, 0.9]
rmse = eval_metric(labels, predictions, 'RMSE')
```
The following is an example of usage with a [classification metric](https://catboost.ai/docs/en/concepts/en/concepts/loss-functions-classification):
```
from catboost.utils import eval_metric
from math import log
labels = [1, 0, 1]
probabilities = [0.4, 0.1, 0.9]
# In binary classification it is necessary to apply the logit function
# to the probabilities to get approxes.
logit = lambda x: log(x / (1 - x))
approxes = list(map(logit, probabilities))
accuracy = eval_metric(labels, approxes, 'Accuracy')
```
The following is an example of usage with a [ranking metric](https://catboost.ai/docs/en/concepts/en/concepts/loss-functions-ranking):
```
from catboost.utils import eval_metric
# The dataset consists of five objects. The first two belong to one group
# and the other three to another.
group_ids = [1, 1, 2, 2, 2]
labels = [0.9, 0.1, 0.5, 0.4, 0.8]
# In ranking tasks it is not necessary to predict the same labels.
# It is important to predict the right order of objects.
good_predictions = [0.5, 0.4, 0.2, 0.1, 0.3]
bad_predictions = [0.4, 0.5, 0.2, 0.3, 0.1]
good_ndcg = eval_metric(labels, good_predictions, 'NDCG', group_id=group_ids)
bad_ndcg = eval_metric(labels, bad_predictions, 'NDCG', group_id=group_ids)
```
### Was the article helpful?
Yes
No
Previous
[create\_cd](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_create_cd)
Next
[get\_confusion\_matrix](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_utils_get_confusion_matrix)
 |
| Readable Markdown | Calculate the specified metric on raw approximated values of the formula and label values.
## Method call format
```
eval_metric(label,
approx,
metric,
weight=None,
group_id=None,
subgroup_id=None,
pairs=None,
thread_count=-1)
```
## Parameters
### label
#### Description
A list of target variables (in other words, the label values of the objects).
**Possible types**
- list
- numpy.ndarray
- pandas.DataFrame
- pandas.Series
- [polars.Series](https://docs.pola.rs/api/python/stable/reference/series/index.html)
- [polars.DataFrame](https://docs.pola.rs/api/python/stable/reference/dataframe/index.html)
**Default value**
Required parameter
### approx
#### Description
A list of approximate values for all input objects.
**Possible types**
- list
- numpy.ndarray
- pandas.DataFrame
- pandas.Series
- [polars.Series](https://docs.pola.rs/api/python/stable/reference/series/index.html)
- [polars.DataFrame](https://docs.pola.rs/api/python/stable/reference/dataframe/index.html)
**Default value**
Required parameter
### metric
#### Description
The evaluation metric to calculate.
Supported metrics
- RMSE
- Logloss
- MAE
- CrossEntropy
- Quantile
- LogLinQuantile
- Lq
- MultiRMSE
- MultiClass
- MultiClassOneVsAll
- MultiLogloss
- MultiCrossEntropy
- MAPE
- Poisson
- PairLogit
- PairLogitPairwise
- QueryRMSE
- QuerySoftMax
- GroupQuantile
- Tweedie
- SMAPE
- Recall
- Precision
- F
- F1
- TotalF1
- Accuracy
- BalancedAccuracy
- BalancedErrorRate
- Kappa
- WKappa
- LogLikelihoodOfPrediction
- AUC
- QueryAUC
- R2
- FairLoss
- NumErrors
- MCC
- BrierScore
- HingeLoss
- HammingLoss
- ZeroOneLoss
- MSLE
- MedianAbsoluteError
- Cox
- Huber
- Expectile
- MultiRMSE
- PairAccuracy
- QueryAverage
- PFound
- NDCG
- DCG
- FilteredDCG
- NormalizedGini
- PrecisionAt
- RecallAt
- MAP
- CtrFactor
- YetiRank
- YetiRankPairwise
- StochasticFilter
- StochasticRank
- LambdaMart
**Possible types**
string
**Default value**
Required parameter
### weight
#### Description
The weights of objects.
**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
### group\_id
#### Description
Group identifiers for all input objects. Supported identifier types are:
- int
- string types (string or unicode for Python 2 and bytes or string for Python 3).
**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
### subgroup\_id
#### Description
Subgroup identifiers for all input objects.
**Possible types**
- list
- numpy.ndarray
- [polars.Series](https://docs.pola.rs/api/python/stable/reference/series/index.html)
**Default value**
None
### pairs
#### Description
The description is different for each group of possible types.
**Possible types**
list, numpy.ndarray, pandas.DataFrame, polars.DataFrame
The pairs description in the form of a two-dimensional matrix of shape `N` by 2:
- `N` is the number of pairs.
- The first element of the pair is the zero-based index of the winner object from the input dataset for pairwise comparison.
- The second element of the pair is the zero-based index of the loser object from the input dataset for pairwise comparison.
This information is used for calculation and optimization of [Pairwise metrics](https://catboost.ai/docs/en/concepts/loss-functions-ranking).
string
The path to the input file that contains the [pairs description](https://catboost.ai/docs/en/concepts/input-data_pairs-description).
This information is used for calculation and optimization of [Pairwise metrics](https://catboost.ai/docs/en/concepts/loss-functions-ranking).
**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
list with metric values.
## Usage examples
The following is an example of usage with a [regression metric](https://catboost.ai/docs/en/concepts/loss-functions-regression):
```
from catboost.utils import eval_metric
labels = [0.2, -1, 0.4]
predictions = [0.4, 0.1, 0.9]
rmse = eval_metric(labels, predictions, 'RMSE')
```
The following is an example of usage with a [classification metric](https://catboost.ai/docs/en/concepts/loss-functions-classification):
```
from catboost.utils import eval_metric
from math import log
labels = [1, 0, 1]
probabilities = [0.4, 0.1, 0.9]
# In binary classification it is necessary to apply the logit function
# to the probabilities to get approxes.
logit = lambda x: log(x / (1 - x))
approxes = list(map(logit, probabilities))
accuracy = eval_metric(labels, approxes, 'Accuracy')
```
The following is an example of usage with a [ranking metric](https://catboost.ai/docs/en/concepts/loss-functions-ranking):
```
from catboost.utils import eval_metric
# The dataset consists of five objects. The first two belong to one group
# and the other three to another.
group_ids = [1, 1, 2, 2, 2]
labels = [0.9, 0.1, 0.5, 0.4, 0.8]
# In ranking tasks it is not necessary to predict the same labels.
# It is important to predict the right order of objects.
good_predictions = [0.5, 0.4, 0.2, 0.1, 0.3]
bad_predictions = [0.4, 0.5, 0.2, 0.3, 0.1]
good_ndcg = eval_metric(labels, good_predictions, 'NDCG', group_id=group_ids)
bad_ndcg = eval_metric(labels, bad_predictions, 'NDCG', group_id=group_ids)
``` |
| Shard | 169 (laksa) |
| Root Hash | 17435841955170310369 |
| Unparsed URL | ai,catboost!/docs/en/concepts/python-reference_utils_eval_metric s443 |