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

Function _process_feature_indices

catboost/python-package/catboost/core.py:2491–2527  ·  view source on GitHub ↗
(feature_indices, pool, params, param_name)

Source from the content-addressed store, hash-verified

2489
2490
2491def _process_feature_indices(feature_indices, pool, params, param_name):
2492 if param_name not in params:
2493 return feature_indices
2494
2495 if param_name == 'cat_features':
2496 feature_type_name = 'categorical'
2497 elif param_name == 'text_features':
2498 feature_type_name = 'text'
2499 elif param_name == 'embedding_features':
2500 feature_type_name = 'embedding'
2501 else:
2502 raise CatBoostError('Unknown params_name=' + param_name)
2503
2504 if isinstance(pool, Pool):
2505 feature_indices_from_params = _get_features_indices(params[param_name], pool.get_feature_names())
2506 if param_name == 'cat_features':
2507 feature_indices_from_pool = pool.get_cat_feature_indices()
2508 elif param_name == 'text_features':
2509 feature_indices_from_pool = pool.get_text_feature_indices()
2510 else:
2511 feature_indices_from_pool = pool.get_embedding_feature_indices()
2512
2513 if set(feature_indices_from_pool) != set(feature_indices_from_params):
2514 raise CatBoostError(feature_type_name + " features indices in the model are set to "
2515 + str(feature_indices_from_params) +
2516 " and train dataset " + feature_type_name + " features indices are set to " +
2517 str(feature_indices_from_pool))
2518 elif isinstance(pool, FeaturesData):
2519 raise CatBoostError(
2520 "Categorical features are set in the model. It is not allowed to use FeaturesData type for training dataset.")
2521 else:
2522 if feature_indices is not None and set(feature_indices) != set(params[param_name]):
2523 raise CatBoostError(feature_type_name + " features in the model are set to " + str(params[param_name]) +
2524 ". " + feature_type_name + " features passed to fit function are set to " + str(feature_indices))
2525 feature_indices = params[param_name]
2526 del params[param_name]
2527 return feature_indices
2528
2529
2530class CatBoost(_CatBoostBase):

Callers 1

_prepare_train_paramsMethod · 0.85

Calls 8

isinstanceFunction · 0.85
_get_features_indicesFunction · 0.85
CatBoostErrorClass · 0.50
setFunction · 0.50
strClass · 0.50

Tested by

no test coverage detected