Beispiel #1
0
def exotic_data_gen(ppc=300):
    #generate concentric rings
    #central: gaussian at 0,0
    #ring: sample from [-pi,pi] uniformly
    #sample from [-r,r] normally
    xvals = np.random.uniform(-5, 5, size=(ppc, ))
    deviations = np.random.normal(0.0, 0.1, size=(ppc, )).reshape((-1, 1))
    yvals = ((25 - xvals**2)**0.5)
    yvals2 = -yvals

    locs = np.array(np.ones((ppc, 2)))
    locs2 = np.ones((ppc, 2))
    locs[:, 0] = xvals
    locs[:, 1] = yvals
    locs2[:, 0] = xvals
    locs2[:, 1] = yvals2

    #move the random deviations
    locs = locs + deviations * locs
    locs2 = locs2 + deviations * locs2
    eye = ndist([0.0, 0.0], [[0.1, 0], [0, 0.1]], (ppc))

    X = np.concatenate([locs, locs2, eye])
    y = np.concatenate(
        [np.zeros((ppc, )),
         np.ones((ppc, )),
         np.ones((ppc, )) * 2])
    return X, y
Beispiel #2
0
def exotic_data_gen(ppc=300):
	#generate concentric rings
	#central: gaussian at 0,0
	#ring: sample from [-pi,pi] uniformly
	#sample from [-r,r] normally
	xvals = np.random.uniform(-5,5,size=(ppc,))
	deviations = np.random.normal(0.0,0.1,size=(ppc,)).reshape((-1,1))
	yvals = ((25-xvals**2)**0.5)
	yvals2 = -yvals
	
	locs = np.array(np.ones((ppc,2)))
	locs2 = np.ones((ppc,2))
	locs[:,0] = xvals
	locs[:,1] = yvals
	locs2[:,0] = xvals
	locs2[:,1] = yvals2
	
	#move the random deviations
	locs = locs + deviations*locs
	locs2 = locs2 + deviations*locs2
	eye = ndist([0.0,0.0],[[0.1,0],[0,0.1]],(ppc))

	X = np.concatenate([locs,locs2,eye])
	y = np.concatenate([np.zeros((ppc,)),np.ones((ppc,)),np.ones((ppc,))*2])
	return X,y
Beispiel #3
0
def gaussian_data_gen(points_per_class=500):
    #generate some data for model evaluation/building
    ppc = points_per_class
    sig = np.array([[.3, 0], [0, .3]])
    #cents = [[-2,0],[2,0],[0,2],[0,-2]]
    cents = [[-2, 0], [0, 2], [2, 0]]
    points, targets = [], []
    for i, c in enumerate(cents):
        targets.append(np.ones((ppc, )) * i)
        points.append(ndist(c, sig, (ppc)))

    X = np.concatenate(points, axis=0)
    y = np.concatenate(targets, axis=0)
    inds = range(X.shape[0])
    np.random.shuffle(inds)
    Xshuf = []
    yshuf = []
    for i in inds:
        Xshuf.append(X[i])
        yshuf.append(y[i])
    Xshuf = np.array(Xshuf)
    yshuf = np.array(yshuf)
    #TODO: handle the bimodal case.
    return Xshuf, yshuf
Beispiel #4
0
def gaussian_data_gen(points_per_class=500):		
	#generate some data for model evaluation/building
	ppc = points_per_class
	sig = np.array([[.3,0],[0,.3]])
	#cents = [[-2,0],[2,0],[0,2],[0,-2]]
	cents= [[-2,0],[0,2],[2,0]]
	points,targets = [],[]
	for i,c in enumerate(cents):
		targets.append(np.ones((ppc,))*i)
		points.append(ndist(c,sig,(ppc)))
		
	X = np.concatenate(points,axis=0)
	y = np.concatenate(targets,axis=0)
	inds = range(X.shape[0])
	np.random.shuffle(inds)
	Xshuf = []
	yshuf = []
	for i in inds:
		Xshuf.append(X[i])
		yshuf.append(y[i])
	Xshuf = np.array(Xshuf)
	yshuf = np.array(yshuf)
	#TODO: handle the bimodal case.
	return Xshuf,yshuf