SHOGUN  v3.2.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 
SparsePolyFeatures.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) 2010 Soeren Sonnenburg
8  * Copyright (C) 2010 Berlin Institute of Technology
9  */
10 #ifndef _SPARSEPOLYFEATURES__H__
11 #define _SPARSEPOLYFEATURES__H__
12 
13 #include <shogun/lib/common.h>
16 
17 namespace shogun
18 {
25 {
26  public:
29 
38  CSparsePolyFeatures(CSparseFeatures<float64_t>* feat, int32_t degree, bool normalize, int32_t hash_bits);
39 
40  virtual ~CSparsePolyFeatures();
41 
49 
54  virtual int32_t get_dim_feature_space() const;
55 
61  virtual int32_t get_nnz_features_for_vector(int32_t num);
62 
67  virtual EFeatureType get_feature_type() const;
68 
73  virtual EFeatureClass get_feature_class() const;
74 
79  virtual int32_t get_num_vectors() const;
80 
88  virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df, int32_t vec_idx2);
89 
90  #ifndef DOXYGEN_SHOULD_SKIP_THIS
91 
92  struct sparse_poly_feature_iterator
93  {
95  uint16_t* vec;
97  int32_t vidx;
99  int32_t vlen;
101  bool vfree;
102 
104  int32_t index;
105  };
106  #endif
107 
117  virtual void* get_feature_iterator(int32_t vector_index);
118 
129  bool get_next_feature(int32_t& index, float64_t& value, void* iterator);
130 
136  void free_feature_iterator(void* iterator);
137 
142  CFeatures* duplicate() const;
143 
148  virtual const char* get_name() const { return "SparsePolyFeatures"; }
149 
157  virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len);
158 
167  virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t* vec2, int32_t vec2_len, bool abs_val=false);
168 
169  protected:
172 
173  protected:
177  int32_t m_degree;
187  uint32_t mask;
189  int32_t m_hash_bits;
190  private:
192  void init();
193 
194  private:
196  int32_t m_normalization_values_len;
197 };
198 }
199 #endif // _SPARSEPOLYFEATURES__H__
virtual EFeatureClass get_feature_class() const
CSparseFeatures< float64_t > * m_feat
void free_feature_iterator(void *iterator)
virtual float64_t dot(int32_t vec_idx1, CDotFeatures *df, int32_t vec_idx2)
virtual void * get_feature_iterator(int32_t vector_index)
Features that support dot products among other operations.
Definition: DotFeatures.h:41
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:35
virtual const char * get_name() const
virtual int32_t get_dim_feature_space() const
virtual float64_t dense_dot(int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)
double float64_t
Definition: common.h:48
virtual EFeatureType get_feature_type() const
EFeatureType
shogun feature type
Definition: FeatureTypes.h:16
bool get_next_feature(int32_t &index, float64_t &value, void *iterator)
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:16
virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t *vec2, int32_t vec2_len, bool abs_val=false)
The class Features is the base class of all feature objects.
Definition: Features.h:62
virtual int32_t get_num_vectors() const
implement DotFeatures for the polynomial kernel
virtual int32_t get_nnz_features_for_vector(int32_t num)

SHOGUN Machine Learning Toolbox - Documentation