我已经使用“聚会”库中的ctree函数创建了决策树训练模型,以帮助教师确定要跟进哪些学生。现在,我想将此训练模型应用于我的测试集,以便根据学生有多少问题来预测教师是否应该“(1)干预”,“(2)监控学生的进度”或“(3)不采取任何行动”之前已经回答过,这些问题正确解决的百分比,以及他们需要多少提示。
library(party)
D1 <- read.csv(training data with 378 observations and 4 variables:
prior_prob_count, prior_percent_correct, hints_count, score)
D1$advice <- ifelse(D1$score < 0.5, "1", ifelse(D1$score < 0.6, "2", "3"))
如果学生的分数小于0.5,则老师应进行干预(1)。否则,如果学生的分数小于0.6,则老师应监控学生的进步(2)。否则,如果学生的分数高于0.6,则老师不应采取任何措施(3)。
D1$advice <- as.factor(D1$advice)
score_ctree <- ctree(advice ~ prior_prob_count + prior_percent_correct + hints, data=D1)
plot(score_ctree) # see image for visualization
D2 <- read.csv(test data with 200 observations and 4 variables:
prior_prob_count, prior_percent_correct, hints_count, score)
D2$prediction <- predict(object = D2, model = score_ctree)
UseMethod(“ predict”)中的错误:没有适用于“预测”的适用方法,适用于“ data.frame”类的对象]
我认为您的predict
参数错误。我没有安装party
程序包,但查看其他predict
功能应该是: