MCPcopy Create free account
hub / github.com/modAL-python/modAL / test_margin_sampling

Method test_margin_sampling

tests/core_tests.py:677–696  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

675 shuffled_query_idx, true_query_idx)
676
677 def test_margin_sampling(self):
678 for n_samples in range(1, 10):
679 for n_classes in range(2, 10):
680 for true_query_idx in range(n_samples):
681 predict_proba = np.zeros(shape=(n_samples, n_classes))
682 predict_proba[:, 0] = 1.0
683 predict_proba[true_query_idx, 0] = 0.0
684 classifier = mock.MockEstimator(
685 predict_proba_return=predict_proba)
686
687 query_idx, query_metric = modAL.uncertainty.margin_sampling(
688 classifier, np.random.rand(n_samples, n_classes)
689 )
690 shuffled_query_idx, shuffled_query_metric = modAL.uncertainty.margin_sampling(
691 classifier, np.random.rand(n_samples, n_classes),
692 random_tie_break=True
693 )
694 np.testing.assert_array_equal(query_idx, true_query_idx)
695 np.testing.assert_array_equal(
696 shuffled_query_idx, true_query_idx)
697
698 def test_entropy_sampling(self):
699 for n_samples in range(1, 10):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected