SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
HashedWDFeaturesTransposed.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 
11 #ifndef _HASHEDWDFEATURESTRANSPOSED_H___
12 #define _HASHEDWDFEATURESTRANSPOSED_H___
13 
14 #include <shogun/lib/config.h>
15 
16 #include <shogun/lib/common.h>
19 #include <shogun/lib/Hash.h>
20 
21 namespace shogun
22 {
23 template <class ST> class CStringFeatures;
24 
31 {
32  public:
35 
44  CHashedWDFeaturesTransposed(CStringFeatures<uint8_t>* str, int32_t start_order,
45  int32_t order, int32_t from_order, int32_t hash_bits=12);
46 
49 
52 
60  virtual int32_t get_dim_feature_space() const
61  {
62  return w_dim;
63  }
64 
72  virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df, int32_t vec_idx2);
73 
80  virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len);
81 
93  virtual void dense_dot_range(float64_t* output, int32_t start, int32_t stop, float64_t* alphas, float64_t* vec, int32_t dim, float64_t b);
94 
106  virtual void dense_dot_range_subset(int32_t* sub_index, int32_t num, float64_t* output, float64_t* alphas, float64_t* vec, int32_t dim, float64_t b);
107 
108 
117  virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t* vec2, int32_t vec2_len, bool abs_val=false);
118 
124  virtual int32_t get_nnz_features_for_vector(int32_t num)
125  {
126  return w_dim/alphabet_size;
127  }
128 
133  virtual CFeatures* duplicate() const;
134 
140  {
141  return F_UNKNOWN;
142  }
143 
149  {
150  return C_WD;
151  }
152 
153  virtual int32_t get_num_vectors() const
154  {
155  return num_strings;
156  }
157 
161 
164  {
165  return normalization_const;
166  }
167 
168  #ifndef DOXYGEN_SHOULD_SKIP_THIS
169 
170  struct hashed_wd_transposed_feature_iterator
171  {
173  uint16_t* vec;
175  int32_t vidx;
177  int32_t vlen;
179  bool vfree;
180 
182  int32_t index;
183 
184  };
185  #endif
186 
196  virtual void* get_feature_iterator(int32_t vector_index);
197 
208  virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator);
209 
215  virtual void free_feature_iterator(void* iterator);
216 
218  virtual const char* get_name() const { return "HashedWDFeaturesTransposed"; }
219 
220  protected:
221 
223  void set_wd_weights();
224 
226  static void* dense_dot_range_helper(void* p);
227 
228  protected:
231 
234 
236  int32_t degree;
238  int32_t start_degree;
240  int32_t from_degree;
242  int32_t string_length;
244  int32_t num_strings;
246  int32_t alphabet_size;
248  int32_t w_dim;
250  int32_t partial_w_dim;
254  uint32_t mask;
256  int32_t m_hash_bits;
257 
260 };
261 }
262 #endif // _HASHEDWDFEATURESTRANSPOSED_H___
virtual void free_feature_iterator(void *iterator)
virtual int32_t get_nnz_features_for_vector(int32_t num)
virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t *vec2, int32_t vec2_len, bool abs_val=false)
Features that support dot products among other operations.
Definition: DotFeatures.h:44
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:38
virtual void * get_feature_iterator(int32_t vector_index)
double float64_t
Definition: common.h:50
virtual EFeatureClass get_feature_class() const
virtual float64_t dot(int32_t vec_idx1, CDotFeatures *df, int32_t vec_idx2)
EFeatureType
shogun feature type
Definition: FeatureTypes.h:19
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual bool get_next_feature(int32_t &index, float64_t &value, void *iterator)
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)
Features that compute the Weighted Degreee Kernel feature space explicitly.
virtual EFeatureType get_feature_type() const
virtual void dense_dot_range_subset(int32_t *sub_index, int32_t num, float64_t *output, float64_t *alphas, float64_t *vec, int32_t dim, float64_t b)
virtual void dense_dot_range(float64_t *output, int32_t start, int32_t stop, float64_t *alphas, float64_t *vec, int32_t dim, float64_t b)

SHOGUN Machine Learning Toolbox - Documentation