Text features

CatBoost supports numerical, categorical and text features.

Text features are used to build new numeric features. See the Transforming text features to numerical features section for details.

Choose the implementation for details on the methods and/or parameters used that are required to start using text features.

Class / method Parameter Description
text_features

A one-dimensional array of text columns indices (specified as integers) or names (specified as strings).

Use only if the data parameter is a two-dimensional feature matrix (has one of the following types: list, numpy.ndarray, pandas.DataFrame, pandas.Series).

If any elements in this array are specified as names instead of indices, names for all columns must be provided. To do this, either use the feature_names parameter of this constructor to explicitly specify them or pass a pandas.DataFrame with column names specified in the data parameter.

Class / method Parameter Description
text_features

A one-dimensional array of text columns indices (specified as integers) or names (specified as strings).

Use only if the data parameter is a two-dimensional feature matrix (has one of the following types: list, numpy.ndarray, pandas.DataFrame, pandas.Series).

If any elements in this array are specified as names instead of indices, names for all columns must be provided. To do this, either use the feature_names parameter of this constructor to explicitly specify them or pass a pandas.DataFrame with column names specified in the data parameter.

Supported training parameters:

Text processing parameters
tokenizers list of json

Tokenizers used to preprocess Text type feature columns before creating the dictionary.

Format:

[{
'TokenizerId1': <value>,
'option_name_1': <value>,
..
'option_name_N': <value>,}]
Note.

This parameter works with dictionaries and feature_calcers parameters.

For example, if a single tokenizer, three dictionaries and two feature calcers are given, a total of 6 new groups of features are created for each original text feature ().

Usage example.

GPU

dictionaries list of json

Dictionaries used to preprocess Text type feature columns.

Format:

[{
'dictionaryId1': <value>,
'option_name_1': <value>,
..
'option_name_N': <value>,}]
Note.

This parameter works with tokenizers and feature_calcers parameters.

For example, if a single tokenizer, three dictionaries and two feature calcers are given, a total of 6 new groups of features are created for each original text feature ().

Usage example.

GPU

feature_calcers list of strings

Feature calcers used to calculate new features based on preprocessed Text type feature columns.

Format:

['FeatureCalcerName[:option_name=option_value],
]
  • FeatureCalcerName — The required feature calcer.

  • option_name — Additional options for feature calcers. Refer to the list of supported calcers for details on options available for each of them.

Note.

This parameter works with tokenizers and dictionaries parameters.

For example, if a single tokenizer, three dictionaries and two feature calcers are given, a total of 6 new groups of features are created for each original text feature ().

Usage example.

GPU

text_processing json

A JSON specification of tokenizers, dictionaries and feature calcers, which determine how text features are converted into a list of float features.

Example

Refer to the description of the following parameters for details on supported values:

  • tokenizers
  • dictionaries
  • feature_calcers
Restriction.

Do not use this parameter with the following ones:

  • tokenizers
  • dictionaries
  • feature_calcers
Default value

GPU

Text processing parameters
tokenizers list of json

Tokenizers used to preprocess Text type feature columns before creating the dictionary.

Format:

[{
'TokenizerId1': <value>,
'option_name_1': <value>,
..
'option_name_N': <value>,}]
Note.

This parameter works with dictionaries and feature_calcers parameters.

For example, if a single tokenizer, three dictionaries and two feature calcers are given, a total of 6 new groups of features are created for each original text feature ().

Usage example.

GPU

dictionaries list of json

Dictionaries used to preprocess Text type feature columns.

Format:

[{
'dictionaryId1': <value>,
'option_name_1': <value>,
..
'option_name_N': <value>,}]
Note.

This parameter works with tokenizers and feature_calcers parameters.

For example, if a single tokenizer, three dictionaries and two feature calcers are given, a total of 6 new groups of features are created for each original text feature ().

Usage example.

GPU

feature_calcers list of strings

Feature calcers used to calculate new features based on preprocessed Text type feature columns.

Format:

['FeatureCalcerName[:option_name=option_value],
]
  • FeatureCalcerName — The required feature calcer.

  • option_name — Additional options for feature calcers. Refer to the list of supported calcers for details on options available for each of them.

Note.

This parameter works with tokenizers and dictionaries parameters.

For example, if a single tokenizer, three dictionaries and two feature calcers are given, a total of 6 new groups of features are created for each original text feature ().

Usage example.

GPU

text_processing json

A JSON specification of tokenizers, dictionaries and feature calcers, which determine how text features are converted into a list of float features.

Example

Refer to the description of the following parameters for details on supported values:

  • tokenizers
  • dictionaries
  • feature_calcers
Restriction.

Do not use this parameter with the following ones:

  • tokenizers
  • dictionaries
  • feature_calcers
Default value

GPU

Additional classes are provided for text processing:

Class Class purpose
Tokenizer

Tokenize and process the strings.

Dictionary

Process dictionaries. The text must be tokenized before working with dictionaries.

Class Class purpose
Tokenizer

Tokenize and process the strings.

Dictionary

Process dictionaries. The text must be tokenized before working with dictionaries.