SHOGUN  6.1.3
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  * Written (W) 2011-2012 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/config.h>
17 
18 #include <shogun/lib/common.h>
19 #include <shogun/io/File.h>
20 #include <shogun/base/SGObject.h>
24 #include <shogun/lib/List.h>
27 #include <shogun/base/range.h>
28 
29 namespace shogun
30 {
31  class CFile;
32  class CPreprocessor;
33  class CKernel;
34 }
35 
36 namespace shogun
37 {
38 
69 class CFeatures : public CSGObject
70 {
71  public:
76  CFeatures(int32_t size=0);
77 
79  CFeatures(const CFeatures& orig);
80 
85  CFeatures(CFile* loader);
86 
93  virtual CFeatures* duplicate() const=0;
94 
95  virtual ~CFeatures();
96 
103  virtual EFeatureType get_feature_type() const=0;
104 
111  virtual EFeatureClass get_feature_class() const=0;
112 
113 #ifndef SWIG
114 
124  {
125  return range(0, get_num_vectors());
126  }
127 #endif
128 
133  virtual void add_preprocessor(CPreprocessor* p);
134 
139  virtual void del_preprocessor(int32_t num);
140 
145  CPreprocessor* get_preprocessor(int32_t num) const;
146 
151  void set_preprocessed(int32_t num);
152 
157  bool is_preprocessed(int32_t num) const;
158 
163  int32_t get_num_preprocessed() const;
164 
169  int32_t get_num_preprocessors() const;
170 
172  void clean_preprocessors();
173 
175  void list_preprocessors();
176 
181  int32_t get_cache_size() const;
182 
189  virtual int32_t get_num_vectors() const=0;
190 
199  virtual bool reshape(int32_t num_features, int32_t num_vectors);
200 
202  void list_feature_obj() const;
203 
208  virtual void load(CFile* loader);
209 
214  virtual void save(CFile* writer);
215 
221  bool check_feature_compatibility(CFeatures* f) const;
222 
228  bool has_property(EFeatureProperty p) const;
229 
235 
241 
253  {
254  SG_ERROR("%s::create_merged_copy() is not yet implemented!\n")
255  return NULL;
256  }
257 
267  {
268  SG_ERROR("%s::create_merged_copy() is not yet implemented!\n")
269  return NULL;
270  }
271 
282  virtual void add_subset(SGVector<index_t> subset);
283 
293  virtual void add_subset_in_place(SGVector<index_t> subset);
294 
297  virtual void remove_subset();
298 
301  virtual void remove_all_subsets();
302 
307  virtual CSubsetStack* get_subset_stack();
308 
310  virtual void subset_changed_post() {}
311 
321  virtual CFeatures* copy_subset(SGVector<index_t> indices);
322 
333 
340  virtual bool support_compatible_class() const {return false;}
341 
350  virtual bool get_feature_class_compatibility (EFeatureClass rhs) const;
351 
352 #ifndef SWIG // SWIG should skip this part
354  {
356  return NULL;
357  }
358 #endif
359 
360  private:
361  void init();
362 
363  private:
365  uint64_t properties;
366 
368  int32_t cache_size;
369 
371  CDynamicObjectArray* preproc;
372 
374  CDynamicArray<bool>* preprocessed;
375 
376  protected:
379 };
380 }
381 #endif
virtual CFeatures * shallow_subset_copy()
Definition: Features.h:353
virtual bool support_compatible_class() const
Definition: Features.h:340
CSubsetStack * m_subset_stack
Definition: Features.h:378
virtual void save(CFile *writer)
Definition: Features.cpp:276
virtual void add_subset_in_place(SGVector< index_t > subset)
Definition: Features.cpp:316
virtual bool reshape(int32_t num_features, int32_t num_vectors)
Definition: Features.cpp:165
virtual bool get_feature_class_compatibility(EFeatureClass rhs) const
Definition: Features.cpp:355
void set_preprocessed(int32_t num)
Definition: Features.cpp:143
CFeatures(int32_t size=0)
Definition: Features.cpp:23
virtual int32_t get_num_vectors() const =0
void set_property(EFeatureProperty p)
Definition: Features.cpp:300
#define SG_ERROR(...)
Definition: SGIO.h:128
#define SG_SNOTIMPLEMENTED
Definition: SGIO.h:172
CPreprocessor * get_preprocessor(int32_t num) const
Definition: Features.cpp:93
virtual CFeatures * duplicate() const =0
Range< T > range(T rend)
Definition: range.h:136
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:38
class to add subset support to another class. A CSubsetStackStack instance should be added and wrappe...
Definition: SubsetStack.h:37
virtual CFeatures * create_merged_copy(CFeatures *other)
Definition: Features.h:266
int32_t get_num_preprocessors() const
Definition: Features.cpp:155
virtual CFeatures * create_merged_copy(CList *others)
Definition: Features.h:252
virtual void del_preprocessor(int32_t num)
Definition: Features.cpp:122
virtual void subset_changed_post()
Definition: Features.h:310
bool check_feature_compatibility(CFeatures *f) const
Definition: Features.cpp:283
void list_feature_obj() const
Definition: Features.cpp:171
virtual CSubsetStack * get_subset_stack()
Definition: Features.cpp:334
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:124
void unset_property(EFeatureProperty p)
Definition: Features.cpp:305
bool is_preprocessed(int32_t num) const
Definition: Features.cpp:149
virtual Range< int32_t > index_iterator() const
Definition: Features.h:123
A File access base class.
Definition: File.h:34
virtual EFeatureClass get_feature_class() const =0
Dynamic array class for CSGObject pointers that creates an array that can be used like a list or an a...
virtual void load(CFile *loader)
Definition: Features.cpp:269
EFeatureType
shogun feature type
Definition: FeatureTypes.h:19
virtual void add_preprocessor(CPreprocessor *p)
Definition: Features.cpp:85
virtual CFeatures * copy_dimension_subset(SGVector< index_t > dims)
Definition: Features.cpp:348
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual void remove_subset()
Definition: Features.cpp:322
int32_t get_num_preprocessed() const
Definition: Features.cpp:103
int32_t get_cache_size() const
Definition: Features.cpp:160
virtual CFeatures * copy_subset(SGVector< index_t > indices)
Definition: Features.cpp:340
The class Features is the base class of all feature objects.
Definition: Features.h:69
Class Preprocessor defines a preprocessor interface.
Definition: Preprocessor.h:74
virtual ~CFeatures()
Definition: Features.cpp:53
void clean_preprocessors()
Definition: Features.cpp:116
bool has_property(EFeatureProperty p) const
Definition: Features.cpp:295
virtual void remove_all_subsets()
Definition: Features.cpp:328
EFeatureProperty
shogun feature properties
Definition: FeatureTypes.h:65
void list_preprocessors()
Definition: Features.cpp:131
virtual void add_subset(SGVector< index_t > subset)
Definition: Features.cpp:310
virtual EFeatureType get_feature_type() const =0
Class List implements a doubly connected list for low-level-objects.
Definition: List.h:84

SHOGUN Machine Learning Toolbox - Documentation