In [2]:
# Fix random seed for reproducibility
seed = 7
np.random.seed(seed)

# We need to generate two sets of data
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:\t{}' .format(X.shape))
print('y:\t{}' .format(y.shape))
print(type(X))
print(type(y))

# Spliting data into train and test
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)

# Checking the shape of the input data
print('X_train:\t{}' .format(X_train.shape))
print('y_train:\t{}' .format(y_train.shape))
print('X_test:\t\t{}'.format(X_test.shape))
print('y_test:\t\t{}'.format(y_test.shape))
X:	(2000, 2)
y:	(2000,)
<class 'numpy.ndarray'>
<class 'numpy.ndarray'>
X_train:	(1340, 2)
y_train:	(1340,)
X_test:		(660, 2)
y_test:		(660,)