def test_entropy(self): qs = QS.Entropy() 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, 2)
def test_entropy(self): qs_kwargs = {'model_change': False} qs = QS.Entropy(**qs_kwargs) al = ActiveLearningModel(self.clf, qs, **self.kwargs) scores, choices = al.run(self.train_X, self.test_X, self.train_y, self.test_y) self.assertEqual(scores.shape, (self.ndraws, ))
def test_distdiv(self): qs1 = QS.Entropy() qs2 = QS.MinMax() lam = 0.5 # Gives equal weight to qs1 and qs2, like beta=1 above. qs = QS.DistDivSampler(qs1=qs1, qs2=qs2, lam=lam, choice_metric=np.argmax) 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_combined(self): qs1 = QS.Entropy() qs2 = QS.MinMax() beta = 1 qs = QS.CombinedSampler(qs1=qs1, qs2=qs2, beta=beta, choice_metric=np.argmax) 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_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_entropy(self): qs = QS.Entropy() self.run_test(qs)