Author - Mohit Rathore mrmohitrathoremr@gmail.com - markroxor.in
Licensed under The MIT License - https://opensource.org/licenses/MIT

In [1]:
import numpy as np

from fromscratchtoml.toolbox.random import Distribution
from fromscratchtoml.toolbox import binary_visualize

%matplotlib inline

Data visualisation

In [2]:
X1 = Distribution.linear(pts=100,
               mean=[5, 10],
               covr=[[1.5, 1], [1, 1.5]])
X2 = Distribution.linear(pts=100,
               mean=[10, 5],
               covr=[[1.5, 1], [1, 1.5]])
X3 = Distribution.linear(pts=100,
               mean=[15, 20],
               covr=[[1.5, 1], [1, 1.5]])

Y1 = np.ones(X1.shape[0])
Y2 = -np.ones(X2.shape[0])
Y3 = 2*np.ones(X3.shape[0])

X = np.vstack((X1, X2, X3))
y = np.vstack((Y1, Y2, Y3))

binary_visualize(X, y)

Creating non linear data from a bunch of linear data points.

In [3]:
X1 = Distribution.linear(pts=50,
               mean=[8, 20],
               covr=[[1.5, 1], [1, 2]])
X2 = Distribution.linear(pts=50,
               mean=[8, 15],
               covr=[[1.5, -1], [-1, 2]])

X3 = Distribution.linear(pts=50,
               mean=[15, 20],
               covr=[[1.5, 1], [1, 2]])
X4 = Distribution.linear(pts=50,
               mean=[15, 15],
               covr=[[1.5, -1], [-1, 2]])

X1 = np.vstack((X1, X2))
X2 = np.vstack((X3, X4))

Y1 = np.ones(X1.shape[0])
Y2 = -np.ones(X2.shape[0])

X = np.vstack((X1, X2))
y = np.vstack((Y1, Y2))

binary_visualize(X, y)

Radial data

In [4]:
X1 = Distribution.radial_binary(pts=1000,
               mean=[0, 0],
               st=1,
               ed=2)
X2 = Distribution.radial_binary(pts=1000,
               mean=[0, 0],
               st=4,
               ed=5)


Y1 = np.ones(X1.shape[0])
Y2 = -np.ones(X2.shape[0])

X = np.vstack((X1, X2))
y = np.vstack((Y1, Y2))

binary_visualize(X, y)

Multi class data visualization

In [5]:
X1 = Distribution.linear(pts=100,
               mean=[6, 10],
               covr=[[1.5, 1], [1, 1.5]])
X2 = Distribution.linear(pts=100,
               mean=[9, 5],
               covr=[[1.5, 1], [1, 1.5]])
X3 = Distribution.linear(pts=100,
               mean=[-9, -5],
               covr=[[1.5, 1], [1, 1.5]])
X4 = Distribution.linear(pts=100,
               mean=[-6, -10],
               covr=[[1.5, 1], [1, 1.5]])

Y1 = -1*np.ones(X1.shape[0])
Y2 = 1*np.ones(X2.shape[0])
Y3 = 2*np.ones(X3.shape[0])
Y4 = 3*np.ones(X4.shape[0])

X = np.vstack((X1, X2, X3 ,X4))
y = np.vstack((Y1, Y2, Y3, Y4))

binary_visualize(X, y)
In [6]:
X1 = Distribution.radial_binary(pts=1000,
               mean=[0, 0],
               st=1,
               ed=2)
X2 = Distribution.radial_binary(pts=1000,
               mean=[0, 0],
               st=4,
               ed=5)
X3 = Distribution.radial_binary(pts=1000,
               mean=[0, 0],
               st=6,
               ed=7)
X4 = Distribution.radial_binary(pts=1000,
               mean=[0, 0],
               st=8,
               ed=9)


Y1 = -np.ones(X1.shape[0])
Y2 = np.ones(X2.shape[0])
Y3 = 2*np.ones(X3.shape[0])
Y4 = 3000*np.ones(X4.shape[0])

X = np.vstack((X1, X2, X3, X4))
y = np.vstack((Y1, Y2, Y3, Y4))

binary_visualize(X, y)