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

Method _prepare_train_params

catboost/python-package/catboost/core.py:2564–2687  ·  view source on GitHub ↗
(self, X=None, y=None, cat_features=None, text_features=None, embedding_features=None,
                              pairs=None, graph=None, sample_weight=None, group_id=None, group_weight=None, subgroup_id=None,
                              pairs_weight=None, baseline=None, use_best_model=None, eval_set=None, verbose=None,
                              logging_level=None, plot=None, plot_file=None, column_description=None, verbose_eval=None,
                              metric_period=None, silent=None, early_stopping_rounds=None, save_snapshot=None,
                              snapshot_file=None, snapshot_interval=None, init_model=None, callbacks=None)

Source from the content-addressed store, hash-verified

2562 )
2563
2564 def _prepare_train_params(self, X=None, y=None, cat_features=None, text_features=None, embedding_features=None,
2565 pairs=None, graph=None, sample_weight=None, group_id=None, group_weight=None, subgroup_id=None,
2566 pairs_weight=None, baseline=None, use_best_model=None, eval_set=None, verbose=None,
2567 logging_level=None, plot=None, plot_file=None, column_description=None, verbose_eval=None,
2568 metric_period=None, silent=None, early_stopping_rounds=None, save_snapshot=None,
2569 snapshot_file=None, snapshot_interval=None, init_model=None, callbacks=None):
2570 params = deepcopy(self._get_canonized_params())
2571
2572 if isinstance(X, FeaturesData):
2573 warnings.warn("FeaturesData is deprecated for using in fit function "
2574 "and soon will not be supported. If you want to use FeaturesData, "
2575 "please pass it to Pool initialization and use Pool in fit")
2576
2577 cat_features = _process_feature_indices(cat_features, X, params, 'cat_features')
2578 text_features = _process_feature_indices(text_features, X, params, 'text_features')
2579 embedding_features = _process_feature_indices(embedding_features, X, params, 'embedding_features')
2580
2581 train_pool = _build_train_pool(X, y, cat_features, text_features, embedding_features, pairs, graph,
2582 sample_weight, group_id, group_weight, subgroup_id, pairs_weight,
2583 baseline, column_description)
2584 if train_pool.is_empty_:
2585 raise CatBoostError("X is empty.")
2586
2587 allow_clear_pool = not isinstance(X, Pool)
2588
2589 params['loss_function'] = _get_loss_function_for_train(
2590 params,
2591 getattr(self, '_estimator_type', None),
2592 train_pool
2593 )
2594
2595 metric_period, verbose, logging_level = _process_verbose(
2596 metric_period, verbose, logging_level, verbose_eval, silent)
2597
2598 if metric_period is not None:
2599 params['metric_period'] = metric_period
2600 if logging_level is not None:
2601 params['logging_level'] = logging_level
2602 if verbose is not None:
2603 params['verbose'] = verbose
2604 if use_best_model is not None:
2605 params['use_best_model'] = use_best_model
2606
2607 if early_stopping_rounds is not None:
2608 params['od_type'] = 'Iter'
2609 params['od_wait'] = early_stopping_rounds
2610 if 'od_pval' in params:
2611 del params['od_pval']
2612
2613 if save_snapshot is not None:
2614 params['save_snapshot'] = save_snapshot
2615
2616 if snapshot_file is not None:
2617 params['snapshot_file'] = snapshot_file
2618
2619 if snapshot_interval is not None:
2620 params['snapshot_interval'] = snapshot_interval
2621

Callers 3

_fitMethod · 0.95
_tune_hyperparamsMethod · 0.95
select_featuresMethod · 0.95

Calls 15

get_paramMethod · 0.95
isinstanceFunction · 0.85
_process_feature_indicesFunction · 0.85
_build_train_poolFunction · 0.85
getattrFunction · 0.85
_process_verboseFunction · 0.85
_check_param_typesFunction · 0.85
_params_type_castFunction · 0.85
lenFunction · 0.85

Tested by

no test coverage detected