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

# Overfitting detector

<!-- source: en/_includes/work_src/reusage-common-phrases/od__purpose.md -->
If overfitting occurs, CatBoost can stop the training earlier than the training parameters dictate. For example, it can be stopped before the specified number of trees are built. This option is set in the starting parameters.
<!-- endsource: en/_includes/work_src/reusage-common-phrases/od__purpose.md -->


The following overfitting detection methods are supported:
- [IncToDec](#inctodec)
- [Iter](#iter)


## IncToDec {#inctodec}

Before building each new tree, CatBoost checks the resulting loss change on the validation dataset. The overfit detector is triggered if the $Threshold$ value set in the starting parameters is greater than $CurrentPValue$:

$CurrentPValue < Threshold$

How $CurrentPValue$ is calculated from a set of values for the maximizing metric $score[i]$:
1. $ExpectedInc$ is calculated:

    $ExpectedInc = max_{i_{1} \leq i_{2} \leq i } 0.99^{i - i_{1}} \cdot (score[i_{2}] - score[i_{1}])$

1. $x$ is calculated:

    $x = \frac{ExpectedInc[i]}{max_{j \leq i} { } score[j] - score[i]}$

1. $CurrentPValue$ is calculated:

    $CurrentPValue = exp \left(- \frac{0.5}{x}\right)$


## Iter {#iter}

Before building each new tree, CatBoost checks the number of iterations since the iteration with the optimal [loss function](https://catboost.ai/docs/en/concepts/loss-functions.md) value.

The model is considered overfitted if the number of iterations exceeds the value specified in the training parameters.
