SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
multiclass
MulticlassSVM.h
浏览该文件的文档.
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-2011 Soeren Sonnenburg
8
* Written (W) 2012 Soeren Sonnenburg, Chiyuan Zhang
9
* Copyright (C) 1999-2011 Fraunhofer Institute FIRST and Max-Planck-Society
10
*/
11
12
#ifndef _MULTICLASSSVM_H___
13
#define _MULTICLASSSVM_H___
14
15
#include <
shogun/lib/common.h
>
16
#include <
shogun/features/Features.h
>
17
#include <
shogun/classifier/svm/SVM.h
>
18
#include <
shogun/machine/KernelMulticlassMachine.h
>
19
20
namespace
shogun
21
{
22
23
class
CSVM;
24
26
class
CMulticlassSVM
:
public
CKernelMulticlassMachine
27
{
28
public
:
30
MACHINE_PROBLEM_TYPE
(
PT_MULTICLASS
);
31
33
CMulticlassSVM
();
34
39
CMulticlassSVM
(
CMulticlassStrategy
*strategy);
40
48
CMulticlassSVM
(
49
CMulticlassStrategy
*strategy,
float64_t
C,
CKernel
* k,
CLabels
* lab);
50
virtual
~CMulticlassSVM
();
51
59
bool
create_multiclass_svm
(int32_t num_classes);
60
67
bool
set_svm
(int32_t num,
CSVM
* svm);
68
74
CSVM
*
get_svm
(int32_t num)
75
{
76
return
dynamic_cast<
CSVM
*
>
(
m_machines
->
get_element_safe
(num));
77
}
78
82
bool
load
(FILE* svm_file);
83
87
bool
save
(FILE* svm_file);
88
89
// TODO remove if unnecessary here
93
SGVector<float64_t>
get_linear_term
() {
return
svm_proto
()->
get_linear_term
(); }
94
// TODO remove if unnecessary here
98
float64_t
get_tube_epsilon
() {
return
svm_proto
()->
get_tube_epsilon
(); }
99
// TODO remove if unnecessary here
103
float64_t
get_epsilon
() {
return
svm_proto
()->
get_epsilon
(); }
104
// TODO remove if unnecessary here
108
float64_t
get_nu
() {
return
svm_proto
()->
get_nu
(); }
109
// TODO remove if unnecessary here
113
float64_t
get_C
() {
return
m_C
; }
114
// TODO remove if unnecessary here
118
int32_t
get_qpsize
() {
return
svm_proto
()->
get_qpsize
(); }
119
// TODO remove if unnecessary here
123
bool
get_shrinking_enabled
() {
return
svm_proto
()->
get_shrinking_enabled
(); }
124
// TODO remove if unnecessary here
128
float64_t
get_objective
() {
return
svm_proto
()->
get_objective
(); }
129
130
// TODO remove if unnecessary here
134
bool
get_bias_enabled
() {
return
svm_proto
()->
get_bias_enabled
(); }
135
// TODO remove if unnecessary here
139
bool
get_linadd_enabled
() {
return
svm_proto
()->
get_linadd_enabled
(); }
140
// TODO remove if unnecessary here
144
bool
get_batch_computation_enabled
() {
return
svm_proto
()->
get_batch_computation_enabled
(); }
145
146
// TODO remove if unnecessary here
150
void
set_defaults
(int32_t num_sv=0) {
svm_proto
()->
set_defaults
(num_sv); }
151
// TODO remove if unnecessary here
155
void
set_linear_term
(
SGVector<float64_t>
linear_term) {
svm_proto
()->
set_linear_term
(linear_term); }
156
// TODO remove if unnecessary here
160
void
set_C
(
float64_t
C) {
svm_proto
()->
set_C
(C,C);
m_C
= C; }
161
// TODO remove if unnecessary here
165
void
set_epsilon
(
float64_t
eps) {
svm_proto
()->
set_epsilon
(eps); }
166
// TODO remove if unnecessary here
170
void
set_nu
(
float64_t
nue) {
svm_proto
()->
set_nu
(nue); }
171
// TODO remove if unnecessary here
175
void
set_tube_epsilon
(
float64_t
eps) {
svm_proto
()->
set_tube_epsilon
(eps); }
176
// TODO remove if unnecessary here
180
void
set_qpsize
(int32_t qps) {
svm_proto
()->
set_qpsize
(qps); }
181
// TODO remove if unnecessary here
185
void
set_shrinking_enabled
(
bool
enable) {
svm_proto
()->
set_shrinking_enabled
(enable); }
186
// TODO remove if unnecessary here
190
void
set_objective
(
float64_t
v) {
svm_proto
()->
set_objective
(v); }
191
// TODO remove if unnecessary here
195
void
set_bias_enabled
(
bool
enable_bias) {
svm_proto
()->
set_bias_enabled
(enable_bias); }
196
// TODO remove if unnecessary here
200
void
set_linadd_enabled
(
bool
enable) {
svm_proto
()->
set_linadd_enabled
(enable); }
201
// TODO remove if unnecessary here
205
void
set_batch_computation_enabled
(
bool
enable) {
svm_proto
()->
set_batch_computation_enabled
(enable); }
206
208
virtual
const
char
*
get_name
()
const
209
{
210
return
"MulticlassSVM"
;
211
}
212
213
protected
:
214
216
CSVM
*
svm_proto
()
217
{
218
return
dynamic_cast<
CSVM
*
>
(
m_machine
);
219
}
221
SGVector<int32_t>
svm_svs
()
222
{
223
return
svm_proto
()->
m_svs
;
224
}
225
227
virtual
bool
init_machines_for_apply
(
CFeatures
* data);
228
230
virtual
bool
is_acceptable_machine
(
CMachine
*machine)
231
{
232
CSVM
*svm =
dynamic_cast<
CSVM
*
>
(machine);
233
if
(svm == NULL)
234
return
false
;
235
return
true
;
236
}
237
238
private
:
239
240
void
init();
241
242
protected
:
243
245
float64_t
m_C
;
246
};
247
}
248
#endif
SHOGUN
机器学习工具包 - 项目文档