Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install pytest great_expectations pandas scikit-learn flake8 black mypy pytest-cov
pip install mlflow numpy tensorflow
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

- name: Lint with flake8
Expand All @@ -39,3 +40,13 @@ jobs:
- name: Run model tests
run: |
pytest day5/演習3/tests/test_model.py -v

# 追加: モデルの推論精度・時間の検証
- name: Run model inference tests
run: |
pytest day5/演習3/tests/test_model_inference.py -v

# 追加: モデルのパフォーマンス比較テスト
- name: Run model performance comparison
run: |
pytest day5/演習3/tests/test_model_comparison.py -v
Binary file modified day5/演習1/models/titanic_model.pkl
Binary file not shown.
21 changes: 16 additions & 5 deletions day5/演習2/black_check.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
def say_hello(name):
print("Hello," + name + "!") # greet


def say_hello(name):
print("Hello," + name + "!") # greet


def add(a, b):
return a + b


def add(a, b):
return a + b


def say_hello(name):print("Hello,"+name+"!") # greet
def say_hello(name):print("Hello," + name +"!") # greet
def add( a,b):return a+b
def add( a , b ):return a+b
def add(a, b):
return a+b
return a + b
1 change: 1 addition & 0 deletions day5/演習2/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import time
import great_expectations as gx


class DataLoader:
"""データロードを行うクラス"""

Expand Down
Binary file modified day5/演習2/models/titanic_model.pkl
Binary file not shown.
43 changes: 43 additions & 0 deletions day5/演習3/tests/test_model_inference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import pytest
import time
import json
import os
import pickle
import numpy as np
import pandas as pd
from pathlib import Path

def load_model():
"""モデルをロードする関数"""
# day5/演習1 のモデルを使用
model_path = os.path.join("day5", "演習1", "models", "titanic_model.pkl")
with open(model_path, "rb") as f:
model = pickle.load(f)
return model

def load_test_data():
"""テストデータをロードする関数"""
# day5/演習1 のデータを使用
data_path = os.path.join("day5", "演習1", "data", "test.csv")

# データを読み込む
df = pd.read_csv(data_path)

# 前処理
if 'Survived' in df.columns:
X = df.drop(['Survived'], axis=1)
y = df['Survived']
else:
X = df
# ダミーのラベル
y = pd.Series([0, 1] * (len(df) // 2) + [0] * (len(df) % 2))

# カテゴリカル変数の処理
X = pd.get_dummies(X)

return X, y

def test_model_inference_accuracy():
"""モデルの推論精度をテスト"""
model = load_model()
X, y = load_test_data()
Loading