survivalpredict.model_selection.Sur_GridSearchCV

class survivalpredict.model_selection.Sur_GridSearchCV(estimator, param_grid, *, brier_score_max_time=None, scoring=None, n_jobs=None, refit=True, cv=None, pre_dispatch='2*n_jobs', error_score=nan, return_train_score=False)

Survivalpredict’s native exhaustive search over specified parameter values for an estimator.

The parameters of the estimator used to apply these methods are optimized by cross-validated grid-search over a parameter grid. Like scikit-learn, parallelism is achieved with joblib.

Parameters:
  • estimator (estimator object) – Survivalpredict native estimator.

  • param_grid (dict | list) – Dictionary with parameters names (str) as keys and lists of parameter settings to try as values, or a list of such dictionaries, in which case the grids spanned by each dictionary in the list are explored. This enables searching over any sequence of parameter settings.

  • brier_score_max_time (Optional[int], default=None) – Maximum time to evaluate survival curves for brier scores. If None, will evaluate all times seen.

  • scoring (Optional[Literal["integrated_brier_score_administrative", "integrated_brier_score_ipcw"] | Callable], default=None) – Strategy to evaluate the performance of the cross-validated model on the test set.

  • n_jobs (int, default=None) – Number of jobs to run in parallel. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.

  • refit (bool, str, or callable, default=True) – Refit an estimator using the best found parameters on the whole dataset.

  • cv (int, cross-validation generator or an iterable, default=None) –

    Determines the cross-validation splitting strategy. Fully compatible with scikit-learn CV components.

    Controls the number of jobs that get dispatched during parallel execution. Reducing this number can be useful to avoid an explosion of memory consumption when more jobs get dispatched than CPUs can process. This parameter can be:

    • None, in which case all the jobs are immediately created and spawned. Use this for lightweight and fast-running jobs, to avoid delays due to on-demand spawning of the jobs

    • An int, giving the exact number of total jobs that are spawned

    • A str, giving an expression as a function of n_jobs, as in ‘2*n_jobs’

  • pre_dispatch (int, or str, default="2*n_jobs") –

    Controls the number of jobs that get dispatched during parallel execution. Reducing this number can be useful to avoid an explosion of memory consumption when more jobs get dispatched than CPUs can process. This parameter can be:

    • None, in which case all the jobs are immediately created and spawned. Use this for lightweight and fast-running jobs, to avoid delays due to on-demand spawning of the jobs

    • An int, giving the exact number of total jobs that are spawned

    • A str, giving an expression as a function of n_jobs, as in ‘2*n_jobs’

  • error_score ('raise' or numeric, default=np.nan) – Value to assign to the score if an error occurs in estimator fitting. If set to ‘raise’, the error is raised. If a numeric value is given, FitFailedWarning is raised. This parameter does not affect the refit step, which will always raise the error.

  • return_train_score (bool, default=False) – If False, the cv_results_ attribute will not include training scores. Computing training scores is used to get insights on how different parameter settings impact the overfitting/underfitting trade-off. However computing the scores on the training set can be computationally expensive and is not strictly required to select the parameters that yield the best generalization performance.

Methods

fit(X, times, events[, strata, times_start])

Run fit with sets of parameters.

__init__(estimator, param_grid, *, brier_score_max_time=None, scoring=None, n_jobs=None, refit=True, cv=None, pre_dispatch='2*n_jobs', error_score=nan, return_train_score=False)
Parameters:
  • param_grid (dict | list)

  • brier_score_max_time (int | None)

  • scoring (Literal['integrated_brier_score_administrative', 'integrated_brier_score_ipcw'] | ~typing.Callable | None)

Methods

__init__(estimator, param_grid, *[, ...])

fit(X, times, events[, strata, times_start])

Run fit with sets of parameters.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

set_fit_request(*[, events, strata, times, ...])

Configure whether metadata should be requested to be passed to the fit method.

set_params(**params)

Set the parameters of this estimator.

fit(X, times, events, strata=None, times_start=None)

Run fit with sets of parameters.

Parameters:
  • X (array-like of shape (n_samples, n_features)) – Training data.

  • times (array-like of shape (n_samples), dtype=np.int64) – Point in time last observed.

  • events (array-like of shape (n_samples), dtype=np.bool_) – Experianed event.

  • strata (array-like of shape (n_samples,), dtype=np.int64, default=None) – If passed in, associated strata for per observation.

  • times_start (array-like of shape (n_samples, dtype=np.int64), default=None) – Starting point for observation. If not passed in, all times_start times are assumed to be 0.

Returns:

Instance of fitted estimator.

Return type:

object