SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
HashedDenseFeatures.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) 2013 Evangelos Anagnostopoulos
8  * Copyright (C) 2013 Evangelos Anagnostopoulos
9  */
10 
11 #ifndef _HASHED_DENSEFEATURES_H__
12 #define _HASHED_DENSEFEATURES_H__
13 
14 #include <shogun/lib/config.h>
15 
18 
19 namespace shogun
20 {
21 template <class ST> class CDenseFeatures;
22 class CDotFeatures;
23 
27 template <class ST> class CHashedDenseFeatures : public CDotFeatures
28 {
29 public:
30 
37  CHashedDenseFeatures(int32_t size=0, bool use_quadr = false, bool keep_lin_terms = true);
38 
46  CHashedDenseFeatures(CDenseFeatures<ST>* feats, int32_t d, bool use_quadr = false,
47  bool keep_lin_terms = true);
48 
56  CHashedDenseFeatures(SGMatrix<ST> matrix, int32_t dm, bool use_quadr = false,
57  bool keep_lin_terms = true);
58 
68  CHashedDenseFeatures(ST* src, int32_t num_feat, int32_t num_vec, int32_t d,
69  bool use_quadr = false, bool keep_lin_terms = true);
70 
78  CHashedDenseFeatures(CFile* loader, int32_t d, bool use_quadr = false,
79  bool keep_lin_terms = false);
80 
83 
85  virtual CFeatures* duplicate() const;
86 
88  virtual ~CHashedDenseFeatures();
89 
97  virtual int32_t get_dim_feature_space() const;
98 
108  virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df,
109  int32_t vec_idx2);
110 
119  virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2,
120  int32_t vec2_len);
121 
132  virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1,
133  float64_t* vec2, int32_t vec2_len, bool abs_val = false);
134 
140  virtual int32_t get_nnz_features_for_vector(int32_t num);
141 
153  virtual void* get_feature_iterator(int32_t vector_index);
154 
167  virtual bool get_next_feature(int32_t& index, float64_t& value,
168  void* iterator);
169 
175  virtual void free_feature_iterator(void* iterator);
176 
178  virtual const char* get_name() const;
179 
184  virtual EFeatureType get_feature_type() const;
185 
190  virtual EFeatureClass get_feature_class() const;
191 
196  virtual int32_t get_num_vectors() const;
197 
204 
213  static SGSparseVector<ST> hash_vector(SGVector<ST> vec, int32_t dim, bool use_quadratic = false,
214  bool keep_linear_terms = true);
215 
216 private:
217  void init(CDenseFeatures<ST>* feats, int32_t d, bool use_quadr, bool keep_lin_terms);
218 
219 protected:
220 
223 
225  int32_t dim;
226 
229 
232 };
233 }
234 
235 #endif // _HASHED_DENSEFEATURES_H__
CDenseFeatures< ST > * dense_feats
The class DenseFeatures implements dense feature matrices.
Definition: LDA.h:41
static SGSparseVector< ST > hash_vector(SGVector< ST > vec, int32_t dim, bool use_quadratic=false, bool keep_linear_terms=true)
This class is identical to the CDenseFeatures class except that it hashes each dimension to a new fea...
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 const char * get_name() const
shogun vector
double float64_t
Definition: common.h:50
A File access base class.
Definition: File.h:34
SGSparseVector< ST > get_hashed_feature_vector(int32_t vec_idx)
CHashedDenseFeatures(int32_t size=0, bool use_quadr=false, bool keep_lin_terms=true)
virtual int32_t get_num_vectors() const
virtual bool get_next_feature(int32_t &index, float64_t &value, void *iterator)
virtual EFeatureClass get_feature_class() const
virtual void free_feature_iterator(void *iterator)
EFeatureType
shogun feature type
Definition: FeatureTypes.h:19
virtual float64_t dot(int32_t vec_idx1, CDotFeatures *df, int32_t vec_idx2)
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual float64_t dense_dot(int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)
virtual int32_t get_dim_feature_space() const
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)
virtual EFeatureType get_feature_type() const
virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t *vec2, int32_t vec2_len, bool abs_val=false)
virtual void * get_feature_iterator(int32_t vector_index)

SHOGUN Machine Learning Toolbox - Documentation