SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
classifier
vw
VowpalWabbit.h
浏览该文件的文档.
1
/*
2
* Copyright (c) 2009 Yahoo! Inc. All rights reserved. The copyrights
3
* embodied in the content of this file are licensed under the BSD
4
* (revised) open source license.
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* Written (W) 2011 Shashwat Lal Das
12
* Adaptation of Vowpal Wabbit v5.1.
13
* Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society.
14
*/
15
16
#ifndef _VOWPALWABBIT_H__
17
#define _VOWPALWABBIT_H__
18
19
#include <
shogun/classifier/vw/vw_common.h
>
20
#include <
shogun/classifier/vw/learners/VwAdaptiveLearner.h
>
21
#include <
shogun/classifier/vw/learners/VwNonAdaptiveLearner.h
>
22
#include <
shogun/classifier/vw/VwRegressor.h
>
23
24
#include <
shogun/features/streaming/StreamingVwFeatures.h
>
25
#include <
shogun/machine/OnlineLinearMachine.h
>
26
27
namespace
shogun
28
{
38
class
CVowpalWabbit
:
public
COnlineLinearMachine
39
{
40
public
:
41
43
MACHINE_PROBLEM_TYPE
(
PT_BINARY
);
44
48
CVowpalWabbit
();
49
56
CVowpalWabbit
(
CStreamingVwFeatures
* feat);
57
61
CVowpalWabbit
(
CVowpalWabbit
*vw);
62
66
~CVowpalWabbit
();
67
72
void
reinitialize_weights
();
73
82
void
set_no_training
(
bool
dont_train) { no_training = dont_train; }
83
89
void
set_adaptive
(
bool
adaptive_learning);
90
97
void
set_exact_adaptive_norm
(
bool
exact_adaptive);
98
104
void
set_num_passes
(int32_t passes)
105
{
106
env
->
num_passes
= passes;
107
}
108
114
void
load_regressor
(
char
* file_name);
115
122
void
set_regressor_out
(
char
* file_name,
bool
is_text =
true
);
123
129
void
set_prediction_out
(
char
* file_name);
130
137
void
add_quadratic_pair
(
char
* pair);
138
144
virtual
bool
train_machine
(
CFeatures
* feat = NULL);
145
153
virtual
float32_t
predict_and_finalize
(
VwExample
* ex);
154
163
float32_t
compute_exact_norm
(
VwExample
* &ex,
float32_t
& sum_abs_x);
164
177
float32_t
compute_exact_norm_quad
(
float32_t
* weights,
VwFeature
& page_feature,
v_array<VwFeature>
&offer_features,
178
vw_size_t
mask,
float32_t
g,
float32_t
& sum_abs_x);
179
185
virtual
CVwEnvironment
*
get_env
()
186
{
187
SG_REF
(
env
);
188
return
env
;
189
}
190
196
virtual
const
char
*
get_name
()
const
{
return
"VowpalWabbit"
; }
197
202
virtual
void
set_learner
();
203
207
CVwLearner
*
get_learner
() {
return
learner
; }
208
209
private
:
215
virtual
void
init(
CStreamingVwFeatures
* feat = NULL);
216
224
virtual
float32_t
inline_l1_predict(
VwExample
* &ex);
225
233
virtual
float32_t
inline_predict(
VwExample
* &ex);
234
242
virtual
float32_t
finalize_prediction(
float32_t
ret);
243
249
virtual
void
output_example(
VwExample
* &ex);
250
256
virtual
void
print_update(
VwExample
* &ex);
257
266
virtual
void
output_prediction(int32_t f,
float32_t
res,
float32_t
weight,
v_array<char>
tag);
267
273
void
set_verbose(
bool
verbose);
274
275
protected
:
277
CStreamingVwFeatures
*
features
;
278
280
CVwEnvironment
*
env
;
281
283
CVwLearner
*
learner
;
284
286
CVwRegressor
*
reg
;
287
288
private
:
290
bool
quiet;
291
293
bool
no_training;
294
296
float32_t
dump_interval;
298
float32_t
sum_loss_since_last_dump;
300
float64_t
old_weighted_examples;
301
303
char
* reg_name;
305
bool
reg_dump_text;
306
308
bool
save_predictions;
310
int32_t prediction_fd;
311
};
312
313
}
314
#endif // _VOWPALWABBIT_H__
SHOGUN
机器学习工具包 - 项目文档