get_feature_names

Return the names of features from the dataset.

Method call format

get_feature_names()

Type of return value

List of strings.

Usage examples

Feature names are not set

import numpy as np
from catboost import FeaturesData

fd = FeaturesData(
    num_feature_data=np.array([[1, 4, 5, 6], [4, 5, 6, 7], [30, 40, 50, 60]], dtype=np.float32),
    cat_feature_data=np.array([["a", "b"], ["a", "b"], ["c", "d"]], dtype=object)
)
# print feature names
# the returned value is ['', '', '', '', '', ''] as neither num_feature_names nor cat_feature_names are specified
print(fd.get_feature_names())

Feature names are set

import numpy as np
from catboost import FeaturesData

fd = FeaturesData(
    num_feature_data=np.array([[1, 4, 5, 6], [4, 5, 6, 7], [30, 40, 50, 60]], dtype=np.float32),
    num_feature_names=['num_feat0', 'num_feat1', 'num_feat2', 'num_feat3'],
    cat_feature_data=np.array([["a", "b"], ["a", "b"], ["c", "d"]], dtype=object),
    cat_feature_names=['cat_feat0', 'cat_feat1']
)
# prints ['num_feat0', 'num_feat1', 'num_feat2', 'num_feat3', 'cat_feat0', 'cat_feat1']
print(fd.get_feature_names())