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

# staged_predict

<!-- source: en/_includes/work_src/reusage/staged-predict__purpose__full-with-note__div.md -->
Apply the model to the given dataset and calculate the results taking into consideration only the trees in the range [0; i).


<!-- source: en/_includes/work_src/reusage/applying-the-model__restriction.md -->
{% note info %}

<!-- source: en/_includes/work_src/reusage-common-phrases/python__note__predict_note_for_packages_must-contain-all-features__python.md -->
The model prediction results will be correct only if the `data` parameter with feature values contains all the features used in the model. Typically, the order of these features must match the order of the corresponding columns that is provided during the training. But if feature names are provided both during the training and when applying the model, they can be matched by names instead of columns order. Feature names can be specified if the `data` parameter has one of the following types:
- [FeaturesData](https://catboost.ai/docs/en/concepts/python-features-data__desc.md)
- [catboost.Pool](https://catboost.ai/docs/en/concepts/python-reference_pool.md)
- [pandas.DataFrame](https://pandas.pydata.org/pandas-docs/stable/reference/frame.html) (in this case, feature names are taken from column names)
- [polars.DataFrame](https://docs.pola.rs/api/python/stable/reference/dataframe/index.html) (in this case, feature names are taken from column names)
<!-- endsource: en/_includes/work_src/reusage-common-phrases/python__note__predict_note_for_packages_must-contain-all-features__python.md -->

{% endnote %}
<!-- endsource: en/_includes/work_src/reusage/applying-the-model__restriction.md -->
<!-- endsource: en/_includes/work_src/reusage/staged-predict__purpose__full-with-note__div.md -->


## Method call format {#call-format}

```python
staged_predict(data,
               prediction_type=None,
               ntree_start=0,
               ntree_end=0,
               eval_period=1,
               thread_count=-1,
               verbose=False)
```

## Parameters {#parameters}

### data

#### Description

Feature values data.

The format depends on the number of input objects:

- Multiple — Matrix-like data of shape `(object_count, feature_count)`
- Single — An array

**Possible types**

For multiple objects:

- catboost.Pool
- list of lists
- numpy.ndarray of shape `(object_count, feature_count)`
- pandas.DataFrame
- pandas.SparseDataFrame
- pandas.Series
- [polars.DataFrame](https://docs.pola.rs/api/python/stable/reference/dataframe/index.html)
- [catboost.FeaturesData](https://catboost.ai/docs/en/concepts/python-features-data__desc.md)
- <!-- source: en/_includes/work_src/reusage-formats/scipy-except-dia.md -->
  scipy.sparse.spmatrix (all subclasses except dia_matrix)
  <!-- endsource: en/_includes/work_src/reusage-formats/scipy-except-dia.md -->


For a single object:

- list of feature values
- one-dimensional numpy.ndarray with feature values

**Default value**

Required parameter


### prediction_type

#### Description



The required prediction type.

Supported prediction types:
- Probability
- Class
- RawFormulaVal
- Exponent
- LogProbability

**Possible types**

string

**Default value**

None (Exponent for Poisson and Tweedie, RawFormulaVal for all other loss functions)


### ntree_start

#### Description

To reduce the number of trees to use when the model is applied or the metrics are calculated, set the range of the tree indices to`[ntree_start; ntree_end)` and the `eval_period` parameter to _k_ to calculate metrics on every _k_-th iteration.

<!-- source: en/_includes/work_src/reusage-common-phrases/ntree_start__short-param-desc.md -->
This parameter defines the index of the first tree to be used when applying the model or calculating the metrics (the inclusive left border of the range). Indices are zero-based.
<!-- endsource: en/_includes/work_src/reusage-common-phrases/ntree_start__short-param-desc.md -->

**Possible types**

int

**Default value**

0


### ntree_end

#### Description

To reduce the number of trees to use when the model is applied or the metrics are calculated, set the range of the tree indices to`[ntree_start; ntree_end)` and the `eval_period` parameter to _k_ to calculate metrics on every _k_-th iteration.

<!-- source: en/_includes/work_src/reusage-common-phrases/ntree_end__short-param-desc.md -->
This parameter defines the index of the first tree not to be used when applying the model or calculating the metrics (the exclusive right border of the range). Indices are zero-based.
<!-- endsource: en/_includes/work_src/reusage-common-phrases/ntree_end__short-param-desc.md -->

**Possible types**

int

**Default value**

0 (the index of the last tree to use equals to the number of trees in the
                    model minus one)


### eval_period

#### Description

To reduce the number of trees to use when the model is applied or the metrics are calculated, set the range of the tree indices to`[ntree_start; ntree_end)` and the `eval_period` parameter to _k_ to calculate metrics on every _k_-th iteration.

<!-- source: en/_includes/work_src/reusage-common-phrases/python_r__eval__period__desc__no-example.md -->
This parameter defines the step to iterate over the range `[`ntree_start`; `ntree_end`)`. For example, let's assume that the following parameter values are set:

- `ntree_start` is set 0
- `ntree_end` is set to N (the total tree count)
- `eval_period` is set to 2
<!-- endsource: en/_includes/work_src/reusage-common-phrases/python_r__eval__period__desc__no-example.md -->


In this case, the metrics are calculated for the following tree ranges: `[0, 2)`, `[0, 4)`, ... , `[0, N)`

**Possible types**

int

**Default value**

1 (the trees are applied sequentially: the first tree, then the first two
                    trees, etc.)

### thread_count

#### Description

The number of threads to use.

<!-- source: en/_includes/work_src/reusage/thread_count__cpu_cores__optimizes-the-speed-of-execution.md -->
Optimizes the speed of execution. This parameter doesn't affect results.
<!-- endsource: en/_includes/work_src/reusage/thread_count__cpu_cores__optimizes-the-speed-of-execution.md -->

**Possible types**

int

**Default value**

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


### verbose

#### Description

Output the measured evaluation metric to stderr.

**Possible types**

bool

**Default value**

None


## Return value {#output-format}

<!-- source: en/_includes/work_src/reusage/python__staged_predict__output-type__intro.md -->
Generator that produces predictions with a sequentially growing subset of trees from the model. The type of generated values depends on the number of input objects:
<!-- endsource: en/_includes/work_src/reusage/python__staged_predict__output-type__intro.md -->


<!-- source: en/_includes/work_src/reusage/regressor__type-of-returned-value__div.md -->
- Single object — Single float formula return value
- Multiple objects — One-dimensional numpy.ndarray of formula values for each object.
<!-- endsource: en/_includes/work_src/reusage/regressor__type-of-returned-value__div.md -->


