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
vw
VowpalWabbit.h
Go to the documentation of this file.
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/StreamingVwFeatures.h
>
25
#include <
shogun/machine/OnlineLinearMachine.h
>
26
27
namespace
shogun
28
{
38
class
CVowpalWabbit
:
public
COnlineLinearMachine
39
{
40
public
:
44
CVowpalWabbit
();
45
52
CVowpalWabbit
(
CStreamingVwFeatures
* feat);
53
57
~CVowpalWabbit
();
58
63
void
reinitialize_weights
();
64
73
void
set_no_training
(
bool
dont_train) { no_training = dont_train; }
74
80
void
set_adaptive
(
bool
adaptive_learning);
81
88
void
set_exact_adaptive_norm
(
bool
exact_adaptive);
89
95
void
set_num_passes
(int32_t passes)
96
{
97
env
->
num_passes
= passes;
98
}
99
105
void
load_regressor
(
char
* file_name);
106
113
void
set_regressor_out
(
char
* file_name,
bool
is_text =
true
);
114
120
void
set_prediction_out
(
char
* file_name);
121
128
void
add_quadratic_pair
(
char
* pair);
129
135
virtual
bool
train_machine
(
CFeatures
* feat = NULL);
136
144
virtual
float32_t
predict_and_finalize
(
VwExample
* ex);
145
154
float32_t
compute_exact_norm
(
VwExample
* &ex,
float32_t
& sum_abs_x);
155
168
float32_t
compute_exact_norm_quad
(
float32_t
* weights,
VwFeature
& page_feature,
v_array<VwFeature>
&offer_features,
169
vw_size_t
mask,
float32_t
g,
float32_t
& sum_abs_x);
170
176
virtual
CVwEnvironment
*
get_env
()
177
{
178
SG_REF
(
env
);
179
return
env
;
180
}
181
187
virtual
const
char
*
get_name
()
const
{
return
"VowpalWabbit"
; }
188
189
private
:
195
virtual
void
init(
CStreamingVwFeatures
* feat = NULL);
196
201
virtual
void
set_learner();
202
210
virtual
float32_t
inline_l1_predict(
VwExample
* &ex);
211
219
virtual
float32_t
inline_predict(
VwExample
* &ex);
220
228
virtual
float32_t
finalize_prediction(
float32_t
ret);
229
235
virtual
void
output_example(
VwExample
* &ex);
236
242
virtual
void
print_update(
VwExample
* &ex);
243
252
virtual
void
output_prediction(int32_t f,
float32_t
res,
float32_t
weight,
v_array<char>
tag);
253
259
void
set_verbose(
bool
verbose);
260
261
protected
:
263
CStreamingVwFeatures
*
features
;
264
266
CVwEnvironment
*
env
;
267
269
CVwLearner
*
learner
;
270
272
CVwRegressor
*
reg
;
273
274
private
:
276
bool
quiet;
277
279
bool
no_training;
280
282
float32_t
dump_interval;
284
float32_t
sum_loss_since_last_dump;
286
float64_t
old_weighted_examples;
287
289
char
* reg_name;
291
bool
reg_dump_text;
292
294
bool
save_predictions;
296
int32_t prediction_fd;
297
};
298
299
}
300
#endif // _VOWPALWABBIT_H__
SHOGUN
Machine Learning Toolbox - Documentation