np.random.shuffle() से Shuffle करना
shuffle एक array का order in place mix up करता है, cards का एक deck shuffle करने की तरह।
In this page:
Syntax
np.random.shuffle(arr) # in place
np.random.shuffle()
np.random.shuffle एक array के elements को इसकी पहली axis के along, in place rearrange करता है, और None return करता है। इसकी बजाय एक shuffled copy पाने के लिए np.random.permutation इस्तेमाल करें। 2-D arrays के लिए सिर्फ rows move होती हैं, rows के अंदर values नहीं।
Note:
permutation(10) 0 से 9 का एक random ordering देता है, train/test splits के लिए ideal।
उदाहरण: np.random.shuffle()
import numpy as np
np.random.seed(7)
a = np.arange(8)
np.random.shuffle(a)
print(a)
print(np.random.permutation(5))
# Output:
# [2 5 0 6 3 1 4 7]
# [3 4 2 1 0]
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the
view already swaps in the hi_ translation fields (or blanks these
out if untranslated), so this renders correctly for both languages
without a lang_code check here. #}
आम गलतियां
- shuffle के result को assign करना, जो None है
- यह उम्मीद करना कि columns भी shuffle होंगे
- जब आपको एक copy चाहिए था shuffling करना
चैप्टर सारांश
- shuffle array को in place बदलता है
- यह None return करता है
- permutation एक copy return करता है
- सिर्फ पहली axis shuffle होती है
🔒
Chapter Quiz — Complete all 6 topics to unlock
0/6 topics done
Complete these topics first: