telco-customer-churn-predic.../tests

18 lines
451 B
Plaintext
Raw Permalink Normal View History

2026-01-13 13:49:44 +08:00
# 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 # 只要能预测就通过