(self)
| 595 | ) |
| 596 | |
| 597 | def test_classifier_margin(self): |
| 598 | test_cases_1 = (Test(p * np.ones(shape=(k, l)), np.zeros(shape=(k,))) |
| 599 | for k in range(1, 100) for l in range(1, 10) for p in np.linspace(0, 1, 11)) |
| 600 | test_cases_2 = (Test(p * np.tile(np.asarray(range(k))+1.0, l).reshape(l, k), |
| 601 | p * np.ones(shape=(l, ))*int(k != 1)) |
| 602 | for k in range(1, 10) for l in range(1, 100) for p in np.linspace(0, 1, 11)) |
| 603 | for case in chain(test_cases_1, test_cases_2): |
| 604 | # _proba_margin |
| 605 | np.testing.assert_almost_equal( |
| 606 | modAL.uncertainty._proba_margin(case.input), |
| 607 | case.output |
| 608 | ) |
| 609 | |
| 610 | # fitted estimator |
| 611 | fitted_estimator = mock.MockEstimator( |
| 612 | predict_proba_return=case.input) |
| 613 | np.testing.assert_almost_equal( |
| 614 | modAL.uncertainty.classifier_margin( |
| 615 | fitted_estimator, np.random.rand(10)), |
| 616 | case.output |
| 617 | ) |
| 618 | |
| 619 | # not fitted estimator |
| 620 | not_fitted_estimator = mock.MockEstimator(fitted=False) |
| 621 | np.testing.assert_almost_equal( |
| 622 | modAL.uncertainty.classifier_margin( |
| 623 | not_fitted_estimator, case.input), |
| 624 | np.zeros(shape=(len(case.output))) |
| 625 | ) |
| 626 | |
| 627 | def test_classifier_entropy(self): |
| 628 | for n_samples in range(1, 100): |
nothing calls this directly
no outgoing calls
no test coverage detected