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

Method test_vote_entropy

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

Source from the content-addressed store, hash-verified

407class TestDisagreements(unittest.TestCase):
408
409 def test_vote_entropy(self):
410 for n_samples in range(1, 10):
411 for n_classes in range(1, 10):
412 for true_query_idx in range(n_samples):
413 # 1. fitted committee
414 vote_return = np.zeros(
415 shape=(n_samples, n_classes), dtype=np.int16)
416 vote_return[true_query_idx] = np.asarray(
417 range(n_classes), dtype=np.int16)
418 committee = mock.MockCommittee(classes_=np.asarray(
419 range(n_classes)), vote_return=vote_return)
420 vote_entr = modAL.disagreement.vote_entropy(
421 committee, np.random.rand(n_samples, n_classes)
422 )
423 true_entropy = np.zeros(shape=(n_samples, ))
424 true_entropy[true_query_idx] = entropy(
425 np.ones(n_classes)/n_classes)
426 np.testing.assert_array_almost_equal(
427 vote_entr, true_entropy)
428
429 # 2. unfitted committee
430 committee = mock.MockCommittee(fitted=False)
431 true_entropy = np.zeros(shape=(n_samples,))
432 vote_entr = modAL.disagreement.vote_entropy(
433 committee, np.random.rand(n_samples, n_classes)
434 )
435 np.testing.assert_almost_equal(vote_entr, true_entropy)
436
437 def test_consensus_entropy(self):
438 for n_samples in range(1, 10):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected