Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _STREAMING_SIMPLEFEATURES__H__
00011 #define _STREAMING_SIMPLEFEATURES__H__
00012
00013 #include <shogun/lib/common.h>
00014 #include <shogun/features/StreamingDotFeatures.h>
00015 #include <shogun/features/SimpleFeatures.h>
00016 #include <shogun/lib/DataType.h>
00017 #include <shogun/io/InputParser.h>
00018
00019 namespace shogun
00020 {
00026 template <class T> class CStreamingSimpleFeatures : public CStreamingDotFeatures
00027 {
00028 public:
00029
00037 CStreamingSimpleFeatures();
00038
00047 CStreamingSimpleFeatures(CStreamingFile* file,
00048 bool is_labelled, int32_t size);
00049
00057 CStreamingSimpleFeatures(CSimpleFeatures<T>* simple_features,
00058 float64_t* lab=NULL);
00059
00065 ~CStreamingSimpleFeatures();
00066
00076 virtual void set_vector_reader();
00077
00087 virtual void set_vector_and_label_reader();
00088
00094 virtual void start_parser();
00095
00101 virtual void end_parser();
00102
00107 virtual void reset_stream();
00108
00117 virtual bool get_next_example();
00118
00124 SGVector<T> get_vector();
00125
00133 virtual float64_t get_label();
00134
00141 virtual void release_example();
00142
00150 virtual int32_t get_dim_feature_space() const;
00151
00159 virtual float32_t dot(SGVector<T> vec);
00160
00171 virtual float32_t dot(CStreamingDotFeatures *df);
00172
00180 virtual float32_t dense_dot(const float32_t* vec2, int32_t vec2_len);
00181
00189 virtual float64_t dense_dot(const float64_t* vec2, int32_t vec2_len);
00190
00200 virtual void add_to_dense_vec(float32_t alpha, float32_t* vec2, int32_t vec2_len , bool abs_val=false);
00201
00211 virtual void add_to_dense_vec(float64_t alpha, float64_t* vec2, int32_t vec2_len , bool abs_val=false);
00212
00217 virtual inline int32_t get_nnz_features_for_vector();
00218
00224 int32_t get_num_features();
00225
00231 virtual inline EFeatureType get_feature_type();
00232
00238 virtual EFeatureClass get_feature_class();
00239
00245 virtual CFeatures* duplicate() const;
00246
00252 inline virtual const char* get_name() const { return "StreamingSimpleFeatures"; }
00253
00259 inline virtual int32_t get_num_vectors() const;
00260
00266 virtual int32_t get_size();
00267
00268 private:
00273 void init();
00274
00282 void init(CStreamingFile *file, bool is_labelled, int32_t size);
00283
00284 protected:
00285
00287 float32_t combined_weight;
00288
00290 CInputParser<T> parser;
00291
00293 SGVector<T> current_sgvector;
00294
00296 T* current_vector;
00297
00299 float64_t current_label;
00300
00302 int32_t current_length;
00303 };
00304 }
00305 #endif // _STREAMING_SIMPLEFEATURES__H__