def test_reg_cost_func_data2_3(self, data2): y = data2[:, -1:] X = data2[:, :-1] m, n = X.shape intercept = ones((m, 1), dtype=float64) X = append(intercept, X, axis=1) theta = array([[-25.3], [32], [7.8]]) _lambda = 1000000 assert_allclose([[43514185803.375198]], reg_cost_func(X, y, theta, _lambda), rtol=0, atol=0.001)
def test_reg_cost_func_data1_3(self, data1): y = data1[:, -1:] X = data1[:, :-1] m, n = X.shape intercept = ones((m, 1), dtype=float64) X = append(intercept, X, axis=1) theta = array([[-1], [2]]) _lambda = 750 assert_allclose([[69.706373]], reg_cost_func(X, y, theta, _lambda), rtol=0, atol=0.001)
def test_reg_cost_func_data2_2(self, data2): y = data2[:, -1:] X = data2[:, :-1] m, n = X.shape intercept = ones((m, 1), dtype=float64) X = append(intercept, X, axis=1) theta = ones((n + 1, 1), dtype=float64) _lambda = 1000000 assert_allclose([[64828218577.393623]], reg_cost_func(X, y, theta, _lambda), rtol=0, atol=0.001)
def test_reg_cost_func_data1_1(self, data1): y = data1[:, -1:] X = data1[:, :-1] m, n = X.shape intercept = ones((m, 1), dtype=float64) X = append(intercept, X, axis=1) theta = ones((n + 1, 1), dtype=float64) _lambda = 0 assert_allclose([[10.266]], reg_cost_func(X, y, theta, _lambda), rtol=0, atol=0.001)
def J(theta): return reg_cost_func(X, y, theta, _lambda)