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 * Subset support written (W) 2011 Heiko Strathmann 00010 * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society 00011 */ 00012 00013 #ifndef _CFEATURES__H__ 00014 #define _CFEATURES__H__ 00015 00016 #include <shogun/lib/common.h> 00017 #include <shogun/io/File.h> 00018 #include <shogun/base/SGObject.h> 00019 #include <shogun/preprocessor/Preprocessor.h> 00020 #include <shogun/features/FeatureTypes.h> 00021 #include <shogun/features/Subset.h> 00022 00023 namespace shogun 00024 { 00025 class CFile; 00026 class CPreprocessor; 00027 class CKernel; 00028 } 00029 00030 namespace shogun 00031 { 00032 00056 class CFeatures : public CSGObject 00057 { 00058 void init(); 00059 00060 public: 00065 CFeatures(int32_t size=0); 00066 00068 CFeatures(const CFeatures& orig); 00069 00074 CFeatures(CFile* loader); 00075 00082 virtual CFeatures* duplicate() const=0; 00083 00084 virtual ~CFeatures(); 00085 00092 virtual EFeatureType get_feature_type()=0; 00093 00100 virtual EFeatureClass get_feature_class()=0; 00101 00107 virtual int32_t add_preprocessor(CPreprocessor* p); 00108 00114 virtual CPreprocessor* del_preprocessor(int32_t num); 00115 00120 CPreprocessor* get_preprocessor(int32_t num); 00121 00126 void set_preprocessed(int32_t num); 00127 00132 bool is_preprocessed(int32_t num); 00133 00138 int32_t get_num_preprocessed(); 00139 00144 int32_t get_num_preprocessors() const; 00145 00147 void clean_preprocessors(); 00148 00153 int32_t get_cache_size(); 00154 00161 virtual int32_t get_num_vectors() const=0; 00162 00171 virtual bool reshape(int32_t num_features, int32_t num_vectors); 00172 00179 virtual int32_t get_size()=0; 00180 00182 void list_feature_obj(); 00183 00188 virtual void load(CFile* loader); 00189 00194 virtual void save(CFile* writer); 00195 00201 bool check_feature_compatibility(CFeatures* f); 00202 00208 bool has_property(EFeatureProperty p); 00209 00214 void set_property(EFeatureProperty p); 00215 00220 void unset_property(EFeatureProperty p); 00221 00227 virtual void set_subset(CSubset* subset); 00228 00231 virtual void remove_subset(); 00232 00234 virtual void subset_changed_post() {} 00235 00241 index_t subset_idx_conversion(index_t idx) const; 00242 00246 bool has_subset() const; 00247 00257 virtual CFeatures* copy_subset(SGVector<index_t> indices); 00258 00259 private: 00261 uint64_t properties; 00262 00264 int32_t cache_size; 00265 00267 CPreprocessor** preproc; 00268 00270 int32_t num_preproc; 00271 00273 bool* preprocessed; 00274 00275 protected: 00276 00278 CSubset* m_subset; 00279 }; 00280 } 00281 #endif