I'm using a threshold vector to create binary values in a 2d numpy array row-wise. Sample code is provided below:
import numpy as np
x = np.random.rand(100000, 200)
coef = np.random.random(x.shape[1])
x = np.array([[1 if x[i,j]>=coef[j] else 0 for j in range(x.shape[1])] for i in range(x.shape[0])])
Is there anyway to make it faster?