def test_margin_sampling_notarray(): probs = [0.5, 0.5] with pytest.raises(ValueError) as excinfo: margin_sampling(probs) assert 'Probs should be a numpy array' in str(excinfo.value)
def test_margin_sampling_binary(): probs = np.array([0.2, 0.8]) ms = margin_sampling(probs) np.testing.assert_almost_equal(ms, 0.6)
def test_margin_sampling_threeclass(): probs = np.array([0.1, 0.3, 0.6]) ms = margin_sampling(probs) np.testing.assert_almost_equal(ms, 0.3)
def test_margin_sampling_fourclass(): probs = np.array([0.1, 0.1, 0.1, 0.7]) ms = margin_sampling(probs) np.testing.assert_almost_equal(ms, 0.6)