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

# catboost.load_pool

```no-highlight
catboost.load_pool(data,
                   label = NULL,
                   cat_features = NULL,
                   column_description = NULL,
                   pairs = NULL,
                   delimiter = "\t",
                   has_header = FALSE,
                   weight = NULL,
                   group_id = NULL,
                   group_weight = NULL,
                   subgroup_id = NULL,
                   pairs_weight = NULL,
                   baseline = NULL,
                   feature_names = NULL,
                   thread_count = -1)
```

## Purpose {#purpose}

<!-- source: en/_includes/work_src/reusage-r/load_pool__purpose.md -->
Load the CatBoost dataset.
<!-- endsource: en/_includes/work_src/reusage-r/load_pool__purpose.md -->


## Arguments {#arguments}
### data

#### Description

A file path, data.frame or matrix with features.

<!-- source: en/_includes/work_src/reusage/data__column-types-descc.md -->
The following column types are supported:
- double
- factor. It is assumed that categorical features are given in this type of columns. A standard CatBoost processing procedure is applied to this type of columns:
    1. The values are converted to strings.
    1. The `ConvertCatFeatureToFloat` function is applied to the resulting string.
<!-- endsource: en/_includes/work_src/reusage/data__column-types-descc.md -->


**Default value**

Required argument

### label


#### Description


The target variables (in other words, the objects' label values) of the dataset.

<!-- source: en/_includes/work_src/reusage/r__this-parameter-is-used-if-the-input-data-format-is-matrix.md -->
This parameter is used if the input data format is matrix or data.frame. Otherwise it must be set to NULL.
<!-- endsource: en/_includes/work_src/reusage/r__this-parameter-is-used-if-the-input-data-format-is-matrix.md -->



**Default value**

NULL

### cat_features


#### Description


A vector of categorical features indices.

The indices are zero-based and can differ from the ones given in the [columns description](https://catboost.ai/docs/en/concepts/input-data_column-descfile.md) file.

If `data` parameter is `data.frame` don't use `cat_features`, categorical features are determined automatically
 from `data.frame` column types.


**Default value**

NULL (it is assumed that all columns are the values of numerical
                    features)

### column_description


#### Description


<!-- source: en/_includes/work_src/reusage/cd-short-desct.md -->
The path to the input file  that contains the [columns description](https://catboost.ai/docs/en/concepts/input-data_column-descfile.md).
<!-- endsource: en/_includes/work_src/reusage/cd-short-desct.md -->



This parameter is used if the data is input from a file.


**Default value**

NULL, it is assumed that the first column in the file with the dataset defines the label value, and the other columns are the values of numerical features.

### pairs


#### Description


A file path, matrix or data.frame with  pairs description 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.

<!-- source: en/_includes/work_src/reusage/learn_pairs__where_is_used.md -->
This information is used for calculation and optimization of [Pairwise metrics](https://catboost.ai/docs/en/concepts/loss-functions-ranking.md).
<!-- endsource: en/_includes/work_src/reusage/learn_pairs__where_is_used.md -->



**Default value**


NULL

<!-- source: en/_includes/work_src/reusage-common-phrases/pairwisemetrics_require_pairs_data.md -->
[Pairwise metrics](https://catboost.ai/docs/en/concepts/loss-functions-ranking.md) require pairs data. If this data is not provided explicitly by specifying this parameter, pairs are generated automatically in each group using object label values.
<!-- endsource: en/_includes/work_src/reusage-common-phrases/pairwisemetrics_require_pairs_data.md -->



### delimiter


#### Description


The delimiter character used to separate the data in the dataset input file.

Only single char delimiters are supported. If the specified value contains more than one character, only the first one is used.

<!-- source: en/_includes/work_src/reusage-formats/note-restriction-delimiter-separated-format.md -->
{% note info %}

Used only if the dataset is given in the [Delimiter-separated values format](https://catboost.ai/docs/en/concepts/input-data_values-file.md).

{% endnote %}
<!-- endsource: en/_includes/work_src/reusage-formats/note-restriction-delimiter-separated-format.md -->


**Default value**

\t

### has_header


#### Description


Read the column names from the first line of the dataset file if this parameter is set.

<!-- source: en/_includes/work_src/reusage-formats/note-restriction-delimiter-separated-format.md -->
{% note info %}

Used only if the dataset is given in the [Delimiter-separated values format](https://catboost.ai/docs/en/concepts/input-data_values-file.md).

{% endnote %}
<!-- endsource: en/_includes/work_src/reusage-formats/note-restriction-delimiter-separated-format.md -->



**Default value**

FALSE

### weight


#### Description

The weights of objects.

**Default value**

NULL

### group_id


#### Description


Group identifiers for all input objects.

<!-- source: en/_includes/work_src/reusage/group-id__desc__group-by-group-id__obligatory__note.md -->
{% note warning %}

All objects in the dataset must be grouped by group identifiers if they are present. I.e., the objects with the same group identifier should follow each other in the dataset.

{% cut "Example" %}

For example, let's assume that the dataset consists of documents $d_{1}, d_{2}, d_{3}, d_{4}, d_{5}$. The corresponding groups are $g_{1}, g_{2}, g_{3}, g_{2}, g_{2}$, respectively. The feature vectors for the given documents are $f_{1}, f_{2}, f_{3}, f_{4}, f_{5}$ respectively. Then the dataset can take the following form:

$\begin{pmatrix} d_{2}&g_{2}&f_{2}\\ d_{4}&g_{2}&f_{4}\\ d_{5}&g_{2}&f_{5}\\ d_{3}&g_{3}&f_{3}\\ d_{1}&g_{1}&f_{1} \end{pmatrix}$

The grouped blocks of lines can be input in any order. For example, the following order is equivalent to the previous one:

$\begin{pmatrix} d_{1}&g_{1}&f_{1}\\ d_{3}&g_{3}&f_{3}\\ d_{2}&g_{2}&f_{2}\\ d_{4}&g_{2}&f_{4}\\ d_{5}&g_{2}&f_{5} \end{pmatrix}$

{% endcut %}

{% endnote %}
<!-- endsource: en/_includes/work_src/reusage/group-id__desc__group-by-group-id__obligatory__note.md -->


**Default value**

NULL

### group_weight


#### Description


<!-- source: en/_includes/work_src/reusage/python__group_weight__first-sentence.md -->
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 1 for all objects in all groups.
<!-- endsource: en/_includes/work_src/reusage/python__group_weight__first-sentence.md -->


<!-- source: en/_includes/work_src/reusage/r__group-and-group-weight__restriction.md -->
{% note alert %}

<!-- source: en/_includes/work_src/reusage/python__group-and-group-weight__restriction__intro.md -->
Only one of the following parameters can be used at a time:
<!-- endsource: en/_includes/work_src/reusage/python__group-and-group-weight__restriction__intro.md -->


- `weight`
- `group_weight`

{% endnote %}
<!-- endsource: en/_includes/work_src/reusage/r__group-and-group-weight__restriction.md -->



**Default value**

NULL

### subgroup_id


#### Description


Subgroup identifiers for all input objects.


**Default value**

NULL

### pairs_weight


#### Description


The weight of each input pair of objects.

<!-- source: en/_includes/work_src/reusage/learn_pairs__where_is_used.md -->
This information is used for calculation and optimization of [Pairwise metrics](https://catboost.ai/docs/en/concepts/loss-functions-ranking.md).
<!-- endsource: en/_includes/work_src/reusage/learn_pairs__where_is_used.md -->


<!-- source: en/_includes/work_src/reusage/python__pairs-weight__default-text.md -->
By default, it is set to 1 for all pairs.
<!-- endsource: en/_includes/work_src/reusage/python__pairs-weight__default-text.md -->


Do not use this parameter if an input file is specified in the `pairs` parameter.


**Default value**

NULL

### baseline


#### Description


A vector of formula values for all input objects. The training starts from these values for all input objects instead of starting from zero.


**Default value**

NULL

### feature_names


#### Description


<!-- source: en/_includes/work_src/reusage/feature_names__desc.md -->
A list of names for each feature in the dataset.
<!-- endsource: en/_includes/work_src/reusage/feature_names__desc.md -->



**Default value**

NULL

### thread_count


#### Description

The number of threads to use while reading the data.
Optimizes the reading time. This parameter doesn't affect the results.


**Default value**

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

## Examples {#example}

<!-- source: en/_includes/work_src/reusage-code-examples/load-from-file.md -->
### Load the model from a file {#load-from-file}

The following example illustrates how to save a trained model to a file and then load it.

```python
from catboost import CatBoostClassifier, Pool

train_data = [[1, 3],
              [0, 4],
              [1, 7]]
train_labels = [1, 0, 1]

# catboost_pool = Pool(train_data, train_labels)

model = CatBoostClassifier(learning_rate=0.03)
model.fit(train_data,
          train_labels,
          verbose=False)

model.save_model("model")

from_file = CatBoostClassifier()

from_file.load_model("model")

```
<!-- endsource: en/_includes/work_src/reusage-code-examples/load-from-file.md -->


<!-- source: en/_includes/work_src/reusage-code-examples/load-from-the-package.md -->
Load the dataset from the CatBoostR package (this dataset is a subset of the [Adult Data Set](http://archive.ics.uci.edu/ml/datasets/adult) distributed through the [UCI Machine Learning Repository](http://archive.ics.uci.edu/ml)):
```r
library(catboost)

pool_path = system.file("extdata",
                        "adult_train.1000",
                        package="catboost")

column_description_vector = rep('numeric', 15)
cat_features <- c(3, 5, 7, 8, 9, 10, 11, 15)
for (i in cat_features)
  column_description_vector[i] <- 'factor'

data <- read.table(pool_path,
                   head = F,
                   sep = "\t",
                   colClasses = column_description_vector,
                   na.strings='NAN')

# Transform categorical features to numerical
for (i in cat_features)
  data[,i] <- as.numeric(factor(data[,i]))

pool <- catboost.load_pool(as.matrix(data[,-target]),
                           label = as.matrix(data[,target]),
                           cat_features = cat_features - 2)
head(pool, 1)[[1]]
```
<!-- endsource: en/_includes/work_src/reusage-code-examples/load-from-the-package.md -->


<!-- source: en/_includes/work_src/reusage-code-examples/load-the-dataset-from-data-frame.md -->
Load the dataset from data.frame:
```r
library(catboost)

train_path = system.file("extdata",
                         "adult_train.1000",
                         package="catboost")
test_path = system.file("extdata",
                        "adult_test.1000",
                        package="catboost")

column_description_vector = rep('numeric', 15)
cat_features <- c(3, 5, 7, 8, 9, 10, 11, 15)
for (i in cat_features)
  column_description_vector[i] <- 'factor'

train <- read.table(train_path,
                    head = F,
                    sep = "\t",
                    colClasses = column_description_vector,
                    na.strings='NAN')
test <- read.table(test_path,
                   head = F,
                   sep = "\t",
                   colClasses = column_description_vector,
                   na.strings='NAN')
target <- c(1)
train_pool <- catboost.load_pool(data=train[,-target],
                                 label = train[,target])
test_pool <- catboost.load_pool(data=test[,-target],
                                label = test[,target])
head(train_pool, 1)[[1]]
head(test_pool, 1)[[1]]
```
<!-- endsource: en/_includes/work_src/reusage-code-examples/load-the-dataset-from-data-frame.md -->
