code: # https://deeplearningcourses.com/c/data-science-supervised-machine-learning-in-python
  # https://www.udemy.com/data-science-supervised-machine-learning-in-python
  from __future__ import print_function, division
  from builtins import range, input
  # Note: you may need to update your version of future
  # sudo pip install -U future
  
  
  import numpy as np
  import pandas as pd
  
  def get_data(limit=None):
      print("Reading in and transforming data...")
      df = pd.read_csv('train.csv')
      data = df.values
      np.random.shuffle(data)
      X = data[:, 1:]
      print(X[4000])
      X = data[:, 1:] / 255.0 # data is from 0..255
      print(X[4000])
      Y = data[:, 0]
      if limit is not None:
          X, Y = X[:limit], Y[:limit]
      return X, Y
  
  def get_xor():
      X = np.zeros((200, 2))
      X[:50] = np.random.random((50, 2)) / 2 + 0.5 # (0.5-1, 0.5-1)
      X[50:100] = np.random.random((50, 2)) / 2 # (0-0.5, 0-0.5)
      X[100:150] = np.random.random((50, 2)) / 2 + np.array([[0, 0.5]]) # (0-0.5, 0.5-1)
      X[150:] = np.random.random((50, 2)) / 2 + np.array([[0.5, 0]]) # (0.5-1, 0-0.5)
      Y = np.array([0]*100 + [1]*100)
      return X, Y
  
  def get_donut():
      N = 200
      R_inner = 5
      R_outer = 10
  
      # distance from origin is radius + random normal
      # angle theta is uniformly distributed between (0, 2pi)
      R1 = np.random.randn(N//2) + R_inner
      theta = 2*np.pi*np.random.random(N//2)
      X_inner = np.concatenate([[R1 * np.cos(theta)], [R1 * np.sin(theta)]]).T
  
      R2 = np.random.randn(N//2) + R_outer
      theta = 2*np.pi*np.random.random(N//2)
      X_outer = np.concatenate([[R2 * np.cos(theta)], [R2 * np.sin(theta)]]).T
  
      X = np.concatenate([ X_inner, X_outer ])
      Y = np.array([0]*(N//2) + [1]*(N//2))
      return X, Y
  
  get_data()
apis: numpy.random.shuffle numpy.zeros pandas.read_csv numpy.random.randn numpy.cos numpy.random.random numpy.array numpy.sin numpy.concatenate