员工流失分类器调优

HR Analytics:用 Python 预测员工流失

Hrant Davtyan

Assistant Professor of Data Science American University of Armenia

过拟合

过拟合的存在:

  • 训练准确率:100%
  • 测试准确率:97.23%

应对方法:

  • 限制树的最大深度
  • 限制叶节点的最小样本数
HR Analytics:用 Python 预测员工流失

剪枝决策树

限制深度

model_depth_5 = DecisionTreeClassifier(
                max_depth=5, random_state=42)
# Train set Accuracy: 97.71%
# Test  set Accuracy: 97.06%

限制样本

model_sample_100 = DecisionTreeClassifier(
                   min_samples_leaf=100, random_state=42)
# Train set Accuracy: 96.58%
# Test set Accuracy: 96.13%
HR Analytics:用 Python 预测员工流失

Let's practice!

HR Analytics:用 Python 预测员工流失

Preparing Video For Download...