SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SparsePolyFeatures.h
Go to the documentation of this file.
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/config.h>
14 
15 #include <shogun/lib/common.h>
18 
19 namespace shogun
20 {
27 {
28  public:
31 
40  CSparsePolyFeatures(CSparseFeatures<float64_t>* feat, int32_t degree, bool normalize, int32_t hash_bits);
41 
42  virtual ~CSparsePolyFeatures();
43 
51 
56  virtual int32_t get_dim_feature_space() const;
57 
63  virtual int32_t get_nnz_features_for_vector(int32_t num);
64 
69  virtual EFeatureType get_feature_type() const;
70 
75  virtual EFeatureClass get_feature_class() const;
76 
81  virtual int32_t get_num_vectors() const;
82 
90  virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df, int32_t vec_idx2);
91 
92  #ifndef DOXYGEN_SHOULD_SKIP_THIS
93 
94  struct sparse_poly_feature_iterator
95  {
97  uint16_t* vec;
99  int32_t vidx;
101  int32_t vlen;
103  bool vfree;
104 
106  int32_t index;
107  };
108  #endif
109 
119  virtual void* get_feature_iterator(int32_t vector_index);
120 
131  bool get_next_feature(int32_t& index, float64_t& value, void* iterator);
132 
138  void free_feature_iterator(void* iterator);
139 
144  CFeatures* duplicate() const;
145 
150  virtual const char* get_name() const { return "SparsePolyFeatures"; }
151 
159  virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len);
160 
169  virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t* vec2, int32_t vec2_len, bool abs_val=false);
170 
171  protected:
174 
175  protected:
179  int32_t m_degree;
189  uint32_t mask;
191  int32_t m_hash_bits;
192  private:
194  void init();
195 
196  private:
198  int32_t m_normalization_values_len;
199 };
200 }
201 #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:44
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:38
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:50
virtual EFeatureType get_feature_type() const
EFeatureType
shogun feature type
Definition: FeatureTypes.h:19
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:18
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:68
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