Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _STREAMINGDENSEFEATURES__H__
00012 #define _STREAMINGDENSEFEATURES__H__
00013
00014 #include <shogun/lib/common.h>
00015 #include <shogun/features/streaming/StreamingDotFeatures.h>
00016 #include <shogun/features/DenseFeatures.h>
00017 #include <shogun/lib/DataType.h>
00018 #include <shogun/io/streaming/InputParser.h>
00019
00020 namespace shogun
00021 {
00027 template<class T> class CStreamingDenseFeatures:
00028 public CStreamingDotFeatures
00029 {
00030 public:
00031
00039 CStreamingDenseFeatures();
00040
00049 CStreamingDenseFeatures(CStreamingFile* file, bool is_labelled,
00050 int32_t size);
00051
00059 CStreamingDenseFeatures(CDenseFeatures<T>* dense_features, float64_t* lab=
00060 NULL);
00061
00067 ~CStreamingDenseFeatures();
00068
00078 virtual void set_vector_reader();
00079
00089 virtual void set_vector_and_label_reader();
00090
00096 virtual void start_parser();
00097
00103 virtual void end_parser();
00104
00109 virtual void reset_stream();
00110
00119 virtual bool get_next_example();
00120
00126 SGVector<T> get_vector();
00127
00135 virtual float64_t get_label();
00136
00143 virtual void release_example();
00144
00152 virtual int32_t get_dim_feature_space() const;
00153
00161 virtual float32_t dot(SGVector<T> vec);
00162
00173 virtual float32_t dot(CStreamingDotFeatures *df);
00174
00182 virtual float32_t dense_dot(const float32_t* vec2, int32_t vec2_len);
00183
00191 virtual float64_t dense_dot(const float64_t* vec2, int32_t vec2_len);
00192
00202 virtual void add_to_dense_vec(float32_t alpha, float32_t* vec2,
00203 int32_t vec2_len, bool abs_val=false);
00204
00214 virtual void add_to_dense_vec(float64_t alpha, float64_t* vec2,
00215 int32_t vec2_len, bool abs_val=false);
00216
00221 virtual int32_t get_nnz_features_for_vector();
00222
00228 int32_t get_num_features();
00229
00235 virtual EFeatureType get_feature_type() const;
00236
00242 virtual EFeatureClass get_feature_class() const;
00243
00249 virtual CFeatures* duplicate() const;
00250
00256 virtual const char* get_name() const
00257 {
00258 return "StreamingDenseFeatures";
00259 }
00260
00266 virtual int32_t get_num_vectors() const;
00267
00273 virtual int32_t get_size() const;
00274
00281 virtual CFeatures* get_streamed_features(index_t num_elements);
00282
00283 private:
00288 void init();
00289
00297 void init(CStreamingFile *file, bool is_labelled, int32_t size);
00298
00299 protected:
00300
00302 float32_t combined_weight;
00303
00305 CInputParser<T> parser;
00306
00308 SGVector<T> current_vector;
00309
00311 float64_t current_label;
00312 };
00313 }
00314 #endif // _STREAMINGDENSEFEATURES__H__