diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b4aad9943..704438146 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,8 +1,8 @@ name: ML Pipeline CI on: - # push: - # branches: [ main, master ] + push: + branches: [ main, master ] pull_request: branches: [ main, master ] diff --git "a/day5/\346\274\224\347\277\2223/models/titanic_model_prev.pkl" "b/day5/\346\274\224\347\277\2223/models/titanic_model_prev.pkl" new file mode 100644 index 000000000..1c8888f68 Binary files /dev/null and "b/day5/\346\274\224\347\277\2223/models/titanic_model_prev.pkl" differ diff --git "a/day5/\346\274\224\347\277\2223/tests/test_model.py" "b/day5/\346\274\224\347\277\2223/tests/test_model.py" index e11a19a5c..5c847b9ee 100644 --- "a/day5/\346\274\224\347\277\2223/tests/test_model.py" +++ "b/day5/\346\274\224\347\277\2223/tests/test_model.py" @@ -16,6 +16,7 @@ DATA_PATH = os.path.join(os.path.dirname(__file__), "../data/Titanic.csv") MODEL_DIR = os.path.join(os.path.dirname(__file__), "../models") MODEL_PATH = os.path.join(MODEL_DIR, "titanic_model.pkl") +MODEL_PATH2 = os.path.join(MODEL_DIR, "titanic_model_prev.pkl") @pytest.fixture @@ -108,6 +109,10 @@ def test_model_exists(): pytest.skip("モデルファイルが存在しないためスキップします") assert os.path.exists(MODEL_PATH), "モデルファイルが存在しません" + if not os.path.exists(MODEL_PATH2): + pytest.skip("前回のモデルファイルが存在しないためスキップします") + assert os.path.exists(MODEL_PATH2), "前回のモデルファイルが存在しません" + def test_model_accuracy(train_model): """モデルの精度を検証""" @@ -116,6 +121,7 @@ def test_model_accuracy(train_model): # 予測と精度計算 y_pred = model.predict(X_test) accuracy = accuracy_score(y_test, y_pred) + print(f"モデルの精度: {accuracy:.4f}") # Titanicデータセットでは0.75以上の精度が一般的に良いとされる assert accuracy >= 0.75, f"モデルの精度が低すぎます: {accuracy}" @@ -131,7 +137,7 @@ def test_model_inference_time(train_model): end_time = time.time() inference_time = end_time - start_time - + print(f"推論時間: {inference_time:.4f}秒") # 推論時間が1秒未満であることを確認 assert inference_time < 1.0, f"推論時間が長すぎます: {inference_time}秒" @@ -168,6 +174,4 @@ def test_model_reproducibility(sample_data, preprocessor): predictions1 = model1.predict(X_test) predictions2 = model2.predict(X_test) - assert np.array_equal( - predictions1, predictions2 - ), "モデルの予測結果に再現性がありません" + assert np.array_equal(predictions1, predictions2), "モデルの予測結果に再現性がありません"