SHOGUN  6.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
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/config.h>
20 
21 #include <shogun/lib/common.h>
22 #include <shogun/lib/DataType.h>
24 
31 
32 namespace shogun
33 {
42 {
43 public:
44 
53 
63  bool is_labelled, int32_t size);
64 
74  bool is_labelled, int32_t size);
75 
82 
92  virtual void set_vector_reader();
93 
103  virtual void set_vector_and_label_reader();
104 
110  virtual void start_parser();
111 
117  virtual void end_parser();
118 
123  virtual void reset_stream();
124 
129  virtual CVwEnvironment* get_env();
130 
136  virtual void set_env(CVwEnvironment* vw_env);
137 
146  virtual bool get_next_example();
147 
153  virtual VwExample* get_example();
154 
162  virtual float64_t get_label();
163 
170  virtual void release_example();
171 
180  virtual void expand_if_required(float32_t*& vec, int32_t& len);
181 
190  virtual void expand_if_required(float64_t*& vec, int32_t& len);
191 
199  virtual int32_t get_dim_feature_space() const;
200 
209  virtual float32_t real_weight(float32_t w, float32_t gravity);
210 
221  virtual float32_t dot(CStreamingDotFeatures *df);
222 
231  virtual float32_t dense_dot(VwExample* &ex, const float32_t* vec2);
232 
242  virtual float32_t dense_dot(const float32_t* vec2, int32_t vec2_len);
243 
253  virtual float32_t dense_dot(SGSparseVector<float32_t>* vec1, const float32_t* vec2);
254 
265  virtual float32_t dense_dot_truncated(const float32_t* vec2, VwExample* &ex, float32_t gravity);
266 
277  virtual void add_to_dense_vec(float32_t alpha, VwExample* &ex,
278  float32_t* vec2, int32_t vec2_len, bool abs_val = false);
279 
289  virtual void add_to_dense_vec(float32_t alpha,
290  float32_t* vec2, int32_t vec2_len, bool abs_val = false);
291 
296  virtual int32_t get_nnz_features_for_vector();
297 
303  virtual int32_t get_num_features();
304 
310  virtual EFeatureType get_feature_type() const;
311 
317  virtual EFeatureClass get_feature_class() const;
318 
324  virtual const char* get_name() const { return "StreamingVwFeatures"; }
325 
331  virtual int32_t get_num_vectors() const;
332 
333 private:
338  virtual void init();
339 
347  virtual void init(CStreamingVwFile *file, bool is_labelled, int32_t size);
348 
356  virtual void init(CStreamingVwCacheFile *file, bool is_labelled, int32_t size);
357 
364  virtual void setup_example(VwExample* ae);
365 
366 protected:
367 
370 
373 
376 
378  int32_t current_length;
379 
382 
385 };
386 }
387 #endif // _STREAMING_VWFEATURES__H__
uint32_t vw_size_t
vw_size_t typedef to work across platforms
Definition: vw_constants.h:26
virtual void set_env(CVwEnvironment *vw_env)
virtual EFeatureClass get_feature_class() const
virtual float32_t dot(CStreamingDotFeatures *df)
CVwEnvironment * env
Environment for VW.
Class CVwEnvironment is the environment used by VW.
Definition: VwEnvironment.h:41
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
virtual EFeatureType get_feature_type() const
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:38
virtual float32_t dense_dot_truncated(const float32_t *vec2, VwExample *&ex, float32_t gravity)
float64_t current_label
The current example's label.
virtual const char * get_name() const
virtual CVwEnvironment * get_env()
double float64_t
Definition: common.h:60
virtual int32_t get_nnz_features_for_vector()
virtual float32_t real_weight(float32_t w, float32_t gravity)
Example class for VW.
Definition: vw_example.h:58
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:59
EFeatureType
shogun feature type
Definition: FeatureTypes.h:19
Class StreamingVwFile to read vector-by-vector from Vowpal Wabbit data files. It reads the example an...
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
Class CInputParser is a templated class used to maintain the reading/parsing/providing of examples...
Definition: InputParser.h:85
int32_t current_length
Number of features in current example.
template class SGSparseVector The assumtion is that the stored SGSparseVectorEntry* vector is orde...
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