예제 #1
0
 def test_sparse_logreg_all_positive_labels_warning(self):
     b = np.array([0., 1.0, 0.5])
     A = np.zeros((3, 3))
     with captured_output() as out:
         prob = blitzml.SparseLogisticRegressionProblem(A, b)
     message = out[0]
     self.assertIn("Warning", message)
예제 #2
0
 def test_sparse_logreg_bad_label_too_small(self):
     b = np.array([-1., 0., -2.])
     A = np.zeros((3, 3))
     with captured_output() as out:
         prob = blitzml.SparseLogisticRegressionProblem(A, b)
     message = out[0]
     self.assertIn("Warning", message)
예제 #3
0
 def test_sparse_logreg_bad_initial_conditions(self):
   n = 7
   d = 3
   A = np.arange(n * d).reshape(n, d)
   b = normalize_labels(np.arange(n), True)
   prob = blitzml.SparseLogisticRegressionProblem(A, b)
   lammax = prob.compute_max_l1_penalty()
   weights0 = -1 * np.arange(d)
   lam = 0.02 * lammax
   sol = prob.solve(lam, initial_weights=weights0, stopping_tolerance=1e-6)
   self.assertEqual(is_solution(sol, A, b, lam), True)
예제 #4
0
 def test_sparse_logreg_good_initial_conditions(self):
     n = 9
     d = 21
     np.random.seed(0)
     A = np.random.randn(n, d)
     b = normalize_labels(np.random.randn(n), True)
     prob = blitzml.SparseLogisticRegressionProblem(A, b)
     lammax = prob.compute_max_l1_penalty()
     lam = 0.03 * lammax
     sol0 = prob.solve(lam, stopping_tolerance=1e-4, max_time=1.0)
     sol = prob.solve(lam, initial_weights=sol0.weights, max_time=-1.0)
     self.assertEqual(is_solution(sol, A, b, lam), True)
예제 #5
0
 def make_prob():
     prob = blitzml.SparseLogisticRegressionProblem(A, b)