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

Method test_classifier_uncertainty

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

Source from the content-addressed store, hash-verified

568class TestUncertainties(unittest.TestCase):
569
570 def test_classifier_uncertainty(self):
571 test_cases = (Test(p * np.ones(shape=(k, l)), (1 - p) * np.ones(shape=(k, )))
572 for k in range(1, 100) for l in range(1, 10) for p in np.linspace(0, 1, 11))
573 for case in test_cases:
574 # testing _proba_uncertainty
575 np.testing.assert_almost_equal(
576 modAL.uncertainty._proba_uncertainty(case.input),
577 case.output
578 )
579
580 # fitted estimator
581 fitted_estimator = mock.MockEstimator(
582 predict_proba_return=case.input)
583 np.testing.assert_almost_equal(
584 modAL.uncertainty.classifier_uncertainty(
585 fitted_estimator, np.random.rand(10)),
586 case.output
587 )
588
589 # not fitted estimator
590 not_fitted_estimator = mock.MockEstimator(fitted=False)
591 np.testing.assert_almost_equal(
592 modAL.uncertainty.classifier_uncertainty(
593 not_fitted_estimator, case.input),
594 np.ones(shape=(len(case.output)))
595 )
596
597 def test_classifier_margin(self):
598 test_cases_1 = (Test(p * np.ones(shape=(k, l)), np.zeros(shape=(k,)))

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected