def test_b3_raise_error(): """Test the raise of the ValueError exception for paired P/R/F.""" y = np.array([1, 2, 1, 3, 2, 4, 5, 4]) # test raise when not 1d shape y = y.reshape(2, 4) with pytest.raises(ValueError): b3_precision_recall_fscore(y, y) # test raise when different size of elements y = y.reshape(8, 1) with pytest.raises(ValueError): b3_precision_recall_fscore(y[1:], y[2:]) # test error raise when labels_true is empty with pytest.raises(ValueError): b3_precision_recall_fscore(y, []) # test error raise when labels_pred is empty with pytest.raises(ValueError): b3_precision_recall_fscore([], y) # test error raise when both inputs are empty with pytest.raises(ValueError): b3_precision_recall_fscore([], [])
def test_b3_label_invariability(): """Test that paired P/R/F values are label invariant.""" y = [1, 2, 1, 3, 2, 4, 5, 4] y_prime_invariant = [3, 6, 6, 5, 6, 2, 4, 2] y_prime = [2, 3, 3, 4, 3, 5, 1, 5] assert_equal(b3_precision_recall_fscore(y, y_prime), b3_precision_recall_fscore(y, y_prime_invariant))
def test_b3_raise_error(): """Test the raise of the ValueError exception for paired P/R/F.""" y = np.array([1, 2, 1, 3, 2, 4, 5, 4]) # test raise when not 1d shape y = y.reshape(2, 4) with pytest.raises(ValueError): b3_precision_recall_fscore(y, y) # test raise when different size of elements y = y.reshape(8, 1) with pytest.raises(ValueError): b3_precision_recall_fscore(y[1:], y[2:]) # test error raise when labels_true is empty with pytest.raises(ValueError): b3_precision_recall_fscore(y, []) # test error raise when labels_pred is empty with pytest.raises(ValueError): b3_precision_recall_fscore([], y) # test error raise when both inputs are empty with pytest.raises(ValueError): b3_precision_recall_fscore([], [])
def test_b3_label_invariability(): """Test that paired P/R/F values are label invariant.""" y = [1, 2, 1, 3, 2, 4, 5, 4] y_prime_invariant = [3, 6, 6, 5, 6, 2, 4, 2] y_prime = [2, 3, 3, 4, 3, 5, 1, 5] assert_equal(b3_precision_recall_fscore(y, y_prime), b3_precision_recall_fscore(y, y_prime_invariant))
def test_b3_precision_recall_fscore(): """Test the results of b3_precision_recall_fscore.""" # test for the border case where score maximum y = [1, 2, 1, 3, 2, 4, 5, 4] assert_equal(b3_precision_recall_fscore(y, y), (1, 1, 1)) # test for border case when predicting singletons y_true = [1, 1, 2, 2] y_pred = [1, 2, 3, 4] assert_equal(b3_precision_recall_fscore(y_true, y_pred), (1, 0.5, 2 / 3))
def test_b3_precision_recall_fscore(): """Test the results of b3_precision_recall_fscore.""" # test for the border case where score maximum y = [1, 2, 1, 3, 2, 4, 5, 4] assert_equal(b3_precision_recall_fscore(y, y), (1, 1, 1)) # test for border case when predicting singletons y_true = [1, 1, 2, 2] y_pred = [1, 2, 3, 4] assert_equal(b3_precision_recall_fscore(y_true, y_pred), (1, 0.5, 2 / 3))