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

[r6]: / CSVM / trainSVM.m  Maximize  Restore  History

Download this file

74 lines (70 with data), 2.5 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
68
69
70
71
72
73
74

function trainSVM(dataInput, kernelInput, C, modelInput)

% TRAINSVM

% trainSVM is the main function of the toolbox.

%

% trainSVM(dataInput, kernelInput, C, modelInput) stores the

% results of the SVM training in a global structure called 'svModel'

% that has to be declared before calling trainSVM.

%

% INPUT

% dataInput is a structure obtained via the function 'data' and

% contains the training and the testing set,

%

% kernelInput is a structure obtained via the function 'kernel'

% and contains the type and parameters of the kernel,

%

% C is the slack variable

%

% modelInput is a structure obtained via the function 'model'.

% This parameter is optional and used to initialize a specific a

% priori solution. It contains the support vectors and their

% coefficient.

%

% Example

% global svModel

% [x,y,xt,yt]=dataset('Checkers',200,10,0.5); % generates data

% donnees = data(x,y,xt,yt); % stores data

% noyau = kernel('rbf',.9); % stores kernel

% trainSVM(donnees, noyau, C); % train the SVM

% prediction = testSVM; % gives the results

% % on the test set

%

%

% See also: testSVM, data, kernel, model, svm, dataset

% Last Modified by Gaelle Loosli 09-Nov-2007

%=============================

% checking input

global svModel;

if nargin>4

error('too many input arguments');

end

if nargin<3

error('missing argument');

end

if nargin==3

svm(kernelInput,dataInput);

else

svm(kernelInput,dataInput,modelInput);

end

svModel.C = C;

clear dataInput;

clear kernelInput;

%=============================

% main program

initialize;

svModel.temp.countVS = zeros(1,length(svModel.data.trainlab));

while not(isWellClassified)

solveLinearSystem

if isWellConstrained==0

projectSolution % activates a constraint

else

selectConstraintToRelax % adds a point to the solution

end

maj

end

if svModel.verbose>0

fprintf(svModel.fid,'%d support vectors, %d C bounded \n',svModel.temp.n_active,svModel.temp.n_bounded);

end

svModel.model.nbC = svModel.model.nbC + svModel.temp.n_bounded;

%=============================

clear svModel.temp;

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