SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
StreamingDenseFeatures.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2011 Shashwat Lal Das
8  * Written (W) 2012 Heiko Strathmann
9  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
10  */
11 #ifndef _STREAMINGDENSEFEATURES__H__
12 #define _STREAMINGDENSEFEATURES__H__
13 
14 #include <shogun/lib/config.h>
15 
16 #include <shogun/lib/common.h>
19 #include <shogun/lib/DataType.h>
21 
22 namespace shogun
23 {
30 template<class T> class CStreamingDenseFeatures:
32 {
33 public:
34 
43 
52  CStreamingDenseFeatures(CStreamingFile* file, bool is_labelled,
53  int32_t size);
54 
63  NULL);
64 
71 
81  virtual void set_vector_reader();
82 
92  virtual void set_vector_and_label_reader();
93 
99  virtual void start_parser();
100 
106  virtual void end_parser();
107 
112  virtual void reset_stream();
113 
122  virtual bool get_next_example();
123 
130 
138  virtual float64_t get_label();
139 
146  virtual void release_example();
147 
155  virtual int32_t get_dim_feature_space() const;
156 
164  virtual float32_t dot(SGVector<T> vec);
165 
176  virtual float32_t dot(CStreamingDotFeatures *df);
177 
185  virtual float32_t dense_dot(const float32_t* vec2, int32_t vec2_len);
186 
194  virtual float64_t dense_dot(const float64_t* vec2, int32_t vec2_len);
195 
205  virtual void add_to_dense_vec(float32_t alpha, float32_t* vec2,
206  int32_t vec2_len, bool abs_val=false);
207 
217  virtual void add_to_dense_vec(float64_t alpha, float64_t* vec2,
218  int32_t vec2_len, bool abs_val=false);
219 
224  virtual int32_t get_nnz_features_for_vector();
225 
231  int32_t get_num_features();
232 
238  virtual EFeatureType get_feature_type() const;
239 
245  virtual EFeatureClass get_feature_class() const;
246 
252  virtual CFeatures* duplicate() const;
253 
259  virtual const char* get_name() const
260  {
261  return "StreamingDenseFeatures";
262  }
263 
269  virtual int32_t get_num_vectors() const;
270 
278  virtual CFeatures* get_streamed_features(index_t num_elements);
279 
280 private:
285  void init();
286 
294  void init(CStreamingFile *file, bool is_labelled, int32_t size);
295 
296 protected:
297 
300 
302  CInputParser<T> parser;
303 
306 
309 };
310 }
311 #endif // _STREAMINGDENSEFEATURES__H__
virtual int32_t get_dim_feature_space() const
virtual CFeatures * get_streamed_features(index_t num_elements)
This class implements streaming features with dense feature vectors.
int32_t index_t
Definition: common.h:62
virtual CFeatures * duplicate() const
virtual void add_to_dense_vec(float32_t alpha, float32_t *vec2, int32_t vec2_len, bool abs_val=false)
SGVector< T > current_vector
The current example's feature vector as an SGVector
virtual float32_t dense_dot(const float32_t *vec2, int32_t vec2_len)
virtual EFeatureClass get_feature_class() const
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:38
A Streaming File access class.
Definition: StreamingFile.h:34
CInputParser< T > parser
The parser object, which reads from input and returns parsed example objects.
shogun vector
float32_t combined_weight
feature weighting in combined dot features
double float64_t
Definition: common.h:50
virtual float32_t dot(SGVector< T > vec)
virtual const char * get_name() const
Streaming features that support dot products among other operations.
float64_t current_label
The current example's label.
float float32_t
Definition: common.h:49
EFeatureType
shogun feature type
Definition: FeatureTypes.h:19
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
The class Features is the base class of all feature objects.
Definition: Features.h:68
virtual int32_t get_num_vectors() const
virtual EFeatureType get_feature_type() const

SHOGUN Machine Learning Toolbox - Documentation