bootstrap module¶
A bootstrap tool for resampling and surrogate modeling.
- class gemseo.mlearning.resampling.bootstrap.Bootstrap(sample_indices, n_replicates=100, seed=0)[source]¶
Bases:
BaseResampler
A bootstrap tool for resampling and surrogate modeling.
- Parameters:
sample_indices (NDArray[int]) – The original indices of the samples.
n_replicates (int) –
The number of bootstrap replicates.
By default it is set to 100.
seed (int | None) –
The seed to initialize the random generator. If
None
, then fresh, unpredictable entropy will be pulled from the OS.By default it is set to 0.
- execute(model, return_models=False, input_data=None, stack_predictions=True, fit_transformers=True, store_sampling_result=False)¶
Apply the resampling technique to a machine learning model.
- Parameters:
model (BaseMLAlgo) – The machine learning model.
return_models (bool) –
Whether the sub-models resulting from resampling are returned.
By default it is set to False.
input_data (ndarray | None) – The input data for the prediction, if any.
stack_predictions (bool) –
Whether the sub-predictions are stacked per sub-model (first the predictions of the first sub-model, then the prediction of the second sub-model, etc.). This argument is ignored when
input_data
isNone
.By default it is set to True.
fit_transformers (bool) –
Whether to re-fit the transformers.
By default it is set to True.
store_sampling_result (bool) –
Whether to store the sampling results in the attribute
resampling_results
of the original model.By default it is set to False.
- Returns:
First the sub-models resulting from resampling if
return_models
isTrue
then the predictions, either per fold or stacked.- Raises:
ValueError – When the model is neither a supervised algorithm nor a clustering one.
- Return type:
tuple[list[BaseMLAlgo], list[ndarray] | ndarray]
- plot(file_path='', show=True, colors=('b', 'r'))¶
Plot the train-test splits.
- Parameters:
- Returns:
The visualization.
- Return type: