set_feature_names

Set names for all features in the model.

Method call format

plot_tree(tree_idx, pool=None)

Parameters

feature_names

Description

A one-dimensional array of feature names for each feature. The order and number of specified names must match the ones used in the dataset.

Possible types

  • ndarray
  • list

Default value

Required parameter

Example

The following example outputs the original feature names, changes them and then outputs the updated names.

from catboost import CatBoostClassifier

train_data = [[0, 3],
              [4, 1],
              [8, 1],
              [9, 1]]
train_labels = [0, 0, 1, 1]

model = CatBoostClassifier(loss_function='Logloss')
model.fit(train_data, train_labels, verbose=False)

print("Original feature names:")
print(model.feature_names_)
model.set_feature_names(["feature_1", "feature_2"])
print("Changed feature names:")
print(model.feature_names_)

Output:

Original feature names:
['0', '1']
Changed feature names:
['feature_1', 'feature_2']