SHOGUN
v2.0.0
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 2011 Shashwat Lal Das 00008 * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society 00009 */ 00010 #ifndef _STREAMINGDENSEFEATURES__H__ 00011 #define _STREAMINGDENSEFEATURES__H__ 00012 00013 #include <shogun/lib/common.h> 00014 #include <shogun/features/streaming/StreamingDotFeatures.h> 00015 #include <shogun/features/DenseFeatures.h> 00016 #include <shogun/lib/DataType.h> 00017 #include <shogun/io/streaming/InputParser.h> 00018 00019 namespace shogun 00020 { 00026 template <class T> class CStreamingDenseFeatures : public CStreamingDotFeatures 00027 { 00028 public: 00029 00037 CStreamingDenseFeatures(); 00038 00047 CStreamingDenseFeatures(CStreamingFile* file, 00048 bool is_labelled, int32_t size); 00049 00057 CStreamingDenseFeatures(CDenseFeatures<T>* dense_features, 00058 float64_t* lab=NULL); 00059 00065 ~CStreamingDenseFeatures(); 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() const; 00232 00238 virtual EFeatureClass get_feature_class() const; 00239 00245 virtual CFeatures* duplicate() const; 00246 00252 inline virtual const char* get_name() const { return "StreamingDenseFeatures"; } 00253 00259 inline virtual int32_t get_num_vectors() const; 00260 00266 virtual int32_t get_size() const; 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 // _STREAMINGDENSEFEATURES__H__