survivalpredict.model_selection.Sur_RandomizedSearchCV¶
- class survivalpredict.model_selection.Sur_RandomizedSearchCV(estimator, param_distributions, *, n_iter=10, brier_score_max_time=None, scoring=None, n_jobs=None, refit=True, cv=None, pre_dispatch='2*n_jobs', random_state=None, error_score=nan, return_train_score=False)¶
Survivalpredict’s native randomized search on hyper parameters.
Not all parameter values are tried out, but rather a fixed number of parameter settings is sampled from the specified distributions. The number of parameter settings that are tried is given by n_iter. Like scikit-learn, parallelism is achieved with joblib.
- Parameters:
estimator (estimator object) – Survivalpredict native estimator.
param_distributions (dict | list) – Dictionary with parameters names (str) as keys and distributions or lists of parameters to try. Distributions must provide a rvs method for sampling (such as those from scipy.stats.distributions). If a list is given, it is sampled uniformly. If a list of dicts is given, first a dict is sampled uniformly, and then a parameter is sampled using that dict as above.
n_iter (int, default=10) – Number of parameter settings that are sampled. n_iter trades off runtime vs quality of the solution.
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.
Nonemeans 1 unless in ajoblib.parallel_backendcontext.-1means 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’
random_state (int, RandomState instance or None, default=None) – Pseudo random number generator state used for random uniform sampling from lists of possible values instead of scipy.stats distributions. Pass an int for reproducible output across multiple function calls.
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, thecv_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_distributions, *, n_iter=10, brier_score_max_time=None, scoring=None, n_jobs=None, refit=True, cv=None, pre_dispatch='2*n_jobs', random_state=None, error_score=nan, return_train_score=False)¶
- Parameters:
param_distributions (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_distributions, *)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
fitmethod.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