gaussianKernel.m
sim=sim+exp(-(x1-x2)'*(x1-x2)/2/sigma^2);
dataset3Params.m
err=10000; temp=[0.01,0.03,0.1,0.3,1,3,10,30]; for i=1:length(temp) for j=1:length(temp) model= svmTrain(X, y, temp(i), @(x1, x2) gaussianKernel(x1, x2,temp(j))); predictions = svmPredict(model, Xval); if(err>mean(double(predictions ~= yval))) err=mean(double(predictions ~= yval)); C=temp(i); sigma=temp(j); end end end
processEmail.m
for i=1:length(vocabList) if(strcmp(vocabList(i),str)) word_indices=[word_indices;i]; end end
emailFeatures.m
for i=1:length(word_indices) x(word_indices(i))=1; end