def test_check_scores(session_scope_module): # check both set_scores and get_scores submission_id = 1 path_results = os.path.join(HERE, 'data', 'iris_predictions') set_scores(session_scope_module, submission_id, path_results) scores = get_scores(session_scope_module, submission_id) multi_index = pd.MultiIndex.from_product( [[0, 1], ['train', 'valid', 'test']], names=['fold', 'step'] ) expected_df = pd.DataFrame( {'acc': [0.604167, 0.583333, 0.733333, 0.604167, 0.583333, 0.733333], 'error': [0.395833, 0.416667, 0.266667, 0.395833, 0.416667, 0.266667], 'nll': [0.732763, 2.194549, 0.693464, 0.746132, 2.030762, 0.693992], 'f1_70': [0.333333, 0.33333, 0.666667, 0.33333, 0.33333, 0.666667]}, index=multi_index ) assert_frame_equal(scores, expected_df, check_less_precise=True)
def test_score_submission(session_scope_module): submission_id = 9 multi_index = pd.MultiIndex.from_product( [[0, 1], ['train', 'valid', 'test']], names=['fold', 'step'] ) expected_df = pd.DataFrame( {'acc': [0.604167, 0.583333, 0.733333, 0.604167, 0.583333, 0.733333], 'error': [0.395833, 0.416667, 0.266667, 0.395833, 0.416667, 0.266667], 'nll': [0.732763, 2.194549, 0.693464, 0.746132, 2.030762, 0.693992], 'f1_70': [0.333333, 0.33333, 0.666667, 0.33333, 0.33333, 0.666667]}, index=multi_index ) path_results = os.path.join(HERE, 'data', 'iris_predictions') with pytest.raises(ValueError, match='Submission state must be "tested"'): score_submission(session_scope_module, submission_id) set_submission_state(session_scope_module, submission_id, 'tested') set_predictions(session_scope_module, submission_id, path_results) score_submission(session_scope_module, submission_id) scores = get_scores(session_scope_module, submission_id) assert_frame_equal(scores, expected_df, check_less_precise=True)