Exemplo n.º 1
0
 def setUp(self):
     # Generate fake density
     self.shape = (40, 120)
     self.base = sb.spline_base2d(self.shape[0], self.shape[1], 20, 20, 10)
     self.coef = np.random.random((self.base.shape[0], ))
     self.target = np.dot(self.base.T, self.coef).reshape(self.shape)
     self.target += np.min(self.target.flat)
     self.target = self.target / np.sum(self.target)
     self.csum = np.cumsum(self.target.flat)
Exemplo n.º 2
0
 def setUp(self):
     # Generate fake density
     self.shape = (40,120)
     self.base = sb.spline_base2d(self.shape[0],self.shape[1], 20, 20, 10)  
     self.coef = np.random.random((self.base.shape[0],))
     self.target = np.dot(self.base.T, self.coef).reshape(self.shape)
     self.target += np.min(self.target.flat)
     self.target = self.target /np.sum(self.target)
     self.csum = np.cumsum(self.target.flat)
Exemplo n.º 3
0
 def skip_2Dcosine_fit(self):
     x = np.cos(np.linspace(0,np.pi*2, 99))
     X = np.dot(x[:,np.newaxis],x[:,np.newaxis].T)
     noise = (np.random.random(X.shape)-.5)*0.1
     for num_splines in range(2,20,2):
         splines = sb.spline_base2d(99,99, num_splines, spline_order = 3)
         model =  linear_model.BayesianRidge()
         model.fit(splines.T, (X+noise).flat)
         y = model.predict(splines.T)
         self.assertTrue( np.corrcoef(X+noise, y.reshape(X.shape))[0,1]**2 > 0.7)
Exemplo n.º 4
0
 def skip_2Dcosine_fit(self):
     x = np.cos(np.linspace(0,np.pi*2, 99))
     X = np.dot(x[:,np.newaxis],x[:,np.newaxis].T)
     noise = (np.random.random(X.shape)-.5)*0.1
     for num_splines in range(2,20,2):
         splines = sb.spline_base2d(99,99, num_splines, spline_order = 3)
         model =  linear_model.BayesianRidge()
         model.fit(splines.T, (X+noise).flat)
         y = model.predict(splines.T)
         self.assertTrue( np.corrcoef(X+noise, y.reshape(X.shape))[0,1]**2 > 0.7)