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)
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)
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)
def test_minmax_metric(self): qs = QS.MinMax() self.assertEqual(qs.distance_metric, 'euclidean')
def test_distdiv_dyn(self): ent = QS.Entropy() mm = QS.MinMax() qs = QS.DistDivSampler(qs1=ent, qs2=mm, lam="dynamic") self.run_test(qs)
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)
def test_combined_dyn(self): ent = QS.Entropy() mm = QS.MinMax() qs = QS.CombinedSampler(qs1=ent, qs2=mm, beta="dynamic") self.run_test(qs)
def test_minmax(self): qs = QS.MinMax() self.run_test(qs)