Join/Login

Business Software

Open Source Software

For Vendors

Blog

About

More

Articles

Create

SourceForge Podcast

Site Documentation

Subscribe to our Newsletter

Support Request

For Vendors Help Create Join Login

Business Software

Open Source Software

SourceForge Podcast

Resources

Articles

Case Studies

Blog

Menu

Help

Create

Join

Login

Home

Browse

The Simple SVM toolbox

Code

The Simple SVM toolbox Code

Brought to you by: gloosli

Summary

Files

Reviews

Support

Code

Menu ▾ ▴

Browse Commits

Browse Files

[r8]: / TestFiles / testOC.m  Maximize  Restore  History

Download this file

45 lines (34 with data), 1.3 kB

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

clear all

addpath('../utils/');

global svModel;

addpath('../OCSVM');

% ca c'est pour se servir de dataset.m ...

[x,y,xt,yt] = dataset('oneclass',50,100,0.3);

rn = randperm(length(y));

donnees = data(x(:,rn),y(rn),xt,yt);

nu = 0.1;

C = 1/(nu*length(y));

noyau = kernel('rbf',0.5);

t = cputime;

trainSVM(donnees,noyau,C);

t = cputime-t

ypred = testSVM;

Error = length(find(sign(ypred)==svModel.data.testlab))/length(svModel.data.testlab)

figure;

plot(donnees.trainvec(1,:),donnees.trainvec(2,:),'ro');

hold on

plot(donnees.testvec(1,donnees.testlab==1),donnees.testvec(2,donnees.testlab==1),'rx');

plot(donnees.testvec(1,donnees.testlab==-1),donnees.testvec(2,donnees.testlab==-1),'bx');

plot(donnees.trainvec(1,svModel.model.indices),donnees.trainvec(2,svModel.model.indices),'g+');

legend('train data','positive test','negative test','support vectors');

%------- Building a 2D Grid for function evaluation -------------------------

z = 2*[-1:.05:1];

[xtest1 xtest2] = meshgrid(z,z);

nn = length(xtest1);

Xtest = [reshape(xtest1 ,nn*nn,1) reshape(xtest2 ,nn*nn,1)];

%-------------- Evaluating the decision function

svModel.data.testvec = Xtest';

[ypred] = testSVM;

ypred = reshape(ypred,nn,nn);

%--------------- plotting

contour(z,z,ypred,[-svModel.model.mu 0 -svModel.model.mu]);

SourceForge

Create a Project

Open Source Software

Business Software

Top Downloaded Projects

Company

About

Team

SourceForge Headquarters
225 Broadway Suite 1600
San Diego, CA 92101
+1 (858) 422-6466

Resources

Support

Site Documentation

Site Status

SourceForge Reviews

© 2025 Slashdot Media. All Rights Reserved.

Terms Privacy Opt Out Advertise

×
Want the latest updates on software, tech news, and AI?

Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.

Submit