SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StreamingHashedSparseFeatures.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) 2013 Evangelos Anagnostopoulos
8  * Copyright (C) 2013 Evangelos Anagnostopoulos
9  */
10 
11 #ifndef _STREAMING_HASHED_SPARSEFEATURES__H__
12 #define _STREAMING_HASHED_SPARSEFEATURES__H__
13 
14 #include <shogun/lib/config.h>
15 
19 
20 namespace shogun
21 {
22 class CStreamingDotFeatures;
23 
32 template <class ST> class CStreamingHashedSparseFeatures : public CStreamingDotFeatures
33 {
34 public:
37 
48  CStreamingHashedSparseFeatures (CStreamingFile* file, bool is_labelled, int32_t size,
49  int32_t d = 512, bool use_quadr = false, bool keep_lin_terms = true);
50 
66  CStreamingHashedSparseFeatures (CSparseFeatures<ST>* dot_features, int32_t d = 512,
67  bool use_quadr = false, bool keep_lin_terms = true, float64_t* lab = NULL);
68 
71 
78  virtual float32_t dot(CStreamingDotFeatures* df);
79 
85  virtual float32_t dense_dot(const float32_t* vec2, int32_t vec2_len);
86 
94  virtual void add_to_dense_vec(float32_t alpha, float32_t* vec2,
95  int32_t vec2_len, bool abs_val = false);
96 
104  virtual int32_t get_dim_feature_space() const;
105 
111  virtual const char* get_name() const;
112 
118  virtual int32_t get_num_vectors() const;
119 
125  virtual CFeatures* duplicate() const;
126 
136  virtual void set_vector_reader();
137 
147  virtual void set_vector_and_label_reader();
148 
154  virtual EFeatureType get_feature_type() const;
155 
161  virtual EFeatureClass get_feature_class() const;
162 
167  virtual void start_parser();
168 
172  virtual void end_parser();
173 
181  virtual float64_t get_label();
182 
188  virtual bool get_next_example();
189 
195  virtual void release_example();
196 
202  virtual int32_t get_num_features();
203 
209 
210 private:
211  void init(CStreamingFile* file, bool is_labelled, int32_t size,
212  int32_t d, bool use_quadr, bool keep_lin_terms);
213 
214 protected:
215 
217  int32_t dim;
218 
221 
223  CInputParser<SGSparseVectorEntry<ST> > parser;
224 
227 
230 
233 };
234 }
235 
236 #endif // _STREAMING_HASHED_SPARSEFEATURES__H__

SHOGUN Machine Learning Toolbox - Documentation