# How to load randomly sampled k% from train set?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-load-randomly-sampled-k-from-train-set%2F29728%3E%5C
**Category:** 🤗Datasets\
**Created:** [January 16, 2023, 5:49am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-load-randomly-sampled-k-from-train-set%2F29728 "2023-01-16T05:49:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![macabdul9](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/macabdul9/32/3302_2.png) [@macabdul9](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmacabdul9)%5C
**Post date:** [January 16, 2023, 5:49am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-load-randomly-sampled-k-from-train-set%2F29728%2F1 "2023-01-16T05:49:00Z")

</div>

How to load randomly sampled k% from train set?

---

<div class="post-metadata">

**Author:** ![lhoestq](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lhoestq/32/64813_2.png) [@lhoestq](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Flhoestq)%5C
**Post date:** [January 23, 2023, 1:49pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-load-randomly-sampled-k-from-train-set%2F29728%2F2 "2023-01-23T13:49:23Z")

</div>

You can `.shuffle()` the dataset and then `.select(range(int(percentage * len(ds))))`
