SHOGUN  3.2.1
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
HashedDenseFeatures.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) 2013 Evangelos Anagnostopoulos
8  * Copyright (C) 2013 Evangelos Anagnostopoulos
9  */
10 
11 #ifndef _HASHED_DENSEFEATURES_H__
12 #define _HASHED_DENSEFEATURES_H__
13 
16 
17 namespace shogun
18 {
19 template <class ST> class CDenseFeatures;
20 class CDotFeatures;
21 
25 template <class ST> class CHashedDenseFeatures : public CDotFeatures
26 {
27 public:
28 
35  CHashedDenseFeatures(int32_t size=0, bool use_quadr = false, bool keep_lin_terms = true);
36 
44  CHashedDenseFeatures(CDenseFeatures<ST>* feats, int32_t d, bool use_quadr = false,
45  bool keep_lin_terms = true);
46 
54  CHashedDenseFeatures(SGMatrix<ST> matrix, int32_t dm, bool use_quadr = false,
55  bool keep_lin_terms = true);
56 
66  CHashedDenseFeatures(ST* src, int32_t num_feat, int32_t num_vec, int32_t d,
67  bool use_quadr = false, bool keep_lin_terms = true);
68 
76  CHashedDenseFeatures(CFile* loader, int32_t d, bool use_quadr = false,
77  bool keep_lin_terms = false);
78 
81 
83  virtual CFeatures* duplicate() const;
84 
86  virtual ~CHashedDenseFeatures();
87 
95  virtual int32_t get_dim_feature_space() const;
96 
106  virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df,
107  int32_t vec_idx2);
108 
117  virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2,
118  int32_t vec2_len);
119 
130  virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1,
131  float64_t* vec2, int32_t vec2_len, bool abs_val = false);
132 
138  virtual int32_t get_nnz_features_for_vector(int32_t num);
139 
151  virtual void* get_feature_iterator(int32_t vector_index);
152 
165  virtual bool get_next_feature(int32_t& index, float64_t& value,
166  void* iterator);
167 
173  virtual void free_feature_iterator(void* iterator);
174 
176  virtual const char* get_name() const;
177 
182  virtual EFeatureType get_feature_type() const;
183 
188  virtual EFeatureClass get_feature_class() const;
189 
194  virtual int32_t get_num_vectors() const;
195 
202 
211  static SGSparseVector<ST> hash_vector(SGVector<ST> vec, int32_t dim, bool use_quadratic = false,
212  bool keep_linear_terms = true);
213 
214 private:
215  void init(CDenseFeatures<ST>* feats, int32_t d, bool use_quadr, bool keep_lin_terms);
216 
217 protected:
218 
221 
223  int32_t dim;
224 
227 
230 };
231 }
232 
233 #endif // _HASHED_DENSEFEATURES_H__
CDenseFeatures< ST > * dense_feats
static SGSparseVector< ST > hash_vector(SGVector< ST > vec, int32_t dim, bool use_quadratic=false, bool keep_linear_terms=true)
This class is identical to the CDenseFeatures class except that it hashes each dimension to a new fea...
virtual CFeatures * duplicate() const
Features that support dot products among other operations.
Definition: DotFeatures.h:41
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:35
template class SGSparseVector The assumtion is that the stored SGSparseVectorEntry<T>* vector is orde...
virtual const char * get_name() const
double float64_t
Definition: common.h:48
A File access base class.
Definition: File.h:34
SGSparseVector< ST > get_hashed_feature_vector(int32_t vec_idx)
CHashedDenseFeatures(int32_t size=0, bool use_quadr=false, bool keep_lin_terms=true)
virtual int32_t get_num_vectors() const
virtual bool get_next_feature(int32_t &index, float64_t &value, void *iterator)
virtual EFeatureClass get_feature_class() const
virtual void free_feature_iterator(void *iterator)
EFeatureType
shogun feature type
Definition: FeatureTypes.h:16
virtual float64_t dot(int32_t vec_idx1, CDotFeatures *df, int32_t vec_idx2)
The class DenseFeatures implements dense feature matrices.
Definition: LDA.h:24
shogun matrix
Definition: DenseFeatures.h:27
virtual float64_t dense_dot(int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)
virtual int32_t get_dim_feature_space() const
The class Features is the base class of all feature objects.
Definition: Features.h:62
virtual int32_t get_nnz_features_for_vector(int32_t num)
virtual EFeatureType get_feature_type() const
virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t *vec2, int32_t vec2_len, bool abs_val=false)
virtual void * get_feature_iterator(int32_t vector_index)

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