SHOGUN  v3.0.0
 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/common.h>
20 #include <shogun/lib/DataType.h>
22 
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 EFeatureType get_feature_type() const;
316 
322  virtual EFeatureClass get_feature_class() const;
323 
329  virtual const char* get_name() const { return "StreamingVwFeatures"; }
330 
336  virtual int32_t get_num_vectors() const;
337 
338 private:
343  virtual void init();
344 
352  virtual void init(CStreamingVwFile *file, bool is_labelled, int32_t size);
353 
361  virtual void init(CStreamingVwCacheFile *file, bool is_labelled, int32_t size);
362 
369  virtual void setup_example(VwExample* ae);
370 
371 protected:
372 
374  CInputParser<VwExample> parser;
375 
378 
381 
383  int32_t current_length;
384 
387 
390 };
391 }
392 #endif // _STREAMING_VWFEATURES__H__

SHOGUN Machine Learning Toolbox - Documentation