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

Method test_uncertainty_sampling

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

Source from the content-addressed store, hash-verified

655 )
656
657 def test_uncertainty_sampling(self):
658 for n_samples in range(1, 10):
659 for n_classes in range(1, 10):
660 max_proba = np.zeros(n_classes)
661 for true_query_idx in range(n_samples):
662 predict_proba = np.random.rand(n_samples, n_classes)
663 predict_proba[true_query_idx] = max_proba
664 classifier = mock.MockEstimator(
665 predict_proba_return=predict_proba)
666 query_idx, query_metric = modAL.uncertainty.uncertainty_sampling(
667 classifier, np.random.rand(n_samples, n_classes)
668 )
669 shuffled_query_idx, shuffled_query_metric = modAL.uncertainty.uncertainty_sampling(
670 classifier, np.random.rand(n_samples, n_classes),
671 random_tie_break=True
672 )
673 np.testing.assert_array_equal(query_idx, true_query_idx)
674 np.testing.assert_array_equal(
675 shuffled_query_idx, true_query_idx)
676
677 def test_margin_sampling(self):
678 for n_samples in range(1, 10):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected