SHOGUN  4.1.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
DenseSubSamplesFeatures.h
浏览该文件的文档.
1 /*
2  * Copyright (c) The Shogun Machine Learning Toolbox
3  * Written (W) 2015 Wu Lin
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright notice, this
10  * list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
19  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  * The views and conclusions contained in the software and documentation are those
27  * of the authors and should not be interpreted as representing official policies,
28  * either expressed or implied, of the Shogun Development Team.
29  *
30  */
31 
32 #ifndef DENSESUBSAMPLESFEATURES_H
33 #define DENSESUBSAMPLESFEATURES_H
34 
35 #include <shogun/lib/config.h>
36 
39 
40 namespace shogun
41 {
42 
43 template<class ST> class CDenseFeatures;
44 template<class ST> class SGVector;
45 class CDotFeatures;
46 
48 template<class ST> class CDenseSubSamplesFeatures: public CDotFeatures
49 {
50 public:
53 
56 
58  virtual ~CDenseSubSamplesFeatures();
59 
61  virtual const char* get_name() const { return "DenseSubSamplesFeatures"; }
62 
65 
68 
75  virtual CFeatures* duplicate() const;
76 
83  virtual EFeatureType get_feature_type() const;
84 
91  virtual EFeatureClass get_feature_class() const;
92 
99  virtual int32_t get_num_vectors() const;
100 
108  virtual int32_t get_dim_feature_space() const;
109 
117  virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df, int32_t vec_idx2);
118 
125  virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2,
126  int32_t vec2_len);
127 
136  virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1,
137  float64_t* vec2, int32_t vec2_len, bool abs_val=false);
138 
146  virtual int32_t get_nnz_features_for_vector(int32_t num);
147 
157  virtual void* get_feature_iterator(int32_t vector_index);
158 
169  virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator);
170 
176  virtual void free_feature_iterator(void* iterator);
177 
178 
185  virtual bool support_compatible_class() const {return true;}
186 
195  virtual bool get_feature_class_compatibility (EFeatureClass rhs) const;
196 private:
197  /* init */
198  void init();
199 
203  void check_bound(int32_t index);
204 
205  /* full samples */
206  CDenseFeatures<ST> *m_fea;
207 
208  /* the indices of subsamples of m_fea */
209  SGVector<int32_t> m_idx;
210 };
211 } /* shogun */
212 
213 #endif /* DENSESUBSAMPLESFEATURES_H */
214 
void set_subset_idx(SGVector< int32_t > idx)
virtual bool support_compatible_class() const
virtual bool get_next_feature(int32_t &index, float64_t &value, void *iterator)
The class DenseFeatures implements dense feature matrices.
Definition: LDA.h:41
virtual float64_t dot(int32_t vec_idx1, CDotFeatures *df, int32_t vec_idx2)
virtual float64_t dense_dot(int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)
Features that support dot products among other operations.
Definition: DotFeatures.h:44
virtual int32_t get_dim_feature_space() const
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:38
virtual EFeatureType get_feature_type() const
void set_features(CDenseFeatures< ST > *fea)
virtual bool get_feature_class_compatibility(EFeatureClass rhs) const
virtual const char * get_name() const
virtual CFeatures * duplicate() const
double float64_t
Definition: common.h:50
virtual void * get_feature_iterator(int32_t vector_index)
EFeatureType
shogun feature type
Definition: FeatureTypes.h:19
virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t *vec2, int32_t vec2_len, bool abs_val=false)
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 void free_feature_iterator(void *iterator)
virtual int32_t get_nnz_features_for_vector(int32_t num)
virtual EFeatureClass get_feature_class() const

SHOGUN 机器学习工具包 - 项目文档