【发布时间】:2021-03-13 13:39:06
【问题描述】:
我已经在 2120x10 的样本大小上训练了一个模型。现在我正在尝试将相同的模型应用于测试数据集,但在推导混淆矩阵时遇到了麻烦。
test_predictions <- predict(train_obj, test_data)
test_predictions <- ifelse(test_predictions > 5, 1, 0)
confusionMatrix(as.factor(test_predictions), test_data$outcome, positive="1")
在计算混淆矩阵时出现错误,因为 test_data$outcome 有 2135 个值。如果我使用test_data$outcome[1:2120],一切正常。
有没有更好的方法来计算混淆矩阵而不限制值的数量。?限制test_data$outcome中的值个数是否正确?
【问题讨论】:
标签: r prediction