Skip to content

Is there a way to get a random sample? #3197

Discussion options

You must be logged in to vote

Well, that's just a matter of generating a list of random indices from 0 to nrows - 1 and then using this list in the [i, j, ...] selector as DT[list_of_random_indices, :]. The list_of_random_indices can be easily generated by using the standard Python module random. For instance, random.sample() could be used for this purpose: https://docs.python.org/3/library/random.html#random.sample

If the random samples are needed for K-fold cross validation, then please take a look at the parallel kfold_random() function, that is a part of the datatable.models: https://datatable.readthedocs.io/en/latest/api/models/kfold_random.html

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by argenisleon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants