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

Method test_entropy_sampling

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

Source from the content-addressed store, hash-verified

696 shuffled_query_idx, true_query_idx)
697
698 def test_entropy_sampling(self):
699 for n_samples in range(1, 10):
700 for n_classes in range(2, 10):
701 max_proba = np.ones(n_classes)/n_classes
702 for true_query_idx in range(n_samples):
703 predict_proba = np.zeros(shape=(n_samples, n_classes))
704 predict_proba[:, 0] = 1.0
705 predict_proba[true_query_idx] = max_proba
706 classifier = mock.MockEstimator(
707 predict_proba_return=predict_proba)
708
709 query_idx, query_metric = modAL.uncertainty.entropy_sampling(
710 classifier, np.random.rand(n_samples, n_classes)
711 )
712 shuffled_query_idx, shuffled_query_metric = modAL.uncertainty.entropy_sampling(
713 classifier, np.random.rand(n_samples, n_classes),
714 random_tie_break=True
715 )
716 np.testing.assert_array_equal(query_idx, true_query_idx)
717 np.testing.assert_array_equal(
718 shuffled_query_idx, true_query_idx)
719
720
721# PyTorch model for test cases --> Do not change the layers

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected