SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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/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 
88  CFeatures* duplicate() const;
89 
99  virtual void set_vector_reader();
100 
110  virtual void set_vector_and_label_reader();
111 
117  virtual void start_parser();
118 
124  virtual void end_parser();
125 
130  virtual void reset_stream();
131 
136  virtual CVwEnvironment* get_env();
137 
143  virtual void set_env(CVwEnvironment* vw_env);
144 
153  virtual bool get_next_example();
154 
160  virtual VwExample* get_example();
161 
169  virtual float64_t get_label();
170 
177  virtual void release_example();
178 
187  virtual void expand_if_required(float32_t*& vec, int32_t& len);
188 
197  virtual void expand_if_required(float64_t*& vec, int32_t& len);
198 
206  virtual int32_t get_dim_feature_space() const;
207 
216  virtual float32_t real_weight(float32_t w, float32_t gravity);
217 
228  virtual float32_t dot(CStreamingDotFeatures *df);
229 
238  virtual float32_t dense_dot(VwExample* &ex, const float32_t* vec2);
239 
249  virtual float32_t dense_dot(const float32_t* vec2, int32_t vec2_len);
250 
260  virtual float32_t dense_dot(SGSparseVector<float32_t>* vec1, const float32_t* vec2);
261 
272  virtual float32_t dense_dot_truncated(const float32_t* vec2, VwExample* &ex, float32_t gravity);
273 
284  virtual void add_to_dense_vec(float32_t alpha, VwExample* &ex,
285  float32_t* vec2, int32_t vec2_len, bool abs_val = false);
286 
296  virtual void add_to_dense_vec(float32_t alpha,
297  float32_t* vec2, int32_t vec2_len, bool abs_val = false);
298 
303  virtual int32_t get_nnz_features_for_vector();
304 
310  virtual int32_t get_num_features();
311 
317  virtual EFeatureType get_feature_type() const;
318 
324  virtual EFeatureClass get_feature_class() const;
325 
331  virtual const char* get_name() const { return "StreamingVwFeatures"; }
332 
338  virtual int32_t get_num_vectors() const;
339 
340 private:
345  virtual void init();
346 
354  virtual void init(CStreamingVwFile *file, bool is_labelled, int32_t size);
355 
363  virtual void init(CStreamingVwCacheFile *file, bool is_labelled, int32_t size);
364 
371  virtual void setup_example(VwExample* ae);
372 
373 protected:
374 
376  CInputParser<VwExample> parser;
377 
380 
383 
385  int32_t current_length;
386 
389 
392 };
393 }
394 #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:50
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:49
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
int32_t current_length
Number of features in current example.
The class Features is the base class of all feature objects.
Definition: Features.h:68
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