Shuffle two list at once with same order

前端 未结 6 717
感动是毒
感动是毒 2021-01-30 03:38

I\'m using the nltk library\'s movie_reviews corpus which contains a large number of documents. My task is get predictive performance of these reviews

6条回答
  •  花落未央
    2021-01-30 04:29

    from sklearn.utils import shuffle
    
    a = ['a', 'b', 'c','d','e']
    b = [1, 2, 3, 4, 5]
    
    a_shuffled, b_shuffled = shuffle(np.array(a), np.array(b))
    print(a_shuffled, b_shuffled)
    
    #random output
    #['e' 'c' 'b' 'd' 'a'] [5 3 2 4 1]
    

提交回复
热议问题