Ng機器學習 Week7 SVM

Quiz:
SVM
Q1
Q3
Q4&Q5

Ex:

gaussianKernel.m

sim = exp(-sum((x1 - x2).^2) / (2*(sigma^2)));  

dataset3Params.m

steps = [0.01, 0.03, 0.1, 0.3, 1, 3, 10, 30];  
result = 0;
flag = true;
len = numel(steps);  
for i = 1:len
  for j = 1:len
    C_temp = steps(i);  
    sigma_temp = steps(j);  
    model = svmTrain(X, y, C_temp, @(x1, x2) gaussianKernel(x1, x2, sigma_temp));  
    predictions = svmPredict(model, Xval);  
    error = mean(double(predictions ~= yval));  
    if (flag || error<result)
      result = error;
      C = C_temp;
      sigma = sigma_temp;
      flag = false;
    end
  end  
end  

processEmail.m

word_indices = [word_indices, find(ismember(vocabList, str))];  

emailFeatures.m

x([word_indices]) = 1;  
發佈了37 篇原創文章 · 獲贊 12 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章