SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StreamingVwFeatures.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 _STREAMING_VWFEATURES__H__
17 #define _STREAMING_VWFEATURES__H__
18 
19 #include <shogun/lib/common.h>
20 #include <shogun/lib/DataType.h>
22 
23 #include <shogun/io/InputParser.h>
29 
30 namespace shogun
31 {
40 {
41 public:
42 
51 
61  bool is_labelled, int32_t size);
62 
72  bool is_labelled, int32_t size);
73 
80 
86  CFeatures* duplicate() const;
87 
97  virtual void set_vector_reader();
98 
108  virtual void set_vector_and_label_reader();
109 
115  virtual void start_parser();
116 
122  virtual void end_parser();
123 
128  virtual void reset_stream();
129 
134  virtual CVwEnvironment* get_env();
135 
141  virtual void set_env(CVwEnvironment* vw_env);
142 
151  virtual bool get_next_example();
152 
158  virtual VwExample* get_example();
159 
167  virtual float64_t get_label();
168 
175  virtual void release_example();
176 
185  virtual void expand_if_required(float32_t*& vec, int32_t& len);
186 
195  virtual void expand_if_required(float64_t*& vec, int32_t& len);
196 
204  virtual int32_t get_dim_feature_space() const;
205 
214  virtual float32_t real_weight(float32_t w, float32_t gravity);
215 
226  virtual float32_t dot(CStreamingDotFeatures *df);
227 
236  virtual float32_t dense_dot(VwExample* &ex, const float32_t* vec2);
237 
247  virtual float32_t dense_dot(const float32_t* vec2, int32_t vec2_len);
248 
258  virtual float32_t dense_dot(SGSparseVector<float32_t>* vec1, const float32_t* vec2);
259 
270  virtual float32_t dense_dot_truncated(const float32_t* vec2, VwExample* &ex, float32_t gravity);
271 
282  virtual void add_to_dense_vec(float32_t alpha, VwExample* &ex,
283  float32_t* vec2, int32_t vec2_len, bool abs_val = false);
284 
294  virtual void add_to_dense_vec(float32_t alpha,
295  float32_t* vec2, int32_t vec2_len, bool abs_val = false);
296 
301  virtual int32_t get_nnz_features_for_vector();
302 
308  virtual int32_t get_num_features();
309 
315  virtual inline EFeatureType get_feature_type();
316 
323 
329  inline virtual const char* get_name() const { return "StreamingVwFeatures"; }
330 
336  inline virtual int32_t get_num_vectors() const;
337 
343  virtual int32_t get_size();
344 
345 private:
350  virtual void init();
351 
359  virtual void init(CStreamingVwFile *file, bool is_labelled, int32_t size);
360 
368  virtual void init(CStreamingVwCacheFile *file, bool is_labelled, int32_t size);
369 
376  virtual void setup_example(VwExample* ae);
377 
378 protected:
379 
382 
385 
388 
390  int32_t current_length;
391 
394 
397 };
398 }
399 #endif // _STREAMING_VWFEATURES__H__
uint32_t vw_size_t
vw_size_t typedef to work across platforms
Definition: vw_constants.h:24
virtual void set_env(CVwEnvironment *vw_env)
virtual float32_t dot(CStreamingDotFeatures *df)
CVwEnvironment * env
Environment for VW.
Class CVwEnvironment is the environment used by VW.
Definition: VwEnvironment.h:39
virtual void add_to_dense_vec(float32_t alpha, VwExample *&ex, float32_t *vec2, int32_t vec2_len, bool abs_val=false)
VwExample * current_example
Example currently being processed.
virtual int32_t get_num_vectors() const
virtual int32_t get_dim_feature_space() const
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:35
template class SGSparseVector
Definition: File.h:22
virtual float32_t dense_dot_truncated(const float32_t *vec2, VwExample *&ex, float32_t gravity)
float64_t current_label
The current example&#39;s label.
virtual const char * get_name() const
virtual CVwEnvironment * get_env()
double float64_t
Definition: common.h:56
virtual EFeatureType get_feature_type()
virtual int32_t get_nnz_features_for_vector()
virtual EFeatureClass get_feature_class()
virtual float32_t real_weight(float32_t w, float32_t gravity)
Example class for VW.
Definition: vw_example.h:56
Streaming features that support dot products among other operations.
Class StreamingVwCacheFile to read vector-by-vector from VW cache files.
This class implements streaming features for use with VW.
float float32_t
Definition: common.h:55
EFeatureType
shogun feature type
Definition: FeatureTypes.h:16
Class StreamingVwFile to read vector-by-vector from Vowpal Wabbit data files. It reads the example an...
Class CInputParser is a templated class used to maintain the reading/parsing/providing of examples...
Definition: InputParser.h:80
int32_t current_length
Number of features in current example.
The class Features is the base class of all feature objects.
Definition: Features.h:56
virtual float32_t dense_dot(VwExample *&ex, const float32_t *vec2)
vw_size_t example_count
Number of examples processed at a point of time.
CInputParser< VwExample > parser
The parser object, which reads from input and returns parsed example objects.
virtual void expand_if_required(float32_t *&vec, int32_t &len)

SHOGUN Machine Learning Toolbox - Documentation