(self)
| 462 | consensus_entropy, true_entropy) |
| 463 | |
| 464 | def test_KL_max_disagreement(self): |
| 465 | for n_samples in range(1, 10): |
| 466 | for n_classes in range(2, 10): |
| 467 | for n_learners in range(2, 10): |
| 468 | # 1. fitted committee |
| 469 | vote_proba = np.zeros( |
| 470 | shape=(n_samples, n_learners, n_classes)) |
| 471 | vote_proba[:, :, 0] = 1.0 |
| 472 | committee = mock.MockCommittee( |
| 473 | n_learners=n_learners, classes_=range(n_classes), |
| 474 | vote_proba_return=vote_proba |
| 475 | ) |
| 476 | |
| 477 | true_KL_disagreement = np.zeros(shape=(n_samples, )) |
| 478 | |
| 479 | try: |
| 480 | np.testing.assert_array_almost_equal( |
| 481 | true_KL_disagreement, |
| 482 | modAL.disagreement.KL_max_disagreement( |
| 483 | committee, np.random.rand(n_samples, 1)) |
| 484 | ) |
| 485 | except: |
| 486 | modAL.disagreement.KL_max_disagreement( |
| 487 | committee, np.random.rand(n_samples, 1)) |
| 488 | |
| 489 | # 2. unfitted committee |
| 490 | committee = mock.MockCommittee(fitted=False) |
| 491 | true_KL_disagreement = np.zeros(shape=(n_samples,)) |
| 492 | returned_KL_disagreement = modAL.disagreement.KL_max_disagreement( |
| 493 | committee, np.random.rand(n_samples, n_classes) |
| 494 | ) |
| 495 | np.testing.assert_almost_equal( |
| 496 | returned_KL_disagreement, true_KL_disagreement) |
| 497 | |
| 498 | def test_vote_entropy_sampling(self): |
| 499 | for n_samples, n_features, n_classes in product(range(1, 10), range(1, 10), range(1, 10)): |
nothing calls this directly
no outgoing calls
no test coverage detected