SHOGUN  3.2.1
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
StreamingSparseFeatures.h
浏览该文件的文档.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2011 Shashwat Lal Das
8  * Modifications (W) 2013 Thoralf Klein
9  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
10  */
11 #ifndef _STREAMING_SPARSEFEATURES__H__
12 #define _STREAMING_SPARSEFEATURES__H__
13 
14 #include <shogun/lib/common.h>
17 #include <shogun/lib/DataType.h>
19 
20 namespace shogun
21 {
44 template <class T> class CStreamingSparseFeatures : public CStreamingDotFeatures
45 {
46 public:
47 
56 
66  bool is_labelled,
67  int32_t size);
68 
74  virtual ~CStreamingSparseFeatures();
75 
85  virtual void set_vector_reader();
86 
96  virtual void set_vector_and_label_reader();
97 
103  virtual void start_parser();
104 
110  virtual void end_parser();
111 
120  virtual bool get_next_example();
121 
128  T get_feature(int32_t index);
129 
136 
144  virtual float64_t get_label();
145 
152  virtual void release_example();
153 
158  virtual void reset_stream();
159 
171  int32_t set_num_features(int32_t num);
172 
180  virtual int32_t get_dim_feature_space() const;
181 
192  virtual float32_t dot(CStreamingDotFeatures *df);
193 
204  static T sparse_dot(T alpha, SGSparseVectorEntry<T>* avec, int32_t alen, SGSparseVectorEntry<T>* bvec, int32_t blen);
205 
215  T dense_dot(T alpha, T* vec, int32_t dim, T b);
216 
225  virtual float64_t dense_dot(const float64_t* vec2, int32_t vec2_len);
226 
235  virtual float32_t dense_dot(const float32_t* vec2, int32_t vec2_len);
236 
246  virtual void add_to_dense_vec(float64_t alpha, float64_t* vec2, int32_t vec2_len, bool abs_val=false);
247 
257  virtual void add_to_dense_vec(float32_t alpha, float32_t* vec2, int32_t vec2_len, bool abs_val=false);
258 
264  int64_t get_num_nonzero_entries();
265 
272 
278  void sort_features();
279 
285  virtual int32_t get_num_features();
286 
292  virtual int32_t get_nnz_features_for_vector();
293 
299  virtual EFeatureType get_feature_type() const;
300 
306  virtual EFeatureClass get_feature_class() const;
307 
313  virtual CFeatures* duplicate() const;
314 
320  virtual const char* get_name() const { return "StreamingSparseFeatures"; }
321 
327  virtual int32_t get_num_vectors() const;
328 
329 private:
334  virtual void init();
335 
343  virtual void init(CStreamingFile *file, bool is_labelled, int32_t size);
344 
345 protected:
347  CInputParser< SGSparseVectorEntry<T> > parser;
348 
351 
354 
357 
360 };
361 
362 }
363 #endif // _STREAMING_SPARSEFEATURES__H__

SHOGUN 机器学习工具包 - 项目文档