kernel - One-vs-all multiclass classification -


i trying classify walk cycles svm. using precomputed kernel rbf kernel. k(x,x') = exp(-sigma*dtw(x,x')^2). trying 1 against stratergy multiclass classification. currently, using probabilty predict class want use majority vote kind stuck, need thought on how can use majority voting make class decisions, thought test examples on models , predict class more vote, acceptable approach? have following code.

    %# walk cycles dataset     clear     clc     close     % addpath libsvm toolbox    %addpath('../libsvm-3.12/matlab');     % addpath data      dirdata = './data';      addpath(dirdata);     % load/read seprated datasets      load(fullfile(dirdata,'mytraindata.mat'));      traindata =  mytraindata (:,5:104); clear data;      trainlabel = mytraindata(:,1); clear label;       load(fullfile(dirdata,'mytestdata.mat'));      testdata =  mytestdata(:,5:104); clear data;      testlabel = mytestdata(:,1); clear label;     % extract important information      labellist = unique(trainlabel);      nclass = length(labellist);      [ntrain d] = size(traindata);      [ntest d] = size(testdata);        [~,~,labels] = unique(trainlabel);   %# labels: 1/2/3/4...../51      %data = zscore(meas); % not scaling features                   numinst = size(traindata,1);      numlabels = max(trainlabel);       %# split training/testing      % have seprated train , test dataset      idx = randperm(numinst);      numtrain = 100;       numtest = size(testdata,1);      %traindata = data(idx(1:numtrain),:);  testdata = data(idx(numtrain+1:end),:);      %trainlabel = labels(idx(1:numtrain)); testlabel = labels(idx(numtrain+1:end));       %# train one-against-all models      precompkernel = @(x,y) (distancemat2(x,y));     k_precompkernel  =  [(1:numtrain)' , precompkernel(traindata,traindata)];     k_precompkerneltest = [(1:numtest)' ,precompkernel(testdata,traindata)];      k_precompnum = k_precompkernel(:,1);     k_precompdata = k_precompkernel(:,2:end);      k_precompkerneltestnum = k_precompkerneltest(:,1);     k_precompkerneltestdata = k_precompkerneltest (:,2:end);      kernalmat = exp((-1/sigma).* k_precompdata.^2);     kernelmattest = exp((-1/sigma).* k_precompkerneltestdata.^2);       kernelfinalmat = [k_precompnum k_precompdata];     kernelfinalmattest = [k_precompkerneltestnum k_precompkerneltestdata];       model = cell(numlabels,1);     k=1:numlabels         model{k} = svmtrain(double(trainlabel==k), kernelfinalmat, '-c 1 -t 4 -b 1');     end     %# probability estimates of test instances using each model       prob = zeros(numtest,numlabels);       k=1:numlabels           [~,~,p] = svmpredict(double(testlabel==k), kernelfinalmattest, model{k}, '-b  1');           prob(:,k) = p(:,model{k}.label==1);    %# probability of class==k       end     %# predict class highest probability       [~,pred] = max(prob,[],2);       acc = sum(pred == testlabel) ./ numel(testlabel)    %# accuracy        c = confusionmat(testlabel, pred)   

there no such thing majority vote in one-vs-all multi-class classification . when perform 1-vs-all voting on k classes, k votes/probabilities/... label assigned whichever individual 1 highest.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -