SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
classifier
svm
SVMOcas.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) 2007-2009 Vojtech Franc
8
* Written (W) 2007-2009 Soeren Sonnenburg
9
* Copyright (C) 2007-2009 Fraunhofer Institute FIRST and Max-Planck-Society
10
*/
11
12
#ifndef _SVMOCAS_H___
13
#define _SVMOCAS_H___
14
15
#include <
shogun/lib/common.h
>
16
#include <
shogun/machine/LinearMachine.h
>
17
#include <shogun/lib/external/libocas.h>
18
#include <
shogun/features/DotFeatures.h
>
19
#include <
shogun/labels/Labels.h
>
20
21
namespace
shogun
22
{
23
#ifndef DOXYGEN_SHOULD_SKIP_THIS
24
enum
E_SVM_TYPE
25
{
26
SVM_OCAS = 0,
27
SVM_BMRM = 1
28
};
29
#endif
30
32
class
CSVMOcas
:
public
CLinearMachine
33
{
34
public
:
35
37
MACHINE_PROBLEM_TYPE
(
PT_BINARY
);
38
40
CSVMOcas
();
41
46
CSVMOcas
(E_SVM_TYPE type);
47
54
CSVMOcas
(
55
float64_t
C,
CDotFeatures
* traindat,
56
CLabels
* trainlab);
57
virtual
~CSVMOcas
();
58
63
virtual
EMachineType
get_classifier_type
() {
return
CT_SVMOCAS
; }
64
71
inline
void
set_C
(
float64_t
c_neg,
float64_t
c_pos) {
C1
=c_neg;
C2
=c_pos; }
72
77
inline
float64_t
get_C1
() {
return
C1
; }
78
83
inline
float64_t
get_C2
() {
return
C2
; }
84
89
inline
void
set_epsilon
(
float64_t
eps) {
epsilon
=eps; }
90
95
inline
float64_t
get_epsilon
() {
return
epsilon
; }
96
101
inline
void
set_bias_enabled
(
bool
enable_bias) {
use_bias
=enable_bias; }
102
107
inline
bool
get_bias_enabled
() {
return
use_bias
; }
108
113
inline
void
set_bufsize
(int32_t sz) {
bufsize
=sz; }
114
119
inline
int32_t
get_bufsize
() {
return
bufsize
; }
120
125
virtual
float64_t
compute_primal_objective
()
const
;
126
127
protected
:
136
static
void
compute_W
(
137
float64_t
*sq_norm_W,
float64_t
*dp_WoldW,
float64_t
*alpha,
138
uint32_t nSel,
void
* ptr);
139
146
static
float64_t
update_W
(
float64_t
t,
void
* ptr );
147
156
static
int
add_new_cut
(
157
float64_t
*new_col_H, uint32_t *new_cut, uint32_t cut_length,
158
uint32_t nSel,
void
* ptr );
159
165
static
int
compute_output
(
float64_t
*output,
void
* ptr );
166
173
static
int
sort
(
float64_t
* vals,
float64_t
* data, uint32_t size);
174
176
static
inline
void
print
(ocas_return_value_T value)
177
{
178
return
;
179
}
180
181
protected
:
190
virtual
bool
train_machine
(
CFeatures
* data=NULL);
191
193
inline
const
char
*
get_name
()
const
{
return
"SVMOcas"
; }
194
private
:
195
void
init();
196
197
protected
:
199
bool
use_bias
;
201
int32_t
bufsize
;
203
float64_t
C1
;
205
float64_t
C2
;
207
float64_t
epsilon
;
209
E_SVM_TYPE
method
;
210
212
float64_t
*
old_w
;
214
float64_t
old_bias
;
216
float64_t
*
tmp_a_buf
;
218
SGVector<float64_t>
lab
;
219
222
float64_t
**
cp_value
;
224
uint32_t**
cp_index
;
226
uint32_t*
cp_nz_dims
;
228
float64_t
*
cp_bias
;
229
231
float64_t
primal_objective
;
232
};
233
}
234
#endif
SHOGUN
机器学习工具包 - 项目文档