Exemplo n.º 1
0
 def test_minmax_query_mah(self):
     qs_kwargs = {'metric': 'mahalanobis'}
     qs = QS.MinMax(**qs_kwargs)
     scores = qs.score(*self.args)
     self.assertEqual(scores.shape, self.unlabeled.y.shape)
     self.assertNotIn(np.NaN, scores)
     choice = qs.choose(scores)
     # A difference in sklearn versions cause
     # a different result to be computed.
     if sklearn_ver == version.parse("0.19.0"):
         self.assertEqual(choice, 0)
     else:
         self.assertEqual(choice, 4)
Exemplo n.º 2
0
 def test_combined_dynamic_beta(self):
     qs1 = QS.Entropy()
     qs2 = QS.MinMax()
     beta = 'dynamic'
     qs = QS.CombinedSampler(qs1=qs1,
                             qs2=qs2,
                             beta=beta,
                             choice_metric=np.argmax)
     self.assertEqual(qs.beta, 'dynamic')
     scores = qs.score(*self.args)
     self.assertEqual(scores.shape, self.unlabeled.y.shape)
     self.assertNotIn(np.NaN, scores)
     choice = qs.choose(scores)
     self.assertEqual(choice, 3)
Exemplo n.º 3
0
 def test_minmax_query_mah_singular(self):
     """Singular matrix"""
     qs_kwargs = {'metric': 'mahalanobis'}
     XU = np.array([[5, 5, 5, 5, 5]] * 5)
     XL = np.array([[3, 3, 3, 3, 3]] * 3)
     yU = np.array([0, 1, 0, 1, 0])
     yL = np.array([1, 0, 1])
     U = Data(X=XU, y=yU)
     L = Data(X=XL, y=yL)
     args = [U, L, self.clf]
     qs = QS.MinMax(**qs_kwargs)
     scores = qs.score(*args)
     self.assertEqual(scores.shape, self.unlabeled.y.shape)
     self.assertNotIn(np.NaN, scores)
     choice = qs.choose(scores)
     self.assertEqual(choice, 0)
Exemplo n.º 4
0
 def test_minmax_metric(self):
     qs = QS.MinMax()
     self.assertEqual(qs.distance_metric, 'euclidean')
Exemplo n.º 5
0
 def test_distdiv_dyn(self):
     ent = QS.Entropy()
     mm = QS.MinMax()
     qs = QS.DistDivSampler(qs1=ent, qs2=mm, lam="dynamic")
     self.run_test(qs)
Exemplo n.º 6
0
 def test_distdiv_even(self):
     ent = QS.Entropy()
     mm = QS.MinMax()
     qs = QS.DistDivSampler(qs1=ent, qs2=mm, lam=0.5)
     self.run_test(qs)
Exemplo n.º 7
0
 def test_combined_dyn(self):
     ent = QS.Entropy()
     mm = QS.MinMax()
     qs = QS.CombinedSampler(qs1=ent, qs2=mm, beta="dynamic")
     self.run_test(qs)
Exemplo n.º 8
0
 def test_minmax(self):
     qs = QS.MinMax()
     self.run_test(qs)