NumPy RandomLesson 19Free preview
Random Permutation
This lesson is part of NumPy · All levels
Summary
Permutation is used to randomly sort the order of an array element, useful in the division of training and test data. np.random.permutation returns a random copy, whereas np.random.shuffle randomly sort directly to the original array (in place). Both are important to ensure that data is non-sequential when traced to models.
Key points
- Np.random. permutation(n) makes a random version of range(n).
- Returns a copy of the tracked array.
- Np.random.shuffle directly tracks the contents of the array (in place) and does not return the value.
- Data tracking prevents biases from the original order of the dataset.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.