ray.data.Dataset.random_sample
ray.data.Dataset.random_sample#
- Dataset.random_sample(fraction: float, *, seed: Optional[int] = None) ray.data.dataset.Dataset[source]#
Returns a new
Datasetcontaining a random fraction of the rows.Note
This method returns roughly
fraction * total_rowsrows. An exact number of rows isn’t guaranteed.Examples
>>> import ray >>> ds = ray.data.range(100) >>> ds.random_sample(0.1).count() 10
- Parameters
fraction – The fraction of elements to sample.
seed – Seeds the python random pRNG generator.
- Returns
Returns a
Datasetcontaining the sampled rows.