def test_input_binary_all_wrong(): y_target = np.array([1, 1, 1, 1, 0, 0, 0, 0]) y_model1 = np.array([0, 0, 0, 0, 1, 1, 1, 1]) y_model2 = np.array([0, 0, 0, 0, 1, 1, 1, 1]) tb = mcnemar_tables(y_target, y_model1, y_model2) expect = np.array([[0, 0], [0, 8]]) assert len(tb) == 1 np.testing.assert_array_equal(tb['model_0 vs model_1'], expect)
def test_input_binary_all_wrong(): y_target = np.array([1, 1, 1, 1, 0, 0, 0, 0]) y_model1 = np.array([0, 0, 0, 0, 1, 1, 1, 1]) y_model2 = np.array([0, 0, 0, 0, 1, 1, 1, 1]) tb = mcnemar_tables(y_target, y_model1, y_model2) expect = np.array([[0, 0], [0, 8]]) assert len(tb) == 1 np.testing.assert_array_equal(tb['model_0 vs model_1'], expect)
def test_input_nonbinary(): y_target = np.array([0, 0, 0, 0, 0, 2, 2, 3, 3, 3]) y_model1 = np.array([0, 1, 0, 0, 0, 2, 2, 1, 1, 1]) y_model2 = np.array([0, 0, 1, 1, 0, 2, 2, 0, 1, 0]) y_model3 = np.array([0, 1, 1, 0, 0, 2, 2, 0, 1, 1]) tb = mcnemar_tables(y_target, y_model1, y_model2, y_model3) expect1 = np.array([[4, 1], [2, 3]]) expect2 = np.array([[5, 0], [1, 4]]) expect3 = np.array([[4, 1], [1, 4]]) assert len(tb) == 3 np.testing.assert_array_equal(tb['model_0 vs model_1'], expect1) np.testing.assert_array_equal(tb['model_0 vs model_2'], expect2) np.testing.assert_array_equal(tb['model_1 vs model_2'], expect3)
def test_input_binary(): y_target = np.array([0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) y_model1 = np.array([0, 1, 0, 0, 0, 1, 1, 0, 0, 0]) y_model2 = np.array([0, 0, 1, 1, 0, 1, 1, 0, 0, 0]) y_model3 = np.array([0, 1, 1, 0, 0, 1, 1, 0, 0, 0]) tb = mcnemar_tables(y_target, y_model1, y_model2, y_model3) expect1 = np.array([[4, 1], [2, 3]]) expect2 = np.array([[5, 0], [1, 4]]) expect3 = np.array([[4, 1], [1, 4]]) assert len(tb) == 3 np.testing.assert_array_equal(tb['model_0 vs model_1'], expect1) np.testing.assert_array_equal(tb['model_0 vs model_2'], expect2) np.testing.assert_array_equal(tb['model_1 vs model_2'], expect3)