function [ypred, values] = predictSVMD(Xtrain, ytrain, Xtest, s, C, B)

% SVM + Deleting hard classes from "non-class"

if(~exist('s','var'))
    s = 1;
end

if(~exist('C','var'))
    C = 1;
end

if(~exist('B','var'))
    B = -1;
end

params = sprintf('-s %d -c %f -B %f -q',s,C,B);

classes = size(ytrain,2);

ypredtrain = zeros(size(Xtrain,1),classes);

for i=1:classes
    model = train(full(ytrain(:,i)), Xtrain, params);
    ypredtrain(:,i) = predict(zeros(size(Xtrain,1),1), Xtrain, model);
end

conf = zeros(classes,classes);
for i=1:classes
    for j=1:classes
        conf(i,j) = sum(ytrain(i,:)==1 & ytrain(j,:)==0 & ypredtrain(i,:)==0 & ypredtrain(j,:)==1);
    end
end

conf = conf.*0;
idx = 1:classes;

ypred = zeros(size(Xtest,1),classes);
values = zeros(size(Xtest,1),classes);
for c=1:classes
    model = train(full(ytrain(sum(ytrain(:,idx(conf(c,:)~=0)),2)==0,c)), Xtrain(sum(ytrain(:,idx(conf(c,:)~=0)),2)==0,:), params);
    [ypred(:,c),~,values(:,c)] = predict(zeros(size(Xtest,1),1), Xtest, model);
end