seed = 7
np.random.seed(seed)
def spirals(points, noise=.5):
n = np.sqrt(np.random.rand(points,1)) * 780 * (2*np.pi)/360
d1x = -np.cos(n)*n + np.random.rand(points,1) * noise
d1y = np.sin(n)*n + np.random.rand(points,1) * noise
return (np.vstack((np.hstack((d1x,d1y)),np.hstack((-d1x,-d1y)))),
np.hstack((np.zeros(points),np.ones(points))))
X, y = spirals(1000)
print(X.shape)
print(y.shape)
print(type(X))
print(type(y))
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)