Shuffle two list at once with same order

前端 未结 6 721
感动是毒
感动是毒 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:32

    I get a easy way to do this

    import numpy as np
    a = np.array([0,1,2,3,4])
    b = np.array([5,6,7,8,9])
    
    indices = np.arange(a.shape[0])
    np.random.shuffle(indices)
    
    a = a[indices]
    b = b[indices]
    # a, array([3, 4, 1, 2, 0])
    # b, array([8, 9, 6, 7, 5])
    

提交回复
热议问题