()
| 32 | |
| 33 | |
| 34 | def get_spiral(): |
| 35 | # Idea: radius -> low...high |
| 36 | # (don't start at 0, otherwise points will be "mushed" at origin) |
| 37 | # angle = low...high proportional to radius |
| 38 | # [0, 2pi/6, 4pi/6, ..., 10pi/6] --> [pi/2, pi/3 + pi/2, ..., ] |
| 39 | # x = rcos(theta), y = rsin(theta) as usual |
| 40 | |
| 41 | radius = np.linspace(1, 10, 100) |
| 42 | thetas = np.empty((6, 100)) |
| 43 | for i in range(6): |
| 44 | start_angle = np.pi*i / 3.0 |
| 45 | end_angle = start_angle + np.pi / 2 |
| 46 | points = np.linspace(start_angle, end_angle, 100) |
| 47 | thetas[i] = points |
| 48 | |
| 49 | # convert into cartesian coordinates |
| 50 | x1 = np.empty((6, 100)) |
| 51 | x2 = np.empty((6, 100)) |
| 52 | for i in range(6): |
| 53 | x1[i] = radius * np.cos(thetas[i]) |
| 54 | x2[i] = radius * np.sin(thetas[i]) |
| 55 | |
| 56 | # inputs |
| 57 | X = np.empty((600, 2)) |
| 58 | X[:,0] = x1.flatten() |
| 59 | X[:,1] = x2.flatten() |
| 60 | |
| 61 | # add noise |
| 62 | X += np.random.randn(600, 2)*0.5 |
| 63 | |
| 64 | # targets |
| 65 | Y = np.array([0]*100 + [1]*100 + [0]*100 + [1]*100 + [0]*100 + [1]*100) |
| 66 | return X, Y |
| 67 | |
| 68 | |
| 69 |
no outgoing calls
no test coverage detected