通往成功的最後一步

HR 分析:以 R 預測員工流失

Anurag Gupta

People Analytics Practitioner

建立你的最終模型

# 最終模型,你會在下一個練習完成
final_log <- glm(...)
HR 分析:以 R 預測員工流失

預測離職機率

# 對訓練資料集做預測
prediction_train <- predict(final_log, newdata = train_set_final, 
                            type = "response")
prediction_train[c(205, 645)]
       205        645 
0.06069079 0.99999898
HR 分析:以 R 預測員工流失

機率範圍圖:訓練資料集

# 查看預測值範圍
hist(prediction_train)

HR 分析:以 R 預測員工流失

預測機率:測試資料集

# 對測試資料集做預測
# test_set 是第 3 章練習 2 的測試資料集
prediction_test <- predict(final_log, newdata = test_set, 
                           type = "response")
HR 分析:以 R 預測員工流失

機率範圍圖:測試資料集

# 查看預測值範圍
hist(prediction_test)

HR 分析:以 R 預測員工流失

一起來練習吧!

HR 分析:以 R 預測員工流失

Preparing Video For Download...