Now, we define a function called sample_points for generating clean input (x, y) pairs. It takes the k parameter as input, which implies a number of (x, y) pairs we want to sample:
def sample_points(k):
x = np.random.rand(k,50)
y = np.random.choice([0, 1], size=k, p=[.5, .5]).reshape([-1,1])
return x,y
The preceding function returns the following output:
x, y = sample_points(10)
print x[0]
print y[0]
[0.69922136 0.77305793 0.72227583 0.45291578 0.52828294 0.65308614 0.77281836 0.59878078 0.71554901 0.51660327 0.65538137 0.25267594 0.13763862 0.12522582 0.16336571 0.87987815 0.64465771 0.86281232 0.24503599 0.85324859 0.62247917 0.58166159 0.47871545 0.75025566 0.87919612 0.49545388 0.31058753 0.66306459 0.34621453 0.56970739 0.84310111 0.08747573 0.48944231 0.50061581 0.86215915 0.3248433 0.01350084 0.23846395 0.91015074 0.04968178 0.59098773 0.74692099 0.92763503 0.16319537 0.69655162 0.20419323 0.58241944 0.15703596 0.76047838 0.93452557] [0]