svcerror.m
资源名称:svm.zip [点击查看]
上传用户:xfjled
上传日期:2007-05-06
资源大小:150k
文件大小:1k
源码类别:
matlab例程
开发平台:
Matlab
- function err = svcerror(trnX,trnY,tstX,tstY,ker,alpha,bias)
- %SVCERROR Calculate SVC Error
- %
- % Usage: err = svcerror(trnX,trnY,tstX,tstY,ker,alpha,bias)
- %
- % Parameters: trnX - Training inputs
- % trnY - Training targets
- % tstX - Test inputs
- % tstY - Test targets
- % ker - kernel function
- % beta - Lagrange Multipliers
- % bias - bias
- %
- % Author: Steve Gunn (srg@ecs.soton.ac.uk)
- if (nargin ~= 7) % check correct number of arguments
- help svcerror
- else
- n = size(trnX,1);
- m = length(tstY);
- H = zeros(m,n);
- for i=1:m
- for j=1:n
- H(i,j) = trnY(j)*svkernel(ker,tstX(i,:),trnX(j,:));
- end
- end
- predictedY = sign(H*alpha + bias);
- err = sum(predictedY ~= tstY);
- end