我想在我的小数据集(65x8)上执行简单的 LDA。我有 65 个实例(样本)、8 个特征(属性)和 4 个类。LDA 的任何 matlab 代码,据我所知,Matlab Toolbox 没有 LDA 功能所以我需要编写自己的代码。有什么帮助吗?
我在网上找到这段代码
load /Data;
All_data= Data(:,1:8);
All_data_label= Data(:,9);
testing_ind = [];
for i = 1:length(Data)
if rand>0.8
testing_ind = [testing_ind, i];
end
end
training_ind = setxor(1:length(Data), testing_ind);
[ldaClass,err,P,logp,coeff] = classify(Data(testing_ind,:),...
Data((training_ind),:),Data_label(training_ind,:),'linear');
[ldaResubCM,grpOrder] = confusionmat(All_data_label(testing_ind,:),ldaClass)
然后我得到了这个结果 ldaClass =
3
2
3
2
1
4
3
3
1
2
1
1
2
错误 =
0.2963
P =
0.0001 0.0469 0.7302 0.2229
0.1178 0.5224 0.3178 0.0419
0.0004 0.2856 0.4916 0.2224
0.0591 0.6887 0.1524 0.0998
0.8327 0.1637 0.0030 0.0007
0.0002 0.1173 0.3897 0.4928
0.0000 0.0061 0.7683 0.2255
0.0000 0.0241 0.5783 0.3976
0.9571 0.0426 0.0003 0.0000
0.2719 0.5569 0.1630 0.0082
0.9999 0.0001 0.0000 0.0000
0.9736 0.0261 0.0003 0.0000
0.0842 0.6404 0.2634 0.0120
系数 =
具有字段的 4x4 结构数组:类型 name1 name2 const linear
ldaResubCM =
4 0 0 0
0 3 1 0
0 1 1 0
0 0 2 1
grpOrder =
1
2
3
4
所以我有 65 个实例、8 个属性和 4 个类(1、2、3、4)。所以不知道如何解释这些结果。有什么帮助吗?