SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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  * 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 
28 namespace shogun
29 {
30  class CFile;
31  class CPreprocessor;
32  class CKernel;
33 }
34 
35 namespace shogun
36 {
37 
68 class CFeatures : public CSGObject
69 {
70  public:
75  CFeatures(int32_t size=0);
76 
78  CFeatures(const CFeatures& orig);
79 
84  CFeatures(CFile* loader);
85 
92  virtual CFeatures* duplicate() const=0;
93 
94  virtual ~CFeatures();
95 
102  virtual EFeatureType get_feature_type() const=0;
103 
110  virtual EFeatureClass get_feature_class() const=0;
111 
116  virtual void add_preprocessor(CPreprocessor* p);
117 
122  virtual void del_preprocessor(int32_t num);
123 
128  CPreprocessor* get_preprocessor(int32_t num) const;
129 
134  void set_preprocessed(int32_t num);
135 
140  bool is_preprocessed(int32_t num) const;
141 
146  int32_t get_num_preprocessed() const;
147 
152  int32_t get_num_preprocessors() const;
153 
155  void clean_preprocessors();
156 
158  void list_preprocessors();
159 
164  int32_t get_cache_size() const;
165 
172  virtual int32_t get_num_vectors() const=0;
173 
182  virtual bool reshape(int32_t num_features, int32_t num_vectors);
183 
185  void list_feature_obj() const;
186 
191  virtual void load(CFile* loader);
192 
197  virtual void save(CFile* writer);
198 
204  bool check_feature_compatibility(CFeatures* f) const;
205 
211  bool has_property(EFeatureProperty p) const;
212 
218 
224 
236  {
237  SG_ERROR("%s::create_merged_copy() is not yet implemented!\n")
238  return NULL;
239  }
240 
250  {
251  SG_ERROR("%s::create_merged_copy() is not yet implemented!\n")
252  return NULL;
253  }
254 
265  virtual void add_subset(SGVector<index_t> subset);
266 
276  virtual void add_subset_in_place(SGVector<index_t> subset);
277 
280  virtual void remove_subset();
281 
284  virtual void remove_all_subsets();
285 
290  virtual CSubsetStack* get_subset_stack();
291 
293  virtual void subset_changed_post() {}
294 
304  virtual CFeatures* copy_subset(SGVector<index_t> indices);
305 
316 
323  virtual bool support_compatible_class() const {return false;}
324 
333  virtual bool get_feature_class_compatibility (EFeatureClass rhs) const;
334 
335 #ifndef SWIG // SWIG should skip this part
337  {
339  return NULL;
340  }
341 #endif
342 
343  private:
344  void init();
345 
346  private:
348  uint64_t properties;
349 
351  int32_t cache_size;
352 
354  CDynamicObjectArray* preproc;
355 
357  CDynamicArray<bool>* preprocessed;
358 
359  protected:
362 };
363 }
364 #endif
virtual CFeatures * shallow_subset_copy()
Definition: Features.h:336
virtual bool support_compatible_class() const
Definition: Features.h:323
CSubsetStack * m_subset_stack
Definition: Features.h:361
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:129
#define SG_SNOTIMPLEMENTED
Definition: SGIO.h:198
CPreprocessor * get_preprocessor(int32_t num) const
Definition: Features.cpp:93
virtual CFeatures * duplicate() const =0
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:249
int32_t get_num_preprocessors() const
Definition: Features.cpp:155
virtual CFeatures * create_merged_copy(CList *others)
Definition: Features.h:235
virtual void del_preprocessor(int32_t num)
Definition: Features.cpp:122
virtual void subset_changed_post()
Definition: Features.h:293
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:115
void unset_property(EFeatureProperty p)
Definition: Features.cpp:305
bool is_preprocessed(int32_t num) const
Definition: Features.cpp:149
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:68
Class Preprocessor defines a preprocessor interface.
Definition: Preprocessor.h:75
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