--- /dev/null
+#!/usr/bin/env python3
+
+# -*- coding: utf-8 -*-
+import numpy as np
+from numpy.random import rand
+import pylab as pl
+
+
+def generateData(n):
+ """
+ Generates a 2D linearly separable dataset with 2n samples.
+ The third element of the sample is the label
+ """
+ xb = (rand(n) * 2 - 1) / 2 - 0.6
+ yb = (rand(n) * 2 - 1) / 2 + 0.6
+ xr = (rand(n) * 2 - 1) / 2 + 0.6
+ yr = (rand(n) * 2 - 1) / 2 - 0.6
+ inputs = []
+ for i in range(n):
+ inputs.append([xb[i], yb[i], -1])
+ inputs.append([xr[i], yr[i], 1])
+ return inputs
+
+
+training_set = generateData(100)
+data = np.array(training_set)
+X = data[:, 0:2]
+Y = data[:, -1]
+
+pl.scatter(X[:, 0], X[:, 1], c=Y, s=100)
+pl.show()