两个预测函数之间的差异

伊万

专家!

我正在训练数据集上测试逻辑回归模型。我知道“预测”功能可以告诉我发生唯一事件的可能性(类型=“响应”)(在这种情况下,一名员工离开了公司)。

我还知道,2019年1月发布了一个名为``Tidypredict''的新程序包,该程序包还预测了事件间隔为95%发生的可能性。

当我尝试这两种不同的方法时,它显示了同一位员工的不同概率。

我研究了这个话题。似乎使用“预测”功能的最佳时机是最终结果已知时。因为我们可以比较并找出模型的准确性。

当结果未知时,使用“ Tidypredict”功能。谁能告诉我有什么区别?这是现成的信息:https : //cran.r-project.org/web/packages/tidypredict/tidypredict.pdf

预测:https : //stat.ethz.ch/R-manual/R-devel/library/stats/html/predict.glm.html

Here is the results for anyone interested: 
test model:         
1         2         3         4         5         6 
0.6633092 0.2440294 0.2031897 0.9038319 0.8374229 0.1735053 
Tidypredict:

    Age         Los Gender Minority test.model       fit
1 xx.xx ThreeToFive   Male Minority  0.6633092 0.7116757
2 xx.xx   ZeroToOne   Male Minority  0.2440294 0.6834286
3 xx.xx   ZeroToOne Female Minority  0.2031897 0.6303713
4 xx.xx TentoTwenty   Male Minority  0.9038319 0.6963801
5 xx.xx ThreeToFive   Male Minority  0.8374229 0.8658365
6 xx.xx   ZeroToOne Female Minority  0.1735053 0.5840209



      #logistic model# 
model1=glm(Leave~.,family="binomial",data=train)
       #Predict function# 
    test.model<-predict(model1,newdata=test1,type="response")
      #Tidypredict function#
       emp_risk<-test1%>%
       tidypredict_to_column(model1)

我无法重现您的问题-这是一个可重复的示例,说明的预测与的predict()匹配tidypredict_to_column()我的建议-深入研究一个不匹配的具体示例,找出其中的区别。如果您发布可复制的示例,则会获得更具体的帮助:

library(titanic)
library(dplyr)
library(tidypredict)
d <- titanic_train
mod <- glm(Survived ~ Pclass + Sex + Age + SibSp + Parch, data = d, family = "binomial")

d <- d %>% tidypredict_to_column(mod)
d$fit2 <- predict(mod, newdata = d, type = "response")
summary(d$fit - d$fit2)
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
#>       0       0       0       0       0       0     177

reprex软件包(v0.2.1)创建于2019-04-01

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章