Two different inputs get the same XGBoost churn probability in my Flask API—does that mean my model is broken?

未关闭 适合新手
#571 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@github-actions 已经在做这个了。

开始于 2026年11月11日。

  • #572 来自 @github-actions —— 未关闭

评估

难度
1/5
预计耗时
1-3 小时
新手友好度
85/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
活跃
技术栈
flask, python

调研方向

Issue 包含 FAQ 答案以及一个使用 DictVectorizer 和 XGBoost 的 Python 示例。首先检查现有的 FAQ 结构,以及 machine-learning-zoomcamp 课程中相邻的条目。将这个问题及其答案按照 repository 已有的格式添加,并保留示例和检查清单,即表示完成。

由索引模型根据 Issue 内容生成。

描述

faq-proposal
Course

machine-learning-zoomcamp

Question

I deployed an XGBoost customer churn prediction model using Flask and DictVectorizer. Sometimes, two customers with different input values receive exactly the same churn probability.

Does this mean my API or model is broken?

Answer

Not necessarily. Tree-based models such as XGBoost divide feature values into ranges using decision thresholds.

Two customers can have different numerical values but still follow the same paths through all the trees. In that case, they can receive identical predictions.

However, identical predictions can also indicate a preprocessing issue.

How to investigate:

Check whether the JSON input contains the expected feature names.

Verify that the same fitted DictVectorizer is used during training and prediction.

Compare the transformed feature vectors for both customers.

Check whether the differences in input values actually change the model's decision paths.

For example:

customer_1 = {
"age": 35,
"balance": 50000
}

customer_2 = {
"age": 36,
"balance": 50500
}

X = dv.transform([customer_1, customer_2])

predictions = model.predict_proba(X)[:, 1]

print(predictions)

This example assumes dv and model are already fitted and loaded. For a full churn model, the complete set of required features should be supplied.

Key takeaway: Identical predictions do not automatically indicate a bug. Tree-based models can assign the same probability to different inputs, but checking preprocessing is essential before drawing conclusions.

Checklist
  • I have searched existing FAQs and this question is not already answered
  • The answer provides accurate, helpful information
  • I have included any relevant code examples or links
主要语言
Python
星标
8
派生
20
平均合并
4 天 9 小时
30 天内合并 PR
27

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

DataTalksClub/faq 的其他 Issue

查看 DataTalksClub/faq 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。