Exhaustive search over specified parameter values for a model. After calling this method model is fitted and can be used, if not specified otherwise (refit=False). Parameters ---------- param_grid: dict or list of dictionaries Dictionary with par
(self, param_grid, X, y=None, cv=3, 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)
| 4413 | return cv_result |
| 4414 | |
| 4415 | def grid_search(self, param_grid, X, y=None, cv=3, partition_random_seed=0, |
| 4416 | calc_cv_statistics=True, search_by_train_test_split=True, |
| 4417 | refit=True, shuffle=True, stratified=None, train_size=0.8, verbose=True, plot=False, plot_file=None, |
| 4418 | log_cout=None, log_cerr=None): |
| 4419 | """ |
| 4420 | Exhaustive search over specified parameter values for a model. |
| 4421 | After calling this method model is fitted and can be used, if not specified otherwise (refit=False). |
| 4422 | |
| 4423 | Parameters |
| 4424 | ---------- |
| 4425 | param_grid: dict or list of dictionaries |
| 4426 | Dictionary with parameters names (string) as keys and lists of parameter settings |
| 4427 | to try as values, or a list of such dictionaries, in which case the grids spanned by each |
| 4428 | dictionary in the list are explored. |
| 4429 | This enables searching over any sequence of parameter settings. |
| 4430 | |
| 4431 | X: numpy.ndarray or pandas.DataFrame or polars.DataFrame or catboost.Pool |
| 4432 | Data to compute statistics on |
| 4433 | |
| 4434 | y: list or numpy.ndarray or pandas.DataFrame or pandas.Series or polars.DataFrame or polars.Series, optional (default=None) |
| 4435 | Labels of the training data. |
| 4436 | If not None, can be a single- or two- dimensional array with either: |
| 4437 | - numerical values - for regression (including multiregression), ranking and binary classification problems |
| 4438 | - class labels (boolean, integer or string) - for classification (including multiclassification) problems |
| 4439 | Use only if X is not catboost.Pool and does not point to a file. |
| 4440 | |
| 4441 | cv: int, cross-validation generator or an iterable, optional (default=None) |
| 4442 | Determines the cross-validation splitting strategy. Possible inputs for cv are: |
| 4443 | - None, to use the default 3-fold cross validation, |
| 4444 | - integer, to specify the number of folds in a (Stratified)KFold |
| 4445 | - one of the scikit-learn splitter classes |
| 4446 | (https://scikit-learn.org/stable/modules/classes.html#splitter-classes) |
| 4447 | - An iterable yielding (train, test) splits as arrays of indices. |
| 4448 | |
| 4449 | partition_random_seed: int, optional (default=0) |
| 4450 | Use this as the seed value for random permutation of the data. |
| 4451 | Permutation is performed before splitting the data for cross validation. |
| 4452 | Each seed generates unique data splits. |
| 4453 | Used only when cv is None or int. |
| 4454 | |
| 4455 | search_by_train_test_split: bool, optional (default=True) |
| 4456 | If True, source dataset is splitted into train and test parts, models are trained |
| 4457 | on the train part and parameters are compared by loss function score on the test part. |
| 4458 | After that, if calc_cv_statistics=true, statistics on metrics are calculated |
| 4459 | using cross-validation using best parameters and the model is fitted with these parameters. |
| 4460 | |
| 4461 | If False, every iteration of grid search evaluates results on cross-validation. |
| 4462 | It is recommended to set parameter to True for large datasets, and to False for small datasets. |
| 4463 | |
| 4464 | calc_cv_statistics: bool, optional (default=True) |
| 4465 | The parameter determines whether quality should be estimated. |
| 4466 | using cross-validation with the found best parameters. Used only when search_by_train_test_split=True. |
| 4467 | |
| 4468 | refit: bool (default=True) |
| 4469 | Refit an estimator using the best found parameters on the whole dataset. |
| 4470 | |
| 4471 | shuffle: bool, optional (default=True) |
| 4472 | Shuffle the dataset objects before parameters searching. |