MCPcopy Create free account
hub / github.com/catboost/catboost / _infer_feature_names

Method _infer_feature_names

catboost/python-package/catboost/core.py:1382–1411  ·  view source on GitHub ↗
(self, data_as_data_frame, embedding_features_data=None, embedding_features=None)

Source from the content-addressed store, hash-verified

1380 )
1381
1382 def _infer_feature_names(self, data_as_data_frame, embedding_features_data=None, embedding_features=None):
1383 non_embedding_data_feature_names = list(data_as_data_frame.columns)
1384
1385 if embedding_features_data is not None:
1386 if isinstance(embedding_features_data, dict):
1387 embedding_feature_names = list(embedding_features_data.keys())
1388 if embedding_features is not None:
1389 if set(embedding_features) != set(embedding_feature_names):
1390 raise CatBoostError('keys of embedding_features_data and embedding_features are different')
1391 return non_embedding_data_feature_names + embedding_feature_names
1392 else:
1393 if embedding_features is None:
1394 raise CatBoostError('embedding_features is not specified but embedding_features_data without feature names is present')
1395 if not all([isinstance(embedding_feature_id, INTEGER_TYPES) for embedding_feature_id in embedding_features]):
1396 raise CatBoostError('embedding_features contain feature names but embedding_features_data without feature names is present')
1397
1398 embedding_features_set = set(embedding_features)
1399
1400 feature_names = []
1401 non_embedding_feature_idx = 0
1402 for feature_idx in range(len(non_embedding_data_feature_names) + len(embedding_features)):
1403 if feature_idx in embedding_features_set:
1404 feature_names.append('_embedding_feature_%i' % feature_idx)
1405 else:
1406 feature_names.append(non_embedding_data_feature_names[non_embedding_feature_idx])
1407 non_embedding_feature_idx += 1
1408
1409 return feature_names
1410 else:
1411 return non_embedding_data_feature_names
1412
1413 def _init(
1414 self,

Callers 1

_initMethod · 0.95

Calls 8

isinstanceFunction · 0.85
lenFunction · 0.85
listClass · 0.50
setFunction · 0.50
CatBoostErrorClass · 0.50
allFunction · 0.50
rangeFunction · 0.50
appendMethod · 0.45

Tested by

no test coverage detected