SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ExplicitSpecFeatures.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 Soeren Sonnenburg
8  * Copyright (C) 2009 Fraunhofer Institute FIRST and Max-Planck-Society
9  */
10 
11 #ifndef _EXPLICITSPECFEATURES_H___
12 #define _EXPLICITSPECFEATURES_H___
13 
14 #include <shogun/lib/config.h>
15 
16 #include <shogun/lib/common.h>
19 
20 namespace shogun
21 {
22 template <class ST> class CStringFeatures;
23 
29 {
30  public:
33 
39  CExplicitSpecFeatures(CStringFeatures<uint16_t>* str, bool normalize=true);
40 
43 
45  virtual ~CExplicitSpecFeatures();
46 
51  virtual CFeatures* duplicate() const;
52 
60  virtual int32_t get_dim_feature_space() const;
61 
69  virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df, int32_t vec_idx2);
70 
77  virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len);
78 
87  virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1,
88  float64_t* vec2, int32_t vec2_len, bool abs_val=false);
89 
90  #ifndef DOXYGEN_SHOULD_SKIP_THIS
91 
92  struct explicit_spec_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  };
107  #endif
108 
118  virtual void* get_feature_iterator(int32_t vector_index);
119 
130  virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator);
131 
137  virtual void free_feature_iterator(void* iterator);
138 
144  virtual int32_t get_nnz_features_for_vector(int32_t num);
145 
150  virtual EFeatureType get_feature_type() const;
151 
156  virtual EFeatureClass get_feature_class() const;
157 
162  virtual int32_t get_num_vectors() const;
163 
165  virtual const char* get_name() const { return "ExplicitSpecFeatures"; }
166 
167  protected:
173 
175  void delete_kmer_spectrum();
176 
177  protected:
181  int32_t num_strings;
183  int32_t alphabet_size;
184 
186  int32_t spec_size;
189 };
190 }
191 #endif // _EXPLICITSPECFEATURES_H___
void obtain_kmer_spectrum(CStringFeatures< uint16_t > *str)
virtual const char * get_name() const
virtual float64_t dot(int32_t vec_idx1, CDotFeatures *df, int32_t vec_idx2)
virtual bool get_next_feature(int32_t &index, float64_t &value, void *iterator)
virtual int32_t get_dim_feature_space() const
virtual CFeatures * duplicate() const
Features that support dot products among other operations.
Definition: DotFeatures.h:44
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:38
virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t *vec2, int32_t vec2_len, bool abs_val=false)
double float64_t
Definition: common.h:50
virtual int32_t get_num_vectors() const
Features that compute the Spectrum Kernel feature space explicitly.
virtual EFeatureType get_feature_type() const
EFeatureType
shogun feature type
Definition: FeatureTypes.h:19
virtual void free_feature_iterator(void *iterator)
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 float64_t dense_dot(int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)
virtual int32_t get_nnz_features_for_vector(int32_t num)
virtual EFeatureClass get_feature_class() const
virtual void * get_feature_iterator(int32_t vector_index)

SHOGUN Machine Learning Toolbox - Documentation