SHOGUN  5.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
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/lib/config.h>
20 
25 
28 
29 namespace shogun
30 {
41 {
42 public:
43 
46 
50  CVowpalWabbit();
51 
59 
64 
69 
74  void reinitialize_weights();
75 
84  void set_no_training(bool dont_train) { no_training = dont_train; }
85 
91  void set_adaptive(bool adaptive_learning);
92 
99  void set_exact_adaptive_norm(bool exact_adaptive);
100 
106  void set_num_passes(int32_t passes)
107  {
108  env->num_passes = passes;
109  }
110 
116  void load_regressor(char* file_name);
117 
124  void set_regressor_out(char* file_name, bool is_text = true);
125 
131  void set_prediction_out(char* file_name);
132 
139  void add_quadratic_pair(char* pair);
140 
146  virtual bool train_machine(CFeatures* feat = NULL);
147 
156 
166 
179  float32_t compute_exact_norm_quad(float32_t* weights, VwFeature& page_feature, v_array<VwFeature> &offer_features,
180  vw_size_t mask, float32_t g, float32_t& sum_abs_x);
181 
188  {
189  SG_REF(env);
190  return env;
191  }
192 
198  virtual const char* get_name() const { return "VowpalWabbit"; }
199 
204  virtual void set_learner();
205 
210 
211 private:
217  virtual void init(CStreamingVwFeatures* feat = NULL);
218 
226  virtual float32_t inline_l1_predict(VwExample* &ex);
227 
235  virtual float32_t inline_predict(VwExample* &ex);
236 
244  virtual float32_t finalize_prediction(float32_t ret);
245 
251  virtual void output_example(VwExample* &ex);
252 
258  virtual void print_update(VwExample* &ex);
259 
268  virtual void output_prediction(int32_t f, float32_t res, float32_t weight, v_array<char> tag);
269 
275  void set_verbose(bool verbose);
276 
277 protected:
280 
283 
286 
289 
290 private:
292  bool quiet;
293 
295  bool no_training;
296 
298  float32_t dump_interval;
300  float32_t sum_loss_since_last_dump;
302  float64_t old_weighted_examples;
303 
305  char* reg_name;
307  bool reg_dump_text;
308 
310  bool save_predictions;
312  int32_t prediction_fd;
313 };
314 
315 }
316 #endif // _VOWPALWABBIT_H__
uint32_t vw_size_t
vw_size_t typedef to work across platforms
Definition: vw_constants.h:26
CVwRegressor * reg
Regressor.
Definition: VowpalWabbit.h:288
Class OnlineLinearMachine is a generic interface for linear machines like classifiers which work thro...
void set_adaptive(bool adaptive_learning)
virtual CVwEnvironment * get_env()
Definition: VowpalWabbit.h:187
void set_prediction_out(char *file_name)
Class CVwEnvironment is the environment used by VW.
Definition: VwEnvironment.h:41
CVwLearner * get_learner()
Definition: VowpalWabbit.h:209
void set_num_passes(int32_t passes)
Definition: VowpalWabbit.h:106
Class v_array taken directly from JL's implementation.
CVwEnvironment * env
Environment for VW, i.e., globals.
Definition: VowpalWabbit.h:282
#define SG_REF(x)
Definition: SGObject.h:54
float32_t compute_exact_norm_quad(float32_t *weights, VwFeature &page_feature, v_array< VwFeature > &offer_features, vw_size_t mask, float32_t g, float32_t &sum_abs_x)
void load_regressor(char *file_name)
virtual void set_learner()
MACHINE_PROBLEM_TYPE(PT_BINARY)
double float64_t
Definition: common.h:50
float32_t compute_exact_norm(VwExample *&ex, float32_t &sum_abs_x)
Base class for all VW learners.
Definition: VwLearner.h:35
vw_size_t num_passes
Number of passes.
Regressor used by VW.
Definition: VwRegressor.h:37
void set_exact_adaptive_norm(bool exact_adaptive)
Example class for VW.
Definition: vw_example.h:58
virtual float32_t predict_and_finalize(VwExample *ex)
This class implements streaming features for use with VW.
void set_regressor_out(char *file_name, bool is_text=true)
float float32_t
Definition: common.h:49
One feature in VW.
Definition: vw_example.h:34
virtual const char * get_name() const
Definition: VowpalWabbit.h:198
void set_no_training(bool dont_train)
Definition: VowpalWabbit.h:84
virtual bool train_machine(CFeatures *feat=NULL)
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
CStreamingVwFeatures * features
Features.
Definition: VowpalWabbit.h:279
The class Features is the base class of all feature objects.
Definition: Features.h:68
void add_quadratic_pair(char *pair)
Class CVowpalWabbit is the implementation of the online learning algorithm used in Vowpal Wabbit...
Definition: VowpalWabbit.h:40
CVwLearner * learner
Learner to use.
Definition: VowpalWabbit.h:285

SHOGUN Machine Learning Toolbox - Documentation