Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DS School - Differential test #126

Open
yeomko22 opened this issue Sep 23, 2021 · 0 comments
Open

DS School - Differential test #126

yeomko22 opened this issue Sep 23, 2021 · 0 comments

Comments

@yeomko22
Copy link
Owner

Differential test

  • 시스템에 변화를 가했을때, 이전 버전과 현재 버전 간의 차이를 테스트
@pytest.mark.differential
def test_model_prediction_differentials(client):
    test_inputs_df = load_dataset(file_name="test.csv")
    old_model_inputs_df = test_inputs_df.rename(
        columns=SECONDARY_VARIABLES_TO_RENAME
    )

    new_model_response = client.post(
        "v1/predictions/gradient", json=test_inputs_df.to_dict(orient="records")
    )
    new_model_predictions = json.loads(new_model_response.data)["predictions"]

    old_model_response = client.post(
        "v1/predictions/regression",
        json=old_model_inputs_df.to_dict(orient="records"),
    )
    old_model_predictions = json.loads(old_model_response.data)["predictions"]

    # We just pass in the first 10 rows as the two models' validation differs
    # which means they filter out a slightly different number of rows
    # which would cause the differential tests to fail.
    compare_differences(
        expected_predictions=new_model_predictions[:10],
        actual_predictions=old_model_predictions[:10],
        # you would adjust the rel_tol level parameter on your model.
        # right now this is extremely permissive of variation.
        rel_tol=0.2,
    )
  • 이전 모델과 현재 모델에서 각각 예측 결과를 가져온 다음, 결과값의 개수, 예측 스코어 값을 비교한다.
  • 예측 스코어를 비교할 떄는 직접 정의한 compare_differences 함수를 사용하며 이 때 relative tolerance를 주어 이전 버전과 현재 버전의 스코어 값 간의 최대 차이를 설정할 수 있다.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant