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

Function _get_features_indices

catboost/python-package/catboost/core.py:311–336  ·  view source on GitHub ↗

Parameters ---------- features : must be a sequence of either integers or strings if it contains strings 'feature_names' parameter must be defined and string ids from 'features' must represent a subset of in 'feature_names' featur

(features, feature_names)

Source from the content-addressed store, hash-verified

309
310
311def _get_features_indices(features, feature_names):
312 """
313 Parameters
314 ----------
315 features :
316 must be a sequence of either integers or strings
317 if it contains strings 'feature_names' parameter must be defined and string ids from 'features'
318 must represent a subset of in 'feature_names'
319
320 feature_names :
321 A sequence of string ids for features or None.
322 Used to get feature indices for string ids in 'features' parameter
323 """
324 if (not isinstance(features, (Sequence, np.ndarray))) or isinstance(features, (str, bytes, bytearray)):
325 raise CatBoostError("feature names should be a sequence, but got " + repr(features))
326 if feature_names is not None:
327 return [
328 feature_names.index(f) if isinstance(f, STRING_TYPES) else f
329 for f in features
330 ]
331 else:
332 for f in features:
333 if isinstance(f, STRING_TYPES):
334 raise CatBoostError("features parameter contains string value '{}' but feature names "
335 "for a dataset are not specified".format(f))
336 return features
337
338
339def _update_params_quantize_part(params, ignored_features, per_float_feature_quantization, border_count,

Callers 3

_initMethod · 0.85
_process_feature_indicesFunction · 0.85
cvFunction · 0.85

Calls 5

isinstanceFunction · 0.85
reprFunction · 0.85
CatBoostErrorClass · 0.50
indexMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected