def test_orthonormal_update(): forwardPasser = ForwardPasser(X, missing, y[:, numpy.newaxis], numpy.ones(X.shape[0]), numpy.ones(1), max_terms=1000, penalty=1) numpy.set_printoptions(precision=4) m, n = X.shape B_orth = forwardPasser.get_B_orth() v = numpy.random.normal(size=m) for i in range(1, 10): v_ = numpy.random.normal(size=m) B_orth[:, i] = 10 * v_ + v v = v_ forwardPasser.orthonormal_update(i) B_orth_dot_B_orth_T = numpy.dot(B_orth[:, 0:i + 1].transpose(), B_orth[:, 0:i + 1]) assert_true( numpy.max(numpy.abs(B_orth_dot_B_orth_T - numpy.eye(i + 1))) < .0000001)
def test_run(): forwardPasser = ForwardPasser(X, y, numpy.ones(y.shape), max_terms=1000, penalty=1) forwardPasser.run() res = str(forwardPasser.get_basis()) + \ '\n' + str(forwardPasser.trace()) filename = os.path.join(os.path.dirname(__file__), 'forward_regress.txt') with open(filename, 'r') as fl: prev = fl.read() assert_equal(res, prev)
def test_run(): forwardPasser = ForwardPasser(X, missing, y[:, numpy.newaxis], sample_weight, max_terms=1000, penalty=1) forwardPasser.run() res = str(forwardPasser.get_basis()) + \ '\n' + str(forwardPasser.trace()) filename = os.path.join(os.path.dirname(__file__), 'forward_regress.txt') # with open(filename, 'w') as fl: # fl.write(res) with open(filename, 'r') as fl: prev = fl.read() assert_equal(res, prev)