SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
classifier
svm
OnlineLibLinear.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-2010 Soeren Sonnenburg
8
* Written (W) 2011 Shashwat Lal Das
9
* Modifications (W) 2013 Thoralf Klein
10
* Copyright (c) 2007-2009 The LIBLINEAR Project.
11
* Copyright (C) 2007-2010 Fraunhofer Institute FIRST and Max-Planck-Society
12
*/
13
14
#ifndef _ONLINELIBLINEAR_H__
15
#define _ONLINELIBLINEAR_H__
16
17
#include <
shogun/lib/config.h
>
18
19
#include <
shogun/lib/SGVector.h
>
20
#include <
shogun/lib/common.h
>
21
#include <
shogun/base/Parameter.h
>
22
#include <
shogun/machine/OnlineLinearMachine.h
>
23
24
namespace
shogun
25
{
28
class
COnlineLibLinear
:
public
COnlineLinearMachine
29
{
30
public
:
31
33
MACHINE_PROBLEM_TYPE
(
PT_BINARY
);
34
36
COnlineLibLinear
();
37
43
COnlineLibLinear
(
float64_t
C);
44
51
COnlineLibLinear
(
float64_t
C,
CStreamingDotFeatures
* traindat);
52
57
COnlineLibLinear
(
COnlineLibLinear
*mch);
58
60
virtual
~COnlineLibLinear
();
61
68
virtual
void
set_C
(
float64_t
c_neg,
float64_t
c_pos) { C1=c_neg; C2=c_pos; }
69
75
virtual
float64_t
get_C1
() {
return
C1; }
76
82
float64_t
get_C2
() {
return
C2; }
83
89
virtual
void
set_bias_enabled
(
bool
enable_bias) { use_bias=enable_bias; }
90
96
virtual
bool
get_bias_enabled
() {
return
use_bias; }
97
99
virtual
const
char
*
get_name
()
const
{
return
"OnlineLibLinear"
; }
100
102
virtual
void
start_train
();
103
105
virtual
void
stop_train
();
106
116
virtual
void
train_example
(
CStreamingDotFeatures
*feature,
float64_t
label);
117
122
virtual
void
train_one
(
SGVector<float32_t>
ex,
float64_t
label);
123
128
virtual
void
train_one
(
SGSparseVector<float32_t>
ex,
float64_t
label);
129
130
private
:
132
void
init();
133
134
private
:
136
bool
use_bias;
138
float64_t
C1;
140
float64_t
C2;
141
142
private
:
143
//========================================
144
// "local" variables used during training
145
146
float64_t
C, d, G;
147
float64_t
QD;
148
149
// y and alpha for example being processed
150
int32_t y_current;
151
float64_t
alpha_current;
152
153
// Cost constants
154
float64_t
Cp;
155
float64_t
Cn;
156
157
// PG: projected gradient, for shrinking and stopping
158
float64_t
PG;
159
float64_t
PGmax_old;
160
float64_t
PGmin_old;
161
float64_t
PGmax_new;
162
float64_t
PGmin_new;
163
164
// Diag is probably unnecessary
165
float64_t
diag[3];
166
float64_t
upper_bound[3];
167
168
// Objective value = v/2
169
float64_t
v;
170
// Number of support vectors
171
int32_t nSV;
172
};
173
}
174
#endif // _ONLINELIBLINEAR_H__
SHOGUN
机器学习工具包 - 项目文档