Skip to content
Open
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
2 changes: 2 additions & 0 deletions day5/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# 改行コードを LF に統一
*.py text eol=lf
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.
18 changes: 18 additions & 0 deletions day5/演習3/tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ def test_model_inference_time(train_model):

# 推論時間が1秒未満であることを確認
assert inference_time < 1.0, f"推論時間が長すぎます: {inference_time}秒"
assert (
inference_time < 2.0
), f"推論時間が長すぎて何か大きな修正が必要です: {inference_time}秒"


def test_model_reproducibility(sample_data, preprocessor):
Expand Down Expand Up @@ -171,3 +174,18 @@ def test_model_reproducibility(sample_data, preprocessor):
assert np.array_equal(
predictions1, predictions2
), "モデルの予測結果に再現性がありません"


def test_model_is_better_than_random(train_model):
"""モデルの精度がランダム予測より有意に高いことを検証"""
model, X_test, y_test = train_model

y_pred = model.predict(X_test)
model_acc = accuracy_score(y_test, y_pred)

random_preds = np.random.choice([0, 1], size=len(y_test))
random_acc = accuracy_score(y_test, random_preds)

assert (
model_acc >= random_acc + 0.1
), f"モデルの精度がランダムと大差ありません: model={model_acc:.3f}, random={random_acc:.3f}"