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