From 2f2f63fb0bf526517b8c88d9f7b379dfd352365a Mon Sep 17 00:00:00 2001 From: zhelisi Date: Tue, 13 Jan 2026 13:49:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests diff --git a/tests b/tests new file mode 100644 index 0000000..0fea438 --- /dev/null +++ b/tests @@ -0,0 +1,18 @@ +# tests/test_model.py +import joblib +import pandas as pd + +def test_model_prediction(): + # 加载模型 + model = joblib.load("../telco_churn_model.pkl") + # 构造测试数据 + test_data = pd.DataFrame({ + "tenure": [2], + "MonthlyCharges": [89.99], + "Contract": ["Month-to-month"] + }) + # 测试预测是否正常运行 + pred = model.predict(test_data) + assert pred is not None # 只要能预测就通过 + + \ No newline at end of file