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

Method test_consensus_entropy

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

Source from the content-addressed store, hash-verified

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):
439 for n_classes in range(2, 10):
440 for true_query_idx in range(n_samples):
441 # 1. fitted committee
442 proba = np.zeros(shape=(n_samples, n_classes))
443 proba[:, 0] = 1.0
444 proba[true_query_idx] = np.ones(n_classes)/n_classes
445 committee = mock.MockCommittee(predict_proba_return=proba)
446 consensus_entropy = modAL.disagreement.consensus_entropy(
447 committee, np.random.rand(n_samples, n_classes)
448 )
449 true_entropy = np.zeros(shape=(n_samples,))
450 true_entropy[true_query_idx] = entropy(
451 np.ones(n_classes) / n_classes)
452 np.testing.assert_array_almost_equal(
453 consensus_entropy, true_entropy)
454
455 # 2. unfitted committee
456 committee = mock.MockCommittee(fitted=False)
457 true_entropy = np.zeros(shape=(n_samples,))
458 consensus_entropy = modAL.disagreement.consensus_entropy(
459 committee, np.random.rand(n_samples, n_classes)
460 )
461 np.testing.assert_almost_equal(
462 consensus_entropy, true_entropy)
463
464 def test_KL_max_disagreement(self):
465 for n_samples in range(1, 10):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected