Demo entry 6781024

v

   

Submitted by anonymous on Dec 31, 2018 at 07:01
Language: Matlab. Code size: 620 Bytes.

CArr = [0.01, 0.03, 0.1, 0.3, 1, 3, 10, 30];  
sigmaArr = [0.01, 0.03, 0.1, 0.3, 1, 3, 10, 30];  
C_Temp = 1;  
sigma_Temp = 0.3;  
err = Inf;  
for i = 1:length(CArr)  
    for j = 1:length(sigmaArr)  
        C_Temp = CArr(i);  
        sigma_Temp = sigmaArr(j);  
        model = svmTrain(X, y,C_Temp, @(x1, x2) gaussianKernel(x1, x2, sigma_Temp));  
        predictions = svmPredict(model, Xval);  
        if(mean(double(predictions ~= yval)) < err)  
            C = C_Temp;  
            sigma = sigma_Temp;  
            err = mean(double(predictions ~= yval));  
        end  
    end  
end  

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).