【发布时间】:2014-02-05 23:01:16
【问题描述】:
在我通过 as.factor(response) 将我的响应变量设置为一个因素后,我运行:
tree = ctree(response~., data=trainingset)
当我绘制这棵树时:它给了我图中 y 的向量值作为示例: y=(0.095, 0.905, 0) 我注意到这 3 个值的总和为 1。
但事实上,实际响应变量仅包含 0、1、99 的值。
谁能帮我在 ctree 图中解释这个向量吗?谢谢!
具体代码如下:
response = as.factor(data$response)
newdata = cbind(predictor.matrix, response)
ind = sample(2, nrow(newdata), replace=TRUE, prob=c(0.7, 0.3))
trainData = newdata[ind==1,]
testData = newdata[ind==2,]
tree = ctree(response~., data=trainData)
plot(tree, type="simple")
【问题讨论】:
-
这些是每个类的后验概率;即,对于
1类,观察值约为 0.9 (90%) 的后验概率。 -
感谢 Gavin,我使用了命令 plot(tree, type="simple")
-
对于 is.factor() 问题,返回值为 TRUE。 :)
-
具体代码请看我上面编辑的帖子原文。谢谢!
-
重新转换
response的代码,不太理想。你想要response在trainingset中。最好是trainingset <- transform(trainingset, response = as.factor(response))。
标签: r classification