SHOGUN
v1.1.0
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
shogun
classifier
svm
SVM_libsvm.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2000-2009 Chih-Chung Chang and Chih-Jen Lin
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
*
9
* 1. Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
*
12
* 2. Redistributions in binary form must reproduce the above copyright
13
* notice, this list of conditions and the following disclaimer in the
14
* documentation and/or other materials provided with the distribution.
15
*
16
* 3. Neither name of copyright holders nor the names of its contributors
17
* may be used to endorse or promote products derived from this software
18
* without specific prior written permission.
19
*
20
*
21
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
25
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
*
33
* Shogun specific adjustments (w) 2006-2009 Soeren Sonnenburg
34
*/
35
36
#ifndef DOXYGEN_SHOULD_SKIP_THIS
37
38
#ifndef _LIBSVM_H
39
#define _LIBSVM_H
40
41
#include <
shogun/kernel/Kernel.h
>
42
43
namespace
shogun
44
{
46
struct
svm_node
47
{
49
int32_t index;
50
};
51
53
struct
svm_problem
54
{
55
56
57
public
:
58
60
svm_problem() {
61
y = NULL;
62
x = NULL;
63
C = NULL;
64
pv = NULL;
65
}
66
67
69
int32_t l;
71
float64_t
*y;
73
struct
svm_node **x;
75
float64_t
*C;
77
float64_t
*pv;
78
79
};
80
81
enum
{ C_SVC=1, NU_SVC=2, NU_MULTICLASS_SVC=3, ONE_CLASS=4, EPSILON_SVR=5, NU_SVR=6 };
/* svm_type */
82
enum
{ LINEAR, POLY, RBF, SIGMOID, PRECOMPUTED };
/* kernel_type */
83
85
struct
svm_parameter
86
{
88
int32_t svm_type;
90
int32_t kernel_type;
92
shogun::CKernel
* kernel;
94
int32_t degree;
96
float64_t
gamma;
98
float64_t
coef0;
99
100
/* these are for training only */
102
float64_t
cache_size;
104
float64_t
max_train_time;
106
float64_t
eps;
108
float64_t
C;
110
int32_t nr_class;
112
int32_t nr_weight;
114
int32_t *weight_label;
116
float64_t
* weight;
118
float64_t
nu;
120
float64_t
p;
122
int32_t shrinking;
124
bool
use_bias;
125
};
126
128
struct
svm_model
129
{
131
svm_parameter param;
133
int32_t nr_class;
135
int32_t l;
137
svm_node **SV;
139
float64_t
**sv_coef;
141
float64_t
*rho;
143
float64_t
*normwcw;
144
145
// for classification only
146
148
int32_t *label;
152
int32_t *nSV;
153
// XXX
157
int32_t free_sv;
159
float64_t
objective;
160
};
161
162
163
164
struct
svm_model *svm_train(
165
const
struct
svm_problem *prob,
const
struct
svm_parameter *param);
166
167
float64_t
svm_predict(
const
struct
svm_model *model,
const
struct
svm_node *x);
168
169
void
svm_destroy_model(
struct
svm_model *model);
170
171
const
char
*svm_check_parameter(
const
struct
svm_problem *prob,
const
struct
svm_parameter *param);
172
}
173
#endif
/* _LIBSVM_H */
174
175
#endif // DOXYGEN_SHOULD_SKIP_THIS
SHOGUN
Machine Learning Toolbox - Documentation