SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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__

SHOGUN Machine Learning Toolbox - Documentation