SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
WDFeatures.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) 2009-2010 Soeren Sonnenburg
8  * Copyright (C) 2009 Fraunhofer Institute FIRST and Max-Planck-Society
9  * Copyright (C) 2010 Berlin Institute of Technology
10  */
11 
12 #ifndef _WDFEATURES_H___
13 #define _WDFEATURES_H___
14 
15 #include <shogun/lib/config.h>
16 
17 #include <shogun/lib/common.h>
20 
21 namespace shogun
22 {
23 template <class ST> class CStringFeatures;
24 
30 class CWDFeatures : public CDotFeatures
31 {
32  public:
34  CWDFeatures();
35 
42  CWDFeatures(CStringFeatures<uint8_t>* str, int32_t order, int32_t from_order);
43 
45  CWDFeatures(const CWDFeatures & orig);
46 
48  virtual ~CWDFeatures();
49 
57  virtual int32_t get_dim_feature_space() const;
58 
66  virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df, int32_t vec_idx2);
67 
74  virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len);
75 
84  virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1,
85  float64_t* vec2, int32_t vec2_len, bool abs_val=false);
86 
92  virtual int32_t get_nnz_features_for_vector(int32_t num);
93 
94  #ifndef DOXYGEN_SHOULD_SKIP_THIS
95 
96  struct wd_feature_iterator
97  {
99  uint8_t* vec;
101  int32_t vidx;
103  int32_t vlen;
105  bool vfree;
106 
111  int32_t lim;
112  int32_t* val;
113  int32_t asize;
114  int32_t asizem1;
115  int32_t offs;
116  int32_t k;
117  int32_t i;
118  int32_t o;
120  };
121  #endif
122 
132  virtual void* get_feature_iterator(int32_t vector_index);
133 
144  virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator);
145 
151  virtual void free_feature_iterator(void* iterator);
152 
157  virtual CFeatures* duplicate() const;
158 
163  virtual EFeatureType get_feature_type() const;
164 
169  virtual EFeatureClass get_feature_class() const;
170 
171  virtual int32_t get_num_vectors() const;
172 
176 
179 
181  virtual const char* get_name() const { return "WDFeatures"; }
182 
187  void set_wd_weights(SGVector<float64_t> weights);
188 
190  void set_wd_weights();
191 
192  protected:
195 
197  int32_t degree;
199  int32_t from_degree;
201  int32_t string_length;
203  int32_t num_strings;
205  int32_t alphabet_size;
207  int32_t w_dim;
210 
213 
214 };
215 }
216 #endif // _WDFEATURES_H___
virtual EFeatureClass get_feature_class() const
Definition: WDFeatures.cpp:327
float64_t get_normalization_const()
Definition: WDFeatures.cpp:337
virtual float64_t dense_dot(int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)
Definition: WDFeatures.cpp:119
virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t *vec2, int32_t vec2_len, bool abs_val=false)
Definition: WDFeatures.cpp:157
Features that compute the Weighted Degreee Kernel feature space explicitly.
Definition: WDFeatures.h:30
Features that support dot products among other operations.
Definition: DotFeatures.h:44
virtual float64_t dot(int32_t vec_idx1, CDotFeatures *df, int32_t vec_idx2)
Definition: WDFeatures.cpp:88
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:38
float64_t * wd_weights
Definition: WDFeatures.h:209
virtual int32_t get_dim_feature_space() const
Definition: WDFeatures.cpp:308
void set_normalization_const(float64_t n=0)
Definition: WDFeatures.cpp:212
double float64_t
Definition: common.h:50
virtual const char * get_name() const
Definition: WDFeatures.h:181
virtual bool get_next_feature(int32_t &index, float64_t &value, void *iterator)
Definition: WDFeatures.cpp:256
float64_t normalization_const
Definition: WDFeatures.h:212
EFeatureType
shogun feature type
Definition: FeatureTypes.h:19
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
The class Features is the base class of all feature objects.
Definition: Features.h:68
virtual int32_t get_nnz_features_for_vector(int32_t num)
Definition: WDFeatures.cpp:313
virtual void * get_feature_iterator(int32_t vector_index)
Definition: WDFeatures.cpp:228
CStringFeatures< uint8_t > * strings
Definition: WDFeatures.h:194
virtual CFeatures * duplicate() const
Definition: WDFeatures.cpp:303
virtual int32_t get_num_vectors() const
Definition: WDFeatures.cpp:332
virtual EFeatureType get_feature_type() const
Definition: WDFeatures.cpp:322
virtual void free_feature_iterator(void *iterator)
Definition: WDFeatures.cpp:294
virtual ~CWDFeatures()
Definition: WDFeatures.cpp:82

SHOGUN Machine Learning Toolbox - Documentation