generated from Python-2026Spring/assignment-05-final-project-template
添加 tests
This commit is contained in:
parent
8c3fe8b760
commit
2f2f63fb0b
18
tests
Normal file
18
tests
Normal file
@ -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 # 只要能预测就通过
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user