watex.utils.random_sampling#
- watex.utils.random_sampling(d, /, samples=None, replace=False, random_state=None, shuffle=True)[source]#
Sampling data.
- Parameters
d ({array-like, sparse matrix} of shape (n_samples, n_features)) – Data for sampling, where n_samples is the number of samples and n_features is the number of features.
samples (int,optional) – Ratio or number of items from axis to return. Default = 1 if samples is
None.replace (bool, default=False) – Allow or disallow sampling of the same row more than once.
random_state (int, array-like, BitGenerator, np.random.RandomState, np.random.Generator, optional) – If int, array-like, or BitGenerator, seed for random number generator. If np.random.RandomState or np.random.Generator, use as given.
shuffle (bool, default=True) – Shuffle the data before sampling
- Returns
d ({array-like, sparse matrix} of shape (n_samples, n_features))
samples data based on the given samples.
Examples
>>> from watex.utils.funcutils import random_sampling >>> from watex.datasets import load_hlogs >>> data= load_hlogs().frame >>> random_sampling( data, samples = 7 ).shape (7, 27)