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

Method randomized_search

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

Randomized search on hyper parameters. After calling this method model is fitted and can be used, if not specified otherwise (refit=False). In contrast to grid_search, not all parameter values are tried out, but rather a fixed number of parameter settings is sampled

(self, param_distributions, X, y=None, cv=3, n_iter=10, partition_random_seed=0,
                          calc_cv_statistics=True, search_by_train_test_split=True, refit=True,
                          shuffle=True, stratified=None, train_size=0.8, verbose=True, plot=False, plot_file=None,
                          log_cout=None, log_cerr=None)

Source from the content-addressed store, hash-verified

4520 )
4521
4522 def randomized_search(self, param_distributions, X, y=None, cv=3, n_iter=10, partition_random_seed=0,
4523 calc_cv_statistics=True, search_by_train_test_split=True, refit=True,
4524 shuffle=True, stratified=None, train_size=0.8, verbose=True, plot=False, plot_file=None,
4525 log_cout=None, log_cerr=None):
4526 """
4527 Randomized search on hyper parameters.
4528 After calling this method model is fitted and can be used, if not specified otherwise (refit=False).
4529
4530 In contrast to grid_search, not all parameter values are tried out,
4531 but rather a fixed number of parameter settings is sampled from the specified distributions.
4532 The number of parameter settings that are tried is given by n_iter.
4533
4534 Parameters
4535 ----------
4536 param_distributions: dict
4537 Dictionary with parameters names (string) as keys and distributions or lists of parameters to try.
4538 Distributions must provide a rvs method for sampling (such as those from scipy.stats.distributions).
4539 If a list is given, it is sampled uniformly.
4540
4541 X: numpy.ndarray or pandas.DataFrame or polars.DataFrame or catboost.Pool
4542 Data to compute statistics on
4543
4544 y: list or numpy.ndarray or pandas.DataFrame or pandas.Series or polars.DataFrame or polars.Series, optional (default=None)
4545 Labels of the training data.
4546 If not None, can be a single- or two- dimensional array with either:
4547 - numerical values - for regression (including multiregression), ranking and binary classification problems
4548 - class labels (boolean, integer or string) - for classification (including multiclassification) problems
4549 Use only if X is not catboost.Pool and does not point to a file.
4550
4551 cv: int, cross-validation generator or an iterable, optional (default=None)
4552 Determines the cross-validation splitting strategy. Possible inputs for cv are:
4553 - None, to use the default 3-fold cross validation,
4554 - integer, to specify the number of folds in a (Stratified)KFold
4555 - one of the scikit-learn splitter classes
4556 (https://scikit-learn.org/stable/modules/classes.html#splitter-classes)
4557 - An iterable yielding (train, test) splits as arrays of indices.
4558
4559 n_iter: int
4560 Number of parameter settings that are sampled.
4561 n_iter trades off runtime vs quality of the solution.
4562
4563 partition_random_seed: int, optional (default=0)
4564 Use this as the seed value for random permutation of the data.
4565 Permutation is performed before splitting the data for cross validation.
4566 Each seed generates unique data splits.
4567 Used only when cv is None or int.
4568
4569 search_by_train_test_split: bool, optional (default=True)
4570 If True, source dataset is splitted into train and test parts, models are trained
4571 on the train part and parameters are compared by loss function score on the test part.
4572 After that, if calc_cv_statistics=true, statistics on metrics are calculated
4573 using cross-validation using best parameters and the model is fitted with these parameters.
4574
4575 If False, every iteration of grid search evaluates results on cross-validation.
4576 It is recommended to set parameter to True for large datasets, and to False for small datasets.
4577
4578 calc_cv_statistics: bool, optional (default=True)
4579 The parameter determines whether quality should be estimated.

Calls 5

_tune_hyperparamsMethod · 0.95
isinstanceFunction · 0.85
hasattrFunction · 0.85
CatBoostErrorClass · 0.50
formatMethod · 0.45