def test_fit(self): """ optimization test """ self.vc.optimize(verbose=False) params = self.vc.getScales() if self.generate: self.D['params_true'] = params data.dump(self.D,self.dataset) self.generate=False params_true = self.D['params_true'] RV = ((SP.absolute(params)-SP.absolute(params_true))**2).max() self.assertTrue(RV<1e-6)
def test_fit(self): """ optimization test """ self.vc.optimize(verbose=False) params = self.vc.getScales() if self.generate: self.D['params_true'] = params data.dump(self.D, self.dataset) self.generate = False params_true = self.D['params_true'] RV = ((SP.absolute(params) - SP.absolute(params_true))**2).max() self.assertTrue(RV < 1e-6)
def test_fit(self): """ optimization test """ self.vc.optimize(verbose=False) params = self.vc.getScales() if self.generate: self.D['params_true'] = params data.dump(self.D,self.dataset) self.generate=False params_true = self.D['params_true'] RV = ((SP.absolute(params)-SP.absolute(params_true))**2).max() #permit more flexibility, as we set a few values to NAN self.assertTrue(RV<1e-4)
def test_fit(self): """ optimization test """ self.vc.optimize(verbose=False) params = self.vc.getScales() if self.generate: self.D['params_true'] = params data.dump(self.D, self.dataset) self.generate = False params_true = self.D['params_true'] RV = ((SP.absolute(params) - SP.absolute(params_true))**2).max() #permit more flexibility, as we set a few values to NAN self.assertTrue(RV < 1e-4)
def test_fitFast(self): """ optimization test """ self.vc.optimize(fast=True,verbose=False) params = self.vc.getScales() if self.generate: self.D['params_true'] = params data.dump(self.D,self.dataset) self.generate=False params_true = self.D['params_true'] #make sign invariant RV = ((SP.absolute(params)-SP.absolute(params_true))**2).max()<1e-6 self.assertTrue(RV)
def test_fitFast(self): """ optimization test """ self.vc.optimize(fast=True, verbose=False) params = self.vc.getScales() if self.generate: self.D['params_true'] = params data.dump(self.D, self.dataset) self.generate = False params_true = self.D['params_true'] #make sign invariant RV = ((SP.absolute(params) - SP.absolute(params_true))**2).max() < 1e-6 self.assertTrue(RV)
def test_fit(self): """ test fitting """ self.lmmlasso.set_params(alpha=1e-1) self.lmmlasso.fit(self.D['X'], self.D['y'], self.D['K']) params = self.lmmlasso.coef_ yhat = self.lmmlasso.predict(self.D['X'], self.D['K']) if self.generate: self.D['params_true'] = params self.D['yhat'] = yhat data.dump(self.D, self.dataset) self.generate = False params_true = self.D['params_true'] yhat_true = self.D['yhat'] RV = ((SP.absolute(params) - SP.absolute(params_true))**2).max() np.testing.assert_almost_equal(RV, 0., decimal=4) RV = ((SP.absolute(yhat) - SP.absolute(yhat_true))**2).max() np.testing.assert_almost_equal(RV, 0., decimal=2)
def test_fit(self): """ test fitting """ self.lmmlasso.set_params(alpha=1e-1) self.lmmlasso.fit(self.D['X'],self.D['y'],self.D['K']) params = self.lmmlasso.coef_ yhat = self.lmmlasso.predict(self.D['X'],self.D['K']) if self.generate: self.D['params_true'] = params self.D['yhat'] = yhat data.dump(self.D,self.dataset) self.generate=False params_true = self.D['params_true'] yhat_true = self.D['yhat'] RV = ((SP.absolute(params)-SP.absolute(params_true))**2).max() np.testing.assert_almost_equal(RV, 0., decimal=4) RV = ((SP.absolute(yhat)-SP.absolute(yhat_true))**2).max() np.testing.assert_almost_equal(RV, 0., decimal=2)