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
Dataset
containing a random fraction of the rows.Note
This method returns roughly
fraction * total_rows
rows. 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
Dataset
containing the sampled rows.