Features.h

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 1999-2009 Soeren Sonnenburg
00008  * Written (W) 1999-2008 Gunnar Raetsch
00009  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
00010  */
00011 
00012 #ifndef _CFEATURES__H__
00013 #define _CFEATURES__H__
00014 
00015 #include "lib/common.h"
00016 #include "lib/File.h"
00017 #include "base/SGObject.h"
00018 #include "preproc/PreProc.h"
00019 #include "features/FeatureTypes.h"
00020 
00021 namespace shogun
00022 {
00023     class CFile;
00024     class CPreProc;
00025     class CKernel;
00026     enum EFeatureType;
00027     enum EFeatureClass;
00028     enum EFeatureProperty;
00029 }
00030 
00031 namespace shogun
00032 {
00033 
00053 class CFeatures : public CSGObject
00054 {
00055     void init(void);
00056 
00057     public:
00062         CFeatures(int32_t size=0);
00063 
00065         CFeatures(const CFeatures& orig);
00066 
00071         CFeatures(CFile* loader);
00072 
00079         virtual CFeatures* duplicate() const=0;
00080 
00081         virtual ~CFeatures();
00082 
00089         virtual EFeatureType get_feature_type()=0;
00090 
00097         virtual EFeatureClass get_feature_class()=0;
00098 
00104         virtual int32_t add_preproc(CPreProc* p);
00105 
00111         virtual CPreProc* del_preproc(int32_t num);
00112 
00117         CPreProc* get_preproc(int32_t num);
00118 
00123         inline void set_preprocessed(int32_t num) { preprocessed[num]=true; }
00124 
00129         inline bool is_preprocessed(int32_t num) { return preprocessed[num]; }
00130 
00135         int32_t get_num_preprocessed();
00136 
00141         inline int32_t get_num_preproc() { return num_preproc; }
00142 
00144         void clean_preprocs();
00145 
00150         inline int32_t get_cache_size() { return cache_size; };
00151 
00158         virtual int32_t get_num_vectors()=0 ;
00159 
00168         virtual bool reshape(int32_t num_features, int32_t num_vectors) { return false; }
00169 
00176         virtual int32_t get_size()=0;
00177 
00179         void list_feature_obj();
00180 
00185         virtual void load(CFile* loader)
00186         {
00187             SG_SET_LOCALE_C;
00188             SG_NOTIMPLEMENTED;
00189             SG_RESET_LOCALE;
00190         }
00191 
00196         virtual void save(CFile* writer)
00197         {
00198             SG_SET_LOCALE_C;
00199             SG_NOTIMPLEMENTED;
00200             SG_RESET_LOCALE;
00201         }
00202 
00208         bool check_feature_compatibility(CFeatures* f);
00209 
00215         inline bool has_property(EFeatureProperty p) { return (properties & p) != 0; }
00216 
00221         inline void set_property(EFeatureProperty p)
00222         {
00223             properties |= p;
00224         }
00225 
00230         inline void unset_property(EFeatureProperty p)
00231         {
00232             properties &= (properties | p) ^ p;
00233         }
00234 
00235     private:
00237         uint64_t  properties;
00238 
00240         int32_t cache_size;
00241 
00243         CPreProc** preproc;
00244 
00246         int32_t num_preproc;
00247 
00249         bool* preprocessed;
00250 };
00251 }
00252 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation