SHOGUN  v3.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
StreamingDenseFeatures.h
Go to the documentation of this file.
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  * Written (W) 2012 Heiko Strathmann
00009  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
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 {
00028 template<class T> class CStreamingDenseFeatures:
00029     public CStreamingDotFeatures
00030 {
00031 public:
00032 
00040     CStreamingDenseFeatures();
00041 
00050     CStreamingDenseFeatures(CStreamingFile* file, bool is_labelled,
00051             int32_t size);
00052 
00060     CStreamingDenseFeatures(CDenseFeatures<T>* dense_features, float64_t* lab=
00061             NULL);
00062 
00068     ~CStreamingDenseFeatures();
00069 
00079     virtual void set_vector_reader();
00080 
00090     virtual void set_vector_and_label_reader();
00091 
00097     virtual void start_parser();
00098 
00104     virtual void end_parser();
00105 
00110     virtual void reset_stream();
00111 
00120     virtual bool get_next_example();
00121 
00127     SGVector<T> get_vector();
00128 
00136     virtual float64_t get_label();
00137 
00144     virtual void release_example();
00145 
00153     virtual int32_t get_dim_feature_space() const;
00154 
00162     virtual float32_t dot(SGVector<T> vec);
00163 
00174     virtual float32_t dot(CStreamingDotFeatures *df);
00175 
00183     virtual float32_t dense_dot(const float32_t* vec2, int32_t vec2_len);
00184 
00192     virtual float64_t dense_dot(const float64_t* vec2, int32_t vec2_len);
00193 
00203     virtual void add_to_dense_vec(float32_t alpha, float32_t* vec2,
00204             int32_t vec2_len, bool abs_val=false);
00205 
00215     virtual void add_to_dense_vec(float64_t alpha, float64_t* vec2,
00216             int32_t vec2_len, bool abs_val=false);
00217 
00222     virtual int32_t get_nnz_features_for_vector();
00223 
00229     int32_t get_num_features();
00230 
00236     virtual EFeatureType get_feature_type() const;
00237 
00243     virtual EFeatureClass get_feature_class() const;
00244 
00250     virtual CFeatures* duplicate() const;
00251 
00257     virtual const char* get_name() const
00258     {
00259         return "StreamingDenseFeatures";
00260     }
00261 
00267     virtual int32_t get_num_vectors() const;
00268 
00275     virtual CFeatures* get_streamed_features(index_t num_elements);
00276 
00277 private:
00282     void init();
00283 
00291     void init(CStreamingFile *file, bool is_labelled, int32_t size);
00292 
00293 protected:
00294 
00296     float32_t combined_weight;
00297 
00299     CInputParser<T> parser;
00300 
00302     SGVector<T> current_vector;
00303 
00305     float64_t current_label;
00306 };
00307 }
00308 #endif // _STREAMINGDENSEFEATURES__H__
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation