对于每一组样本点,应该有三个类/因子,即我应该有3x3表,但是一些引用和预测数据包含的类少于两个,或者是不重叠的类,例如: A我需要相同数量的类/因子来运行confusionMatrix,所以我要做的是有条件地用零替换缺少的因子,如下所示:
Class A B C Class A B C编辑:我使用的实际数据示例(通过光栅/shapefile)和
当我试图解释混淆矩阵时,我得到了以下错误。 Error: `data` and `reference` should be factors with the same levels.., data = training, method = "rpart",predict(dtree_fit, newdata = testing[1,])
test_
我正在尝试计算一个非常大的数据帧的多分类问题的混淆矩阵,它被划分和缩放为Train_Scale和Test_Scale (训练集的比例用于缩放测试)集。当我试图通过混淆矩阵解释结果时,我得到了以下错误: > caret::confusionMatrix(Test_Scale$Class, probabilitiesClass$predictions)Error: `data` and `reference` should be factors with the same levels