def test_best_combination(self): isis = ISIS(SIS(gamma=0.5, selector=L0BrutalForce(1e-4)), l0_regulate=False) _ = isis.run(self.x.values, self.y, max_p=4) comb_best, coeff_best, score_best = _best_combination( self.x.values, self.y, np.array([10, 11]), np.array([12, 0])) self.assertArrayEqual(comb_best, [10, 11, 12]) self.assertArrayAlmostEqual(coeff_best, [1, 1, 1]) self.assertAlmostEqual(score_best, 0)
def test_isis(self): # isis = ISIS(SIS(gamma=0.5, selector=L0BrutalForce(1e-4))) # selected = isis.run(self.x.values, self.y, max_p=4) # # np.testing.assert_equal(selected, [10, 11, 12, 4, 5, 6, 0, 3, 2, 8]) # np.testing.assert_equal(selected, [10, 11, 12, 4]) # Test update gamma isis = ISIS(SIS(gamma=0.1, selector=L0BrutalForce(1e-4))) selected = isis.run(self.x.values, self.y, max_p=5) self.assertAlmostEqual(isis.sis.gamma, 0.15) # # np.testing.assert_equal(selected, [10, 11, 12, 4, 5, 6, 0, 3, 2, 8]) np.testing.assert_equal(selected, [10, 11, 12, 5, 0])
def test_evaluate(self): isis = ISIS(SIS(gamma=0.5, selector=L0BrutalForce(1e-4)), l0_regulate=False) _ = isis.run(self.x.values, self.y, max_p=4) mae = isis.evaluate(self.x.values, self.y) self.assertAlmostEqual(mae, 0)
def test_coeff(self): isis = ISIS(SIS(gamma=0.5, selector=L0BrutalForce(1e-4))) coeff = _get_coeff(self.x.values, self.y) self.assertArrayAlmostEqual(coeff[10:], [1, 1, 1])