---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.3
alternate:
  - https://catboost.ai/docs/en/concepts/python-reference_catboost.md
---
> **Documentation Index:** Fetch the complete configuration index at https://catboost.ai/docs/en/llms.txt

# CatBoost

```python
class CatBoost(params=None)
```

## Purpose {#purpose}

<!-- source: en/_includes/work_src/reusage-python/purpose.md -->
Training and applying models.
<!-- endsource: en/_includes/work_src/reusage-python/purpose.md -->


## Parameters {#parameters}

### params

#### Description

The list of [parameters](https://catboost.ai/docs/en/references/training-parameters/index.md) to start training with.

If omitted, default values are used.

<!-- source: en/_includes/work_src/reusage/python--precedence.md -->
{% note info %}

Some parameters duplicate the ones specified for the [fit](https://catboost.ai/docs/en/concepts/python-reference_catboost_fit.md) method. In these cases the values specified for the [fit](https://catboost.ai/docs/en/concepts/python-reference_catboost_fit.md) method take precedence.

{% endnote %}
<!-- endsource: en/_includes/work_src/reusage/python--precedence.md -->

**Possible types:** `dict`

**Default value**

 `None`


## Attributes {#attributes}

### [tree_count_](https://catboost.ai/docs/en/concepts/python-reference_catboost_attributes.md#tree_count)

<!-- source: en/_includes/work_src/reusage-attributes/tree_count__desc.md -->
Return the number of trees in the model.

This number can differ from the value specified in the `--iterations` training parameter in the following cases:
- The training is stopped by the [overfitting detector](https://catboost.ai/docs/en/concepts/overfitting-detector.md).
- The `--use-best-model` training parameter is set to <q>True</q>.
<!-- endsource: en/_includes/work_src/reusage-attributes/tree_count__desc.md -->

###  [feature_importances_](https://catboost.ai/docs/en/concepts/python-reference_catboost_attributes.md#feature_importances)

<!-- source: en/_includes/work_src/reusage-attributes/feature_importances__desc.md -->
Return the calculated [feature importances](https://catboost.ai/docs/en/concepts/fstr.md). The output data depends on the type of the model's loss function:
- Non-ranking loss functions — [PredictionValuesChange](https://catboost.ai/docs/en/concepts/fstr.md#regular-feature-importance)
- Ranking loss functions — [LossFunctionChange](https://catboost.ai/docs/en/concepts/fstr.md#regular-feature-importances__lossfunctionchange)
<!-- endsource: en/_includes/work_src/reusage-attributes/feature_importances__desc.md -->

### [random_seed_](https://catboost.ai/docs/en/concepts/python-reference_catboost_attributes.md#random_seed)

<!-- source: en/_includes/work_src/reusage-attributes/random_seed__desc.md -->
The random seed used for training.
<!-- endsource: en/_includes/work_src/reusage-attributes/random_seed__desc.md -->

### [learning_rate_](https://catboost.ai/docs/en/concepts/python-reference_catboost_attributes.md#learning_rate)

<!-- source: en/_includes/work_src/reusage-attributes/learning_rate__desc.md -->
The learning rate used for training.
<!-- endsource: en/_includes/work_src/reusage-attributes/learning_rate__desc.md -->

### [feature_names_](https://catboost.ai/docs/en/concepts/python-reference_catboost_attributes.md#feature_names)

<!-- source: en/_includes/work_src/reusage-attributes/feature_names__desc.md -->
The names of features in the dataset.
<!-- endsource: en/_includes/work_src/reusage-attributes/feature_names__desc.md -->

### [evals_result_](https://catboost.ai/docs/en/concepts/python-reference_catboost_attributes.md#evals_result)

<!-- source: en/_includes/work_src/reusage/python__get-evals-result__desc.md -->
Return the values of metrics calculated during the training.
<!-- endsource: en/_includes/work_src/reusage/python__get-evals-result__desc.md -->

### [best_score_](https://catboost.ai/docs/en/concepts/python-reference_catboost_attributes.md#best_score#best_score)

<!-- source: en/_includes/work_src/reusage/python__method__get_best_score__desc.md -->
Return the best result for each metric calculated on each validation dataset.
<!-- endsource: en/_includes/work_src/reusage/python__method__get_best_score__desc.md -->

### [best_iteration_](https://catboost.ai/docs/en/concepts/python-reference_catboost_attributes.md#best_iteration)

<!-- source: en/_includes/work_src/reusage/python__method__get_best_iteration__desc.md -->
Return the identifier of the iteration with the best result of the evaluation metric or loss function on the last validation set.
<!-- endsource: en/_includes/work_src/reusage/python__method__get_best_iteration__desc.md -->

### [classes_](https://catboost.ai/docs/en/concepts/python-reference_catboost_attributes.md#classes)

<!-- source: en/_includes/work_src/reusage-attributes/attributes__classes__desc-div.md -->
Return the names of classes for classification models. An empty list is returned for all other models.

The order of classes in this list corresponds to the order of classes in resulting predictions.
<!-- endsource: en/_includes/work_src/reusage-attributes/attributes__classes__desc-div.md -->

## Methods {#methods}

### [fit](https://catboost.ai/docs/en/concepts/python-reference_catboost_fit.md)



<!-- source: en/_includes/work_src/reusage/fit--purpose-desc.md -->
Train a model.
<!-- endsource: en/_includes/work_src/reusage/fit--purpose-desc.md -->



### [predict](https://catboost.ai/docs/en/concepts/python-reference_catboost_predict.md)



<!-- source: en/_includes/work_src/reusage/predict--purpose.md -->
Apply the model to the given dataset.
<!-- endsource: en/_includes/work_src/reusage/predict--purpose.md -->



### [calc_feature_statistics](https://catboost.ai/docs/en/concepts/python-reference_catboost_calc_feature_statistics.md)



<!-- source: en/_includes/work_src/reusage-python/get_feature_statistics__desc__div.md -->
Calculate and plot a set of statistics for the chosen feature.
<!-- endsource: en/_includes/work_src/reusage-python/get_feature_statistics__desc__div.md -->



### [calc_leaf_indexes](https://catboost.ai/docs/en/concepts/python-reference_catboost_calc_leaf_indexes.md)



<!-- source: en/_includes/concepts/python-reference_catboost_calc_leaf_indexes/calc_leaf_indexes__desc.md -->
Returns indexes of leafs to which objects from pool are mapped by model trees.
<!-- endsource: en/_includes/concepts/python-reference_catboost_calc_leaf_indexes/calc_leaf_indexes__desc.md -->



### [compare](https://catboost.ai/docs/en/concepts/python-reference_catboost_modelcompare.md)



<!-- source: en/_includes/work_src/reusage-python/compare__purpose.md -->
Draw train and evaluation metrics in [Jupyter Notebook](https://catboost.ai/docs/en/features/visualization_jupyter-notebook.md) for two trained models.
<!-- endsource: en/_includes/work_src/reusage-python/compare__purpose.md -->



### [copy](https://catboost.ai/docs/en/concepts/python-reference_catboost_copy.md)



<!-- source: en/_includes/work_src/reusage/copy--purpose.md -->
Copy the CatBoost object.
<!-- endsource: en/_includes/work_src/reusage/copy--purpose.md -->



### [eval_metrics](https://catboost.ai/docs/en/concepts/python-reference_catboost_eval-metrics.md)



<!-- source: en/_includes/work_src/reusage/python__eval-metrics__purpose.md -->
Calculate the specified metrics for the specified dataset.
<!-- endsource: en/_includes/work_src/reusage/python__eval-metrics__purpose.md -->



### [get_all_params](https://catboost.ai/docs/en/concepts/python-reference_catboost_get_all_params.md)



<!-- source: en/_includes/work_src/reusage-python/python__get_all_params__desc__p.md -->
Return the values of all training parameters (including the ones that are not explicitly specified by users).
<!-- endsource: en/_includes/work_src/reusage-python/python__get_all_params__desc__p.md -->



### [get_best_iteration](https://catboost.ai/docs/en/concepts/python-reference_catboost_get_best_iteration.md)



<!-- source: en/_includes/work_src/reusage/python__method__get_best_iteration__desc.md -->
Return the identifier of the iteration with the best result of the evaluation metric or loss function on the last validation set.
<!-- endsource: en/_includes/work_src/reusage/python__method__get_best_iteration__desc.md -->



### [get_best_score](https://catboost.ai/docs/en/concepts/python-reference_catboost_get_best_score.md)



<!-- source: en/_includes/work_src/reusage/python__method__get_best_score__desc.md -->
Return the best result for each metric calculated on each validation dataset.
<!-- endsource: en/_includes/work_src/reusage/python__method__get_best_score__desc.md -->



### [get_borders](https://catboost.ai/docs/en/concepts/python-reference_catboost_get_borders.md)



<!-- source: en/_includes/work_src/reusage-python/get_borders__desc__div.md -->
Return the list of borders for numerical features.
<!-- endsource: en/_includes/work_src/reusage-python/get_borders__desc__div.md -->



### [get_evals_result](https://catboost.ai/docs/en/concepts/python-reference_catboost_get_evals_result.md)



<!-- source: en/_includes/work_src/reusage/python__get-evals-result__desc.md -->
Return the values of metrics calculated during the training.
<!-- endsource: en/_includes/work_src/reusage/python__get-evals-result__desc.md -->



### [get_feature_importance](https://catboost.ai/docs/en/concepts/python-reference_catboost_get_feature_importance.md)



<!-- source: en/_includes/work_src/reusage/feature_importances--purpose.md -->
Calculate and return the [feature importances](https://catboost.ai/docs/en/concepts/fstr.md).
<!-- endsource: en/_includes/work_src/reusage/feature_importances--purpose.md -->



### [get_metadata](https://catboost.ai/docs/en/concepts/python-reference_catboost_metadata.md)

 Return a proxy object with metadata from the model's internal key-value string storage.

### [get_object_importance](https://catboost.ai/docs/en/concepts/python-reference_catboost_get_object_importance.md)



<!-- source: en/_includes/work_src/reusage/python__get_object_importance__desc.md -->
Calculate the effect of objects from the train dataset on the optimized metric values for the objects from the input dataset:
- Positive values reflect that the optimized metric increases.
- Negative values reflect that the optimized metric decreases.
<!-- endsource: en/_includes/work_src/reusage/python__get_object_importance__desc.md -->



### [get_param](https://catboost.ai/docs/en/concepts/python-reference_catboost_get_param.md)



<!-- source: en/_includes/work_src/reusage/get_param--purpose.md -->
Return the value of the given  parameter if it is explicitly by the user before starting the training. If this parameter is used with the default value, this function returns None.
<!-- endsource: en/_includes/work_src/reusage/get_param--purpose.md -->



### [get_params](https://catboost.ai/docs/en/concepts/python-reference_catboost_get_params.md)



<!-- source: en/_includes/work_src/reusage/get_params--purpose.md -->
Return the values of training parameters that are explicitly specified by the user. If all parameters are used with their default values, this function returns an empty dict.
<!-- endsource: en/_includes/work_src/reusage/get_params--purpose.md -->



### [get_scale_and_bias](https://catboost.ai/docs/en/concepts/python-reference_catboost_get_scale_and_bias.md)



<!-- source: en/_includes/work_src/reusage-python/get_scale_and_bias__desc.md -->
Return the scale and bias of the model.

These values affect the results of applying the model, since the model prediction results are calculated as follows:
$\sum leaf\_values \cdot scale + bias$
<!-- endsource: en/_includes/work_src/reusage-python/get_scale_and_bias__desc.md -->



### [get_test_eval](https://catboost.ai/docs/en/concepts/python-reference_catboost_get_test_eval.md)



<!-- source: en/_includes/work_src/reusage/get_test_val--desc.md -->
Return the formula values that were calculated for the objects from the validation dataset provided for training.
<!-- endsource: en/_includes/work_src/reusage/get_test_val--desc.md -->



### [grid_search](https://catboost.ai/docs/en/concepts/python-reference_catboost_grid_search.md)



<!-- source: en/_includes/work_src/reusage-python/python__grid_search--desc.md -->
A simple grid search over specified parameter values for a model.
<!-- endsource: en/_includes/work_src/reusage-python/python__grid_search--desc.md -->



### [load_model](https://catboost.ai/docs/en/concepts/python-reference_catboost_load_model.md)



<!-- source: en/_includes/work_src/reusage/load_model--purpose.md -->
Load the model from a file.
<!-- endsource: en/_includes/work_src/reusage/load_model--purpose.md -->



### [plot_predictions](https://catboost.ai/docs/en/concepts/python-reference_catboost_plot_predictions.md)



<!-- source: en/_includes/work_src/reusage-python/plot_predictions__desc__short.md -->
Sequentially vary the value of the specified features to put them into all buckets and calculate predictions for the input objects accordingly.
<!-- endsource: en/_includes/work_src/reusage-python/plot_predictions__desc__short.md -->



### [plot_tree](https://catboost.ai/docs/en/concepts/python-reference_catboost_plot_tree.md)



<!-- source: en/_includes/work_src/reusage-python/python__plot-tree_desc__div.md -->
Visualize the CatBoost decision trees.
<!-- endsource: en/_includes/work_src/reusage-python/python__plot-tree_desc__div.md -->



### [randomized_search](https://catboost.ai/docs/en/concepts/python-reference_catboost_randomized_search.md)



<!-- source: en/_includes/work_src/reusage-python/python__randomized_search--desc.md -->
A simple randomized search on hyperparameters.
<!-- endsource: en/_includes/work_src/reusage-python/python__randomized_search--desc.md -->



### [save_borders](https://catboost.ai/docs/en/concepts/python-reference_catboost_save_borders.md)



<!-- source: en/_includes/work_src/reusage-python/save_model__div_desc.md -->
Save the model borders to a file.
<!-- endsource: en/_includes/work_src/reusage-python/save_model__div_desc.md -->

### [save_model](https://catboost.ai/docs/en/concepts/python-reference_catboost_save_model.md)



<!-- source: en/_includes/work_src/reusage/save_model--purpose.md -->
Save the model to a file.
<!-- endsource: en/_includes/work_src/reusage/save_model--purpose.md -->

### [select_features](https://catboost.ai/docs/en/concepts/python-reference_catboost_select_features.md)



Select the best features from the dataset using the [Recursive Feature Elimination](https://scikit-learn.org/stable/modules/generated/sklearn.feature_selection.RFE.html) algorithm.


### [set_feature_names](https://catboost.ai/docs/en/concepts/python-reference_catboost_set_feature_names.md)



<!-- source: en/_includes/work_src/reusage-python/non_pool__set_feature_names__div.md -->
Set names for all features in the model.
<!-- endsource: en/_includes/work_src/reusage-python/non_pool__set_feature_names__div.md -->



### [set_params](https://catboost.ai/docs/en/concepts/python-reference_catboost_set_params.md)



<!-- source: en/_includes/work_src/reusage/set_params--purpose.md -->
Set the training parameters.
<!-- endsource: en/_includes/work_src/reusage/set_params--purpose.md -->



### [set_scale_and_bias](https://catboost.ai/docs/en/concepts/python-reference_catboost_set_scale_and_bias.md)



<!-- source: en/_includes/work_src/reusage-python/set_scale_and_bias__desc.md -->
Set the scale and bias.
<!-- endsource: en/_includes/work_src/reusage-python/set_scale_and_bias__desc.md -->



### [shrink](https://catboost.ai/docs/en/concepts/python-reference_catboost_shrink.md)



<!-- source: en/_includes/work_src/reusage/shrink__purpose.md -->
Shrink the model. Only trees with indices from the range `[ntree_start, ntree_end)` are kept.
<!-- endsource: en/_includes/work_src/reusage/shrink__purpose.md -->



### [staged_predict](https://catboost.ai/docs/en/concepts/python-reference_catboost_staged_predict.md)



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