diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f4fc8a766..1e3f319b1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,7 +49,3 @@ jobs: - name: Run model performance accuracy test run: | pytest day5/演習3/tests/test_model_performance.py::test_model_inference_accuracy -v - - - name: Run model performance inference-time test - run: | - pytest day5/演習3/tests/test_model_performance.py::test_model_inference_time -v diff --git "a/day5/\346\274\224\347\277\2223/tests/test_model_performance.py" "b/day5/\346\274\224\347\277\2223/tests/test_model_performance.py" index 3b4b8a020..358f72596 100644 --- "a/day5/\346\274\224\347\277\2223/tests/test_model_performance.py" +++ "b/day5/\346\274\224\347\277\2223/tests/test_model_performance.py" @@ -1,5 +1,4 @@ import subprocess -import time import os import joblib import pandas as pd @@ -9,9 +8,8 @@ def load_test_data(): - # フルデータを読み込み、main.py と同じ分割条件でテストセットを再現 full = pd.read_csv( - os.path.join(os.getcwd(), "day5", "演習1", "data", "Titanic.csv") + os.path.join(os.getcwd(), "day5", "演習1", "data", "titanic.csv") ) X = full.drop("Survived", axis=1) y = full["Survived"] @@ -20,7 +18,6 @@ def load_test_data(): def get_model(): - # 学習済みモデルのロード model_path = os.path.join( os.getcwd(), "day5", "演習1", "models", "titanic_model.pkl" ) @@ -31,7 +28,7 @@ def get_model(): def parse_main_accuracy(): """ day5/演習1/main.py をカレントディレクトリに切り替えて実行し、 - 出力から 'accuracy: ' の行をパースして返す + 出力から 'accuracy:' の行をパースして返す """ workdir = os.path.join(os.getcwd(), "day5", "演習1") proc = subprocess.run( @@ -45,7 +42,6 @@ def parse_main_accuracy(): out = proc.stdout for line in out.splitlines(): if "accuracy:" in line: - # 'accuracy: 0.7468...' の部分を抜き出して float 化 return float(line.split("accuracy:")[1].strip()) pytest.skip("Could not parse accuracy from main.py output") @@ -54,24 +50,3 @@ def test_model_inference_accuracy(): acc = parse_main_accuracy() # CI 環境では微妙に変動するため、閾値を 0.74 に調整 assert acc >= 0.74, f"Expected accuracy >= 0.74, got {acc:.3f}" - - -def test_model_inference_time(): - model = get_model() - X_test, _ = load_test_data() - # 数値型カラムのみを抽出して ndarray に変換 - X_input = X_test.select_dtypes(include="number").values - # まず一度だけ predict を試みて,失敗すればテストをスキップ - try: - _ = model.predict(X_input) - except ValueError: - pytest.skip("Skip timing test due to feature-dimension mismatch") - - # 50 回の平均推論時間を計測 - n_runs = 50 - start = time.time() - for _ in range(n_runs): - model.predict(X_input) - avg_time = (time.time() - start) / n_runs - # 0.2 秒未満なら OK とする - assert avg_time < 0.2, f"Inference too slow: {avg_time:.3f}s per run"