rpart:混淆矩阵错误(回归树)
我使用R中的rpart库准备回归树!我有4个依赖变量和3个独立预测变量。所有变量均为刻度(即公制刻度) > 如果 如何修复错误?这里有答案rpart:混淆矩阵错误(回归树),r,decision-tree,R,Decision Tree,我使用R中的rpart库准备回归树!我有4个依赖变量和3个独立预测变量。所有变量均为刻度(即公制刻度) > 如果 如何修复错误?这里有答案 u = union(round(predicted.t),test$y6) t = table(factor(round(predicted.t), u), factor(test$y6, u)) confusionMatrix(t) 因此矩阵是有效的。请注意,class是R中的一个基本函数,您的数据集覆盖了函数定义。另外,在使用随机抽样时,请记住设置.s
u = union(round(predicted.t),test$y6)
t = table(factor(round(predicted.t), u), factor(test$y6, u))
confusionMatrix(t)
因此矩阵是有效的。请注意,
class
是R中的一个基本函数,您的数据集覆盖了函数定义。另外,在使用随机抽样时,请记住设置.seed(x)以x作为您最喜欢的数字,以确保结果的可再现性。您好,我编辑了我的帖子。这里是.csv格式的mydata。
> confusionMatrix(predicted.t,test)
Error in sort.list(y) : 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?
dput(class)
structure(list(x1 = c(215L, 170L, 340L, 320L, 320L, 320L, 300L,
305L, 345L, 300L, 340L, 220L, 320L, 220L, 300L, 300L, 300L, 215L,
275L, 255L, 275L, 320L, 345L, 250L, 220L, 250L, 300L, 220L, 215L,
300L, 255L, 345L, 350L, 305L, 320L, 215L, 215L, 300L, 220L, 255L,
305L, 320L, 345L, 250L, 305L, 255L, 305L, 305L, 255L, 275L, 320L,
340L, 250L, 300L, 305L, 320L, 250L, 300L, 215L, 250L, 220L, 220L,
320L, 300L, 350L, 350L, 350L, 305L, 170L, 220L, 350L, 320L, 215L,
305L, 255L, 170L, 340L, 300L, 300L, 255L, 300L, 320L, 275L, 275L,
View(class)
x1 x2 x3 y1 y2 y3 y6
215 15,4 94 90 7 3 54,886501
170 16 85 90 6 4 54,886501
340 12,2 72 70 15 15 54,886501
320 15,1 78 80 12 8 54,886501
320 9,7 77 80 5 15 54,886501
320 11,1 70 90 1 9 54,886501
300 14,6 85 80 14 6 54,886501
305 8,6 74 90 6 4 54,886501
345 15 85 90 5 5 54,886501
300 13,7 85 90 7 3 54,886501
340 14,3 82 80 18 2 54,886501
220 8,6 77 80 15 5 54,886501
320 13,2 73 80 12 8 54,886501
220 8,4 85 90 5 5 54,886501
300 16 85 90 7 3 56,08118233
300 8,4 72 90 7 3 54,886501
300 13,7 77 90 7 3 54,886501
215 15,1 77 90 6 4 56,08118233
275 12,2 94 70 15 15 56,08118233
255 16 85 80 12 8 54,886501
275 11,1 94 80 5 15 54,886501
u = union(round(predicted.t),test$y6)
t = table(factor(round(predicted.t), u), factor(test$y6, u))
confusionMatrix(t)