SHOGUN
v3.0.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
shogun
classifier
svm
SVM.h
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 3 of the License, or
5
* (at your option) any later version.
6
*
7
* Written (W) 1999-2009 Soeren Sonnenburg
8
* Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9
*/
10
11
#ifndef _SVM_H___
12
#define _SVM_H___
13
14
#include <
shogun/lib/common.h
>
15
#include <
shogun/features/Features.h
>
16
#include <
shogun/kernel/Kernel.h
>
17
#include <
shogun/machine/KernelMachine.h
>
18
19
namespace
shogun
20
{
21
22
class
CMKL;
23
class
CMulticlassSVM;
24
47
class
CSVM
:
public
CKernelMachine
48
{
49
public
:
50
52
MACHINE_PROBLEM_TYPE
(
PT_BINARY
);
53
57
CSVM
(int32_t num_sv=0);
58
66
CSVM
(
float64_t
C,
CKernel
* k,
CLabels
* lab);
67
68
virtual
~CSVM
();
69
72
void
set_defaults
(int32_t num_sv=0);
73
74
80
virtual
SGVector<float64_t>
get_linear_term
();
81
82
88
virtual
void
set_linear_term
(
const
SGVector<float64_t>
linear_term);
89
90
94
bool
load
(FILE* svm_file);
95
99
bool
save
(FILE* svm_file);
100
105
inline
void
set_nu
(
float64_t
nue) {
nu
=nue; }
106
107
116
inline
void
set_C
(
float64_t
c_neg,
float64_t
c_pos) {
C1
=c_neg;
C2
=c_pos; }
117
118
123
inline
void
set_epsilon
(
float64_t
eps) {
epsilon
=eps; }
124
129
inline
void
set_tube_epsilon
(
float64_t
eps) {
tube_epsilon
=eps; }
130
135
inline
float64_t
get_tube_epsilon
() {
return
tube_epsilon
; }
136
141
inline
void
set_qpsize
(int32_t qps) {
qpsize
=qps; }
142
147
inline
float64_t
get_epsilon
() {
return
epsilon
; }
148
153
inline
float64_t
get_nu
() {
return
nu
; }
154
159
inline
float64_t
get_C1
() {
return
C1
; }
160
165
inline
float64_t
get_C2
() {
return
C2
; }
166
171
inline
int32_t
get_qpsize
() {
return
qpsize
; }
172
177
inline
void
set_shrinking_enabled
(
bool
enable)
178
{
179
use_shrinking
=enable;
180
}
181
186
inline
bool
get_shrinking_enabled
()
187
{
188
return
use_shrinking
;
189
}
190
195
float64_t
compute_svm_dual_objective
();
196
201
float64_t
compute_svm_primal_objective
();
202
207
inline
void
set_objective
(
float64_t
v)
208
{
209
objective
=v;
210
}
211
216
inline
float64_t
get_objective
()
217
{
218
return
objective
;
219
}
220
228
void
set_callback_function
(
CMKL
* m,
bool
(*cb)
229
(
CMKL
*
mkl
,
const
float64_t
* sumw,
const
float64_t
suma));
230
232
virtual
const
char
*
get_name
()
const
{
return
"SVM"
; }
233
234
protected
:
235
241
virtual
float64_t
*
get_linear_term_array
();
242
244
SGVector<float64_t>
m_linear_term
;
245
247
bool
svm_loaded
;
249
float64_t
epsilon
;
251
float64_t
tube_epsilon
;
253
float64_t
nu
;
255
float64_t
C1
;
257
float64_t
C2
;
259
float64_t
objective
;
261
int32_t
qpsize
;
263
bool
use_shrinking
;
264
267
bool (*
callback
) (
CMKL
*
mkl
,
const
float64_t
* sumw,
const
float64_t
suma);
270
CMKL
*
mkl
;
271
272
friend
class
CMulticlassSVM
;
273
};
274
}
275
#endif
SHOGUN
Machine Learning Toolbox - Documentation