MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / get_donut

Function get_donut

supervised_class/util.py:32–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30 return X, Y
31
32def get_donut():
33 N = 200
34 R_inner = 5
35 R_outer = 10
36
37 # distance from origin is radius + random normal
38 # angle theta is uniformly distributed between (0, 2pi)
39 R1 = np.random.randn(N//2) + R_inner
40 theta = 2*np.pi*np.random.random(N//2)
41 X_inner = np.concatenate([[R1 * np.cos(theta)], [R1 * np.sin(theta)]]).T
42
43 R2 = np.random.randn(N//2) + R_outer
44 theta = 2*np.pi*np.random.random(N//2)
45 X_outer = np.concatenate([[R2 * np.cos(theta)], [R2 * np.sin(theta)]]).T
46
47 X = np.concatenate([ X_inner, X_outer ])
48 Y = np.array([0]*(N//2) + [1]*(N//2))
49 return X, Y

Callers 1

knn_donut.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected