Generate data points

Now, we define a function called sample_points for generating our input (x, y) pairs. It takes the k parameter as input, which implies the 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.537339 0.113621 0.62983308 0.3016117 0.91174146 0.95787598 0.20520229 0.123301 0.64143809 0.68485511 0.29509309 0.65719205 0.60906626 0.56890899 0.82614517 0.4408421 0.48018921 0.82674918 0.37076319 0.56239926 0.47655734 0.16489053 0.79742579 0.57731408 0.62065454 0.70110719 0.61330581 0.84084355 0.7967645 0.84148374 0.04915798 0.31650656 0.64326928 0.20878387 0.29682973 0.34488916 0.54626642 0.35608015 0.37950982 0.42281464 0.62984657 0.46538511 0.84092615 0.38056331 0.21669412 0.44118415 0.65537459 0.2136067 0.72679706 0.22969462] [1]
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.93.12