function alpha=kernelOptimization_c2(trData,ecData,trTags,gamma0,gamma1,epsilon) % kernel optimization for binary-class data set. The class tags are supposed to be 0, 1. % "trData": the matrix of the training data. % "ecData": the matrix of the 'local centers'. % "trTags": the class tags of the training data. % "gamma0": the parameter in the basic Gaussian kernel function. % "gamma1": the parameter in the supplementary Gaussian kernel function. % "epsilon": the parameter in the disturbed resampling procedure. % "alpha": the final optimized combination coefficients in out data-dependent kernel model. iterations=1000; initialLearningRate=0.01; trvData=trData; [trvDim,trvSize]=size(trData); trbSize=size(ecData,2); [resData1,resIndex1]=resampling(trvData,trvSize); [resData2,resIndex2]=resampling(trvData,trvSize); randn('state',sum(100*clock)); trvData1=[trvData,resData1+epsilon*randn(size(trvData)),resData2+epsilon*randn(size(trvData))]; trTags1=[trTags,trTags(resIndex1),trTags(resIndex2)]; [trTags1,nIndex]=sort(trTags1); trvData1=trvData1(:,nIndex); kernelMat1=exp(-gamma0*getDistanceMat(trvData1,trvData1)); suppKernelMat1=[ones(size(trvData1,2),1),exp(-gamma1*getDistanceMat(trvData1,ecData))]; [betweenMat1,withinMat1]=getBasicKernelMat(kernelMat1,trTags1); bscMat1=suppKernelMat1'*betweenMat1*suppKernelMat1; bscMat2=suppKernelMat1'*withinMat1*suppKernelMat1; alpha=zeros(size(ecData,2)+1,1); alpha(1,1)=1.0; for i=1:iterations quasi1=suppKernelMat1*alpha; J1=quasi1'*betweenMat1*quasi1; J2=quasi1'*withinMat1*quasi1; currentLearningRate=initialLearningRate*(1.0-(i-1)/iterations); alpha=alpha+(currentLearningRate/J2/J2)*(J2*bscMat1-J1*bscMat2)*alpha; alpha=(1.0/sqrt(alpha'*alpha))*alpha; end