Resample arrays or sparse matrices in a consistent way.
The default strategy implements one step of the bootstrapping
procedure.
Parameters:
*arrays : sequence of array-like of shape (n_samples,) or (n_samples, n_outputs)
Indexable data-structures can be arrays, lists, dataframes or scipy
sparse matrices with consistent first dimension.
replace : bool, default=True
Implements resampling with replacement. It must be set to True
whenever sampling with non-uniform weights: a few data points with very large
weights are expected to be sampled several times with probability to preserve
the distribution induced by the weights. If False, this will implement
(sliced) random permutations.
n_samples : int, default=None
Number of samples to generate. If left to None this is
automatically set to the first dimension of the arrays.
If replace is False it should not be larger than the length of
arrays.
random_state : int, RandomState instance or None, default=None
Determines random number generation for shuffling
the data.
Pass an int for reproducible results across multiple function calls.
See Glossary.
stratify : {array-like, sparse matrix} of shape (n_samples,) or (n_samples, n_outputs), default=None
If not None, data is split in a stratified fashion, using this as
the class labels.
sample_weight : array-like of shape (n_samples,), default=None
Contains weight values to be associated with each sample. Values are
normalized to sum to one and interpreted as probability for sampling
each data point.
Returns:
resampled_arrays : sequence of array-like of shape (n_samples,) or (n_samples, n_outputs)
Sequence of resampled copies of the collections. The original arrays
are not impacted.
Examples
It is possible to mix sparse and dense arrays in the same run: