大家好,我面临这样的错误,我是一个新手,我不知道这是什么意思。我使用neuralnet函数对泰坦尼克号数据集进行分类
有什么建议吗??
str(Prediksi(
num [1:143] 0.393 0.393 0.393 0.393 0.393 ...
str(测试(
num [1:143, 1:10] 1 1 1 1 1 1 1 1 1 1 ...
- attr(*, "dimnames")=List of 2
..$ : chr [1:143] "1" "3" "9" "15" ...
..$ : chr [1:10] "(Intercept)" "Survived" "Pclass" "Sexmale" ...
混淆矩阵(Prediksi,测试(
Error: `data` and `reference` should be factors with the same levels.
在confusionMatrix
函数中,两项都需要是具有相同级别的因子。您的Prediksi
和test
都不是一个因素。
例如,
confusionMatrix(iris$Species, iris$Species)
str(iris$Species)
返回
Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
但是,caret::confusionMatrix
将不允许character
。
看看confusionMatrix(iris$Species, as.character(iris$Species))
,
这将返回
Error: `data` and `reference` should be factors with the same levels.
此外,使用numeric
变量将不起作用。
confusionMatrix(iris$Species, iris$Sepal.Length)
Error: `data` and `reference` should be factors with the same levels.
你没有提供足够的关于你的任务的信息,所以很难说如何解决你的问题,但试着让confusionMatrix
中的两个术语作为一个具有相同水平的因素发挥作用。