numpy.random.choice()函数用法与应用场景

函数用法

Generates a random sample from a given 1-D array

import numpy
numpy.random.choice(100, 3)

输出:array([83, 80, 65])

numpy.random.choice([1,0.2,7,'c'],2)

输出:array(['c', '0.2'],
      dtype='|S32')

场景应用

ix = np.random.choice(np.arange(len(trainingdata)), batch_size, replace=False)

img=[]

 for i in ix:

        img_array=cv2.imread()

       img.append(img_array)

减配版

numpy.random.randint(low, high=None, size=None)

Return random integers from low (inclusive) to high (exclusive).

最后,排列了解一下

np.random.permutation(10)
array([1, 7, 4, 3, 0, 9, 2, 5, 8, 6])

你可能感兴趣的:(大蛇丸,随机森林)