gpt4 book ai didi

r - 预测()函数的类型参数

转载 作者:行者123 更新时间:2023-12-03 14:19:45 26 4
gpt4 key购买 nike

type="class"函数中的type="response"predict有什么区别?

例如:

predict(modelName, newdata=testData, type = "class")




predict(modelName, newdata=testData, type = "response")

最佳答案

响应为您提供数值结果,而类为您提供分配给该值的标签。

响应使您可以确定阈值。例如,

glm.fit = glm(Direction~., data=data, family = binomial, subset = train)
glm.probs = predict(glm.fit, test, type = "response")


glm.probs中,我们有一些介于0和1之间的数值。现在我们可以确定阈值,例如0.6。方向有两个可能的结果,向上或向下。

glm.pred = rep("Down",length(test))
glm.pred[glm.probs>.6] = "Up"

关于r - 预测()函数的类型参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23085096/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com