(self)
| 625 | ) |
| 626 | |
| 627 | def test_classifier_entropy(self): |
| 628 | for n_samples in range(1, 100): |
| 629 | for n_classes in range(1, 20): |
| 630 | proba = np.zeros(shape=(n_samples, n_classes)) |
| 631 | for sample_idx in range(n_samples): |
| 632 | proba[sample_idx, np.random.choice(range(n_classes))] = 1.0 |
| 633 | |
| 634 | # _proba_entropy |
| 635 | np.testing.assert_almost_equal( |
| 636 | modAL.uncertainty._proba_entropy(proba), |
| 637 | np.zeros(shape=(n_samples,)) |
| 638 | ) |
| 639 | |
| 640 | # fitted estimator |
| 641 | fitted_estimator = mock.MockEstimator( |
| 642 | predict_proba_return=proba) |
| 643 | np.testing.assert_equal( |
| 644 | modAL.uncertainty.classifier_entropy( |
| 645 | fitted_estimator, np.random.rand(n_samples, 1)), |
| 646 | np.zeros(shape=(n_samples, )) |
| 647 | ) |
| 648 | |
| 649 | # not fitted estimator |
| 650 | not_fitted_estimator = mock.MockEstimator(fitted=False) |
| 651 | np.testing.assert_almost_equal( |
| 652 | modAL.uncertainty.classifier_entropy( |
| 653 | not_fitted_estimator, np.random.rand(n_samples, 1)), |
| 654 | np.zeros(shape=(n_samples, )) |
| 655 | ) |
| 656 | |
| 657 | def test_uncertainty_sampling(self): |
| 658 | for n_samples in range(1, 10): |
nothing calls this directly
no outgoing calls
no test coverage detected