决策树 - 多个实例
Decision tree - multiple instances
从这些数据出发
i <- c("1","2","3","4","5","6","7","8")
g <- c("man","man","woman","man","woman","man","woman","man")
r <- c("100","34","22","42","62","73","8","66")
o <- c("A1","A2","A3","A2","A2","A1","A3","A2")
data <- data.frame (i,g,r,o)
我需要构建一个决策树,以便为列的每个实例识别规则 "o" 就像那样
if i=1 and g=man and r=100 then A1
有人可以建议我必须使用哪种 R 算法吗?
假设您暗示 o 是您的结果。
require(rpart)
fit <- rpart(o ~ i + g + r, dta)
plot(fit) # won't work as not a tree (too little data)
text(fit)
从这些数据出发
i <- c("1","2","3","4","5","6","7","8")
g <- c("man","man","woman","man","woman","man","woman","man")
r <- c("100","34","22","42","62","73","8","66")
o <- c("A1","A2","A3","A2","A2","A1","A3","A2")
data <- data.frame (i,g,r,o)
我需要构建一个决策树,以便为列的每个实例识别规则 "o" 就像那样
if i=1 and g=man and r=100 then A1
有人可以建议我必须使用哪种 R 算法吗?
假设您暗示 o 是您的结果。
require(rpart)
fit <- rpart(o ~ i + g + r, dta)
plot(fit) # won't work as not a tree (too little data)
text(fit)