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 / testHM.m  Maximize  Restore  History

Download this file

67 lines (54 with data), 1.8 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

%

% SVM 2D Classification

% Comparing Gaussian and polynomial Kernels

%

%

close all

global svModel;

addpath('../HMSVM/')

addpath('../utils/')

%

% Creating Data

%

nbapp=550;

nn=20;

nbtest=nn*nn;

[vector_training_set,label_training_set,vector_test_set,label_test_set,xtest1,xtest2]=dataset('checkers',nbapp,nbtest,0);

donnees = data(vector_training_set,label_training_set,vector_test_set,label_test_set);

%

% learning with polynomial kernels

%

noyau = kernel('poly',[6,.3]);

trainSVM(donnees, noyau);

ypred = testSVM;

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

%------------------- Gaussian Kernel -------------------------

noyau = kernel('rbf',2);

tic;

trainSVM(donnees, noyau);

toc

ypred = testSVM;

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

disp('The same with warm start')

noyau = kernel('rbf',2);

tic;

trainSVM(donnees, noyau,svModel.model);

toc

ypred = testSVM;

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

figure;

plot(vector_training_set(1,label_training_set==1),vector_training_set(2,label_training_set==1),'ro');

hold on

plot(vector_training_set(1,label_training_set==-1),vector_training_set(2,label_training_set==-1),'bo');

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

%------- 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,[-1 0 1]);

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