SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Features.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) 1999-2009 Soeren Sonnenburg
8  * Written (W) 1999-2008 Gunnar Raetsch
9  * Subset support written (W) 2011 Heiko Strathmann
10  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
11  */
12 
13 #ifndef _CFEATURES__H__
14 #define _CFEATURES__H__
15 
16 #include <shogun/lib/common.h>
17 #include <shogun/io/File.h>
18 #include <shogun/base/SGObject.h>
21 #include <shogun/features/Subset.h>
22 
23 namespace shogun
24 {
25  class CFile;
26  class CPreprocessor;
27  class CKernel;
28 }
29 
30 namespace shogun
31 {
32 
56 class CFeatures : public CSGObject
57 {
58  void init();
59 
60  public:
65  CFeatures(int32_t size=0);
66 
68  CFeatures(const CFeatures& orig);
69 
74  CFeatures(CFile* loader);
75 
82  virtual CFeatures* duplicate() const=0;
83 
84  virtual ~CFeatures();
85 
92  virtual EFeatureType get_feature_type()=0;
93 
100  virtual EFeatureClass get_feature_class()=0;
101 
107  virtual int32_t add_preprocessor(CPreprocessor* p);
108 
114  virtual CPreprocessor* del_preprocessor(int32_t num);
115 
120  CPreprocessor* get_preprocessor(int32_t num);
121 
126  void set_preprocessed(int32_t num);
127 
132  bool is_preprocessed(int32_t num);
133 
138  int32_t get_num_preprocessed();
139 
144  int32_t get_num_preprocessors() const;
145 
147  void clean_preprocessors();
148 
153  int32_t get_cache_size();
154 
161  virtual int32_t get_num_vectors() const=0;
162 
171  virtual bool reshape(int32_t num_features, int32_t num_vectors);
172 
179  virtual int32_t get_size()=0;
180 
182  void list_feature_obj();
183 
188  virtual void load(CFile* loader);
189 
194  virtual void save(CFile* writer);
195 
202 
209 
215 
221 
227  virtual void set_subset(CSubset* subset);
228 
231  virtual void remove_subset();
232 
234  virtual void subset_changed_post() {}
235 
242 
246  bool has_subset() const;
247 
257  virtual CFeatures* copy_subset(SGVector<index_t> indices);
258 
259  private:
261  uint64_t properties;
262 
264  int32_t cache_size;
265 
267  CPreprocessor** preproc;
268 
270  int32_t num_preproc;
271 
273  bool* preprocessed;
274 
275  protected:
276 
279 };
280 }
281 #endif
bool has_property(EFeatureProperty p)
Definition: Features.cpp:337
class for adding subset support to a class. Provides an interface for getting/setting subset_matrices...
Definition: Subset.h:24
virtual void save(CFile *writer)
Definition: Features.cpp:320
bool is_preprocessed(int32_t num)
Definition: Features.cpp:194
virtual bool reshape(int32_t num_features, int32_t num_vectors)
Definition: Features.cpp:209
bool check_feature_compatibility(CFeatures *f)
Definition: Features.cpp:327
virtual int32_t get_size()=0
virtual EFeatureType get_feature_type()=0
void set_preprocessed(int32_t num)
Definition: Features.cpp:189
void list_feature_obj()
Definition: Features.cpp:215
virtual CPreprocessor * del_preprocessor(int32_t num)
del current preprocessor
Definition: Features.cpp:144
CSubset * m_subset
Definition: Features.h:278
CFeatures(int32_t size=0)
Definition: Features.cpp:22
virtual int32_t get_num_vectors() const =0
void set_property(EFeatureProperty p)
Definition: Features.cpp:342
virtual CFeatures * duplicate() const =0
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:35
int32_t get_num_preprocessors() const
Definition: Features.cpp:199
virtual void subset_changed_post()
Definition: Features.h:234
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:76
virtual EFeatureClass get_feature_class()=0
void unset_property(EFeatureProperty p)
Definition: Features.cpp:347
A File access base class.
Definition: File.h:33
virtual void load(CFile *loader)
Definition: Features.cpp:313
EFeatureType
shogun feature type
Definition: FeatureTypes.h:16
virtual int32_t add_preprocessor(CPreprocessor *p)
set preprocessor
Definition: Features.cpp:82
virtual void remove_subset()
Definition: Features.cpp:370
virtual CFeatures * copy_subset(SGVector< index_t > indices)
Definition: Features.cpp:375
int32_t get_num_preprocessed()
get whether specified preprocessor (or all if num=1) was/were already applied
Definition: Features.cpp:124
CPreprocessor * get_preprocessor(int32_t num)
get current preprocessor
Definition: Features.cpp:112
The class Features is the base class of all feature objects.
Definition: Features.h:56
Class Preprocessor defines a preprocessor interface.
Definition: Preprocessor.h:74
index_t subset_idx_conversion(index_t idx) const
Definition: Features.cpp:360
virtual ~CFeatures()
Definition: Features.cpp:50
void clean_preprocessors()
clears all preprocs
Definition: Features.cpp:138
int32_t get_cache_size()
Definition: Features.cpp:204
int32_t index_t
Definition: DataType.h:25
virtual void set_subset(CSubset *subset)
Definition: Features.cpp:352
bool has_subset() const
Definition: Features.cpp:365
EFeatureProperty
shogun feature properties
Definition: FeatureTypes.h:55

SHOGUN Machine Learning Toolbox - Documentation