Skip to content

Commit

Permalink
Merge pull request #6 from ratiopharm88/master
Browse files Browse the repository at this point in the history
Changes from friday
  • Loading branch information
Thomas Jespersen committed Mar 16, 2012
2 parents 8fbc0e1 + 5cccd58 commit 0159b37
Show file tree
Hide file tree
Showing 9 changed files with 1,139 additions and 11 deletions.
2 changes: 1 addition & 1 deletion handin3/Code/classify.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function [ classvector ] = classify( data, model )
%% Trains the SVM on the given data using the given parameters.
%% Returns libsvm model data which can then be used with svmpredict.
dummylabels = ones(1, length(data));
dummylabels = ones(1, size(data, 1));

classvector = svmpredict(dummylabels, data, model, '');

Expand Down
15 changes: 15 additions & 0 deletions handin3/Code/dividedataset.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function [class1 class2] = dividedataset (A)
%% Divides a given set of two dimensional classification data into one set for each class.
%% The classes must be encoded by being 1 for the first class and different from one for the second.
%%
%% A - the input data set
class1=ones(0,2);
class2=ones(0,2);
for i=1:length(A)
if A(i,3)==1
class1=[class1;A(i,1),A(i,2)];
else
class2=[class2;A(i,1),A(i,2)];
end
end

17 changes: 17 additions & 0 deletions handin3/Code/dividesupportvectors.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function [free bounded] = dividesupportvectors (c, SVs, SVcoeffs)
%% Takes a matrix containing all support vectors of a trained C-SVM
%% and divides it into free and bounded support vectors.

free=ones(0, size(SVs, 2));
bounded=ones(0, size(SVs, 2));

for i=1:length(SVcoeffs)
current= SVs(i,:);
if c==abs(SVcoeffs(i))
bounded=[bounded; current];
else
free=[free; current];
end
end

end
Loading

0 comments on commit 0159b37

Please sign in to comment.