www.pudn.com > RobustSF.zip > predic_labels.m, change:2014-07-16,size:485b


function [accuray] = predic_labels( Z2,ts_label,W) 
%% 进行预测,预测结果放在数组C中 
WW=W*Z2; 
[~,C]=max(WW); 
 
numclass=length(unique(ts_label)); 
%% 计算预测的准确率 
acc = zeros(numclass, 1); 
for jj = 1 : numclass, 
        c = jj; 
        idx = find(ts_label == c); 
        curr_pred_label = C(idx); 
        curr_gnd_label = ts_label(idx)'; 
        acc(jj) = length(find(curr_pred_label == curr_gnd_label));%/length(idx); 
end;  
accuray= sum(acc)/length(ts_label); 
end