SHOGUN
v3.2.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) 2013 Evangelos Anagnostopoulos 00008 * Copyright (C) 2013 Evangelos Anagnostopoulos 00009 */ 00010 00011 #ifndef _STREAMING_HASHED_DENSEFEATURES__H__ 00012 #define _STREAMING_HASHED_DENSEFEATURES__H__ 00013 00014 #include <shogun/features/DenseFeatures.h> 00015 #include <shogun/features/streaming/StreamingDotFeatures.h> 00016 #include <shogun/io/streaming/InputParser.h> 00017 00018 namespace shogun 00019 { 00020 class CStreamingDotFeatures; 00021 00030 template <class ST> class CStreamingHashedDenseFeatures : public CStreamingDotFeatures 00031 { 00032 public: 00034 CStreamingHashedDenseFeatures(); 00035 00046 CStreamingHashedDenseFeatures(CStreamingFile* file, bool is_labelled, int32_t size, 00047 int32_t d = 512, bool use_quadr = false, bool keep_lin_terms = true); 00048 00064 CStreamingHashedDenseFeatures(CDenseFeatures<ST>* dot_features, int32_t d = 512, 00065 bool use_quadr = false, bool keep_lin_terms = true, float64_t* lab = NULL); 00066 00068 virtual ~CStreamingHashedDenseFeatures(); 00069 00076 virtual float32_t dot(CStreamingDotFeatures* df); 00077 00083 virtual float32_t dense_dot(const float32_t* vec2, int32_t vec2_len); 00084 00092 virtual void add_to_dense_vec(float32_t alpha, float32_t* vec2, 00093 int32_t vec2_len, bool abs_val = false); 00094 00102 virtual int32_t get_dim_feature_space() const; 00103 00109 virtual const char* get_name() const; 00110 00116 virtual int32_t get_num_vectors() const; 00117 00123 virtual CFeatures* duplicate() const; 00124 00134 virtual void set_vector_reader(); 00135 00145 virtual void set_vector_and_label_reader(); 00146 00152 virtual EFeatureType get_feature_type() const; 00153 00159 virtual EFeatureClass get_feature_class() const; 00160 00165 virtual void start_parser(); 00166 00170 virtual void end_parser(); 00171 00179 virtual float64_t get_label(); 00180 00186 virtual bool get_next_example(); 00187 00193 virtual void release_example(); 00194 00200 virtual int32_t get_num_features(); 00201 00206 SGSparseVector<ST> get_vector(); 00207 00208 private: 00209 void init(CStreamingFile* file, bool is_labelled, int32_t size, 00210 int32_t d, bool use_quadr, bool keep_lin_terms); 00211 00212 protected: 00213 00215 int32_t dim; 00216 00218 SGSparseVector<ST> current_vector; 00219 00221 CInputParser<ST> parser; 00222 00224 float64_t current_label; 00225 00227 bool use_quadratic; 00228 00230 bool keep_linear_terms; 00231 }; 00232 } 00233 00234 #endif // _STREAMING_HASHED_DENSEFEATURES__H__