diff --git a/day5/.gitattributes b/day5/.gitattributes new file mode 100644 index 000000000..e5fc7b372 --- /dev/null +++ b/day5/.gitattributes @@ -0,0 +1,2 @@ +# 改行コードを LF に統一 +*.py text eol=lf \ No newline at end of file diff --git "a/day5/\346\274\224\347\277\2221/models/titanic_model.pkl" "b/day5/\346\274\224\347\277\2221/models/titanic_model.pkl" index 6fec87e47..18c70435b 100644 Binary files "a/day5/\346\274\224\347\277\2221/models/titanic_model.pkl" and "b/day5/\346\274\224\347\277\2221/models/titanic_model.pkl" differ diff --git "a/day5/\346\274\224\347\277\2222/black_check.py" "b/day5/\346\274\224\347\277\2222/black_check.py" index 3158f952d..910a40c3a 100644 --- "a/day5/\346\274\224\347\277\2222/black_check.py" +++ "b/day5/\346\274\224\347\277\2222/black_check.py" @@ -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 \ No newline at end of file + return a + b diff --git "a/day5/\346\274\224\347\277\2222/main.py" "b/day5/\346\274\224\347\277\2222/main.py" index 776b70e75..2b256b6c5 100644 --- "a/day5/\346\274\224\347\277\2222/main.py" +++ "b/day5/\346\274\224\347\277\2222/main.py" @@ -11,6 +11,7 @@ import time import great_expectations as gx + class DataLoader: """データロードを行うクラス""" diff --git "a/day5/\346\274\224\347\277\2222/models/titanic_model.pkl" "b/day5/\346\274\224\347\277\2222/models/titanic_model.pkl" index 9e1859fdf..f5f5e860b 100644 Binary files "a/day5/\346\274\224\347\277\2222/models/titanic_model.pkl" and "b/day5/\346\274\224\347\277\2222/models/titanic_model.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..f4db9ff85 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" @@ -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): @@ -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}"