?? test_error.m
字號:
function [TestErrorMSE,TestErrorRate]=Test_Error(test_p,test_t,cents,W,R)
% 求測試MSE及測試分類錯誤率
row=size(test_p,1);
for m=1:row
for n=1:size(cents,1)
H2(m,n)=exp(-(test_p(m,:)-cents(n,:))*R(:,:,n)*(test_p(m,:)-cents(n,:))');
end
end
h(1:row)=1;
H2=[h',H2];
t=H2*W;
% 求MSE
t_error=t-test_t;
t_error=t_error.^2;
% t_error=abs(t_error);
t_error=sum(sum(t_error,2)/size(test_t,2));
TestErrorMSE=t_error/row;
% 求測試分類錯誤率
[t1,index1]=max(t,[],2);
[t2,index2]=max(test_t,[],2);
TestCorrectnum=0;
for i=1:row
if index1(i,1)==index2(i,1)
TestCorrectnum=TestCorrectnum+1;
end
end
TestErrorRate=1-TestCorrectnum/row;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -