1

我正在使用一些数据挖掘工具分析数据集。响应变量有十个级别,我正在尝试创建一个分类器。

问题来了。当使用nnet和bagging函数时,结果不是很好,第5层甚至不在预测中。

我想使用混淆矩阵来分析分类器。但由于预测中未显示第 5 级,我无法获得格式良好的矩阵。那么我怎样才能获得格式良好的矩阵?即我想要一个 10 *10 矩阵。

混淆矩阵:

library("mda")#This is where **confusion** comes from
> confusion(pre.bag$class,CLASS)#here confusion acts like table
         true
predicted   1   2  3  4   6   7  8  9  10  5
       1  338   9  6  0   5  12 10  1  15 46
       2    9 549  1 59  18   0  3  0   0  6
       3   18   1 44  0   0   0  2  0   0  4
       4    0   1  0 21   0   0  0  0   0  0
       6    2  13  0  1 299   2  9  0   0  0
       7    5   2  1  0  10 231  6  0   1  0
       8    0   0  0  0   0   5 76  0   0  0
       9    5   1  0  0   0   0  0 62   0  0
       10   7   3  1  0   0   2  1  6 181 16
attr(,"error")
[1] 0.1231743
attr(,"mismatch")
[1] 0.03386642
4

1 回答 1

1

试试这个:

pred <- factor(pre.bag$class, levels=levels(CLASS) )
confusion(pre.bag$class, CLASS)

(使用 fda 对象测试。)

于 2012-04-16T19:05:58.093 回答